Code to work with GenePop.
See http://wbiomed.curtin.edu.au/genepop/ , the format is documented here: http://wbiomed.curtin.edu.au/genepop/help_input.html .
Classes: Record Holds GenePop data.
Functions: read Parses a GenePop record (file) into a Record object.
Partially inspired by MedLine Code.
Extract the details of the individual information on the line.
Parse a handle containing a GenePop file.
handle is a file-like object that contains a GenePop record.
- class Bio.PopGen.GenePop.Record¶
Hold information from a GenePop record.
marker_len The marker length (2 or 3 digit code per allele).
comment_line Comment line.
loci_list List of loci names.
pop_list List of population names.
populations List of population data.
In most genepop files, the population name is not trustable. It is strongly recommended that populations are referred by index.
populations has one element per population. Each element is itself a list of individuals, each individual is a pair composed by individual name and a list of alleles (2 per marker or 1 for haploids): Example:
[ [ ('Ind1', [(1,2), (3,3), (200,201)], ('Ind2', [(2,None), (3,3), (None,None)], ], [ ('Other1', [(1,1), (4,3), (200,200)], ] ]
Initialize the class.
Return (reconstruct) a GenePop textual representation.
- split_in_pops(self, pop_names)¶
Split a GP record in a dictionary with 1 pop per entry.
Given a record with n pops and m loci returns a dictionary of records (key pop_name) where each item is a record with a single pop and m loci.
Arguments: - pop_names - Population names
- split_in_loci(self, gp)¶
Split a GP record in a dictionary with 1 locus per entry.
Given a record with n pops and m loci returns a dictionary of records (key locus name) where each item is a record with a single locus and n pops.
- remove_population(self, pos)¶
Remove a population (by position).
- remove_locus_by_position(self, pos)¶
Remove a locus by position.
- remove_locus_by_name(self, name)¶
Remove a locus by name.