mod popmap

module popmap

Population map: maps individual names to groups (e.g. M/F).

Structs and Unions

struct GroupConfig

Configuration for group comparison.

group1: String
group2: String
struct Popmap

Population map storing individual-to-group assignments and group counts. Uses IndexMap for group_counts to preserve insertion order (matching C++ unordered_map behavior where first-seen group becomes group1).

individual_groups: HashMap<String, String>

individual_name -> group_name

group_counts: IndexMap<String, u32>

group_name -> count of individuals (insertion-ordered)

n_individuals: u16

Total number of individuals

Implementations

impl Popmap

Functions

fn from_file(path: &Path) -> io::Result<Self>

Load a popmap from a TSV file (individualtgroup per line).

fn get_count(&self, group: &str) -> u32

Get the count of individuals in a group.

fn get_group(&self, individual: &str) -> Option<&str>

Get the group for an individual.

fn print_groups(&self, with_counts: bool) -> String

Format groups for display.

fn resolve_groups(&self, config: &mut GroupConfig) -> Result<(), String>

Resolve group1/group2 from the popmap when not specified by the user. Returns an error message if validation fails.