Package Bio :: Package PopGen :: Package GenePop :: Module FileParser :: Class FileRecord
[hide private]
[frames] | no frames]

Class FileRecord

source code

object --+
         |
        FileRecord

Hold information from a GenePop record.

Attributes: - marker_len The marker length (2 or 3 digit code per allele). - comment_line Comment line. - loci_list List of loci names.

Methods: - get_individual Returns the next individual of the current population. - skip_population Skips the current population.

skip_population skips the individuals of the current population, returns True if there are more populations.

get_individual returns an individual of the current population (or None if the list ended).

Each individual is a pair composed by individual name and a list of alleles (2 per marker or 1 for haploid data). Examples:

('Ind1', [(1,2),    (3,3), (200,201)]
('Ind2', [(2,None), (3,3), (None,None)]
('Other1', [(1,1),  (4,3), (200,200)]
Instance Methods [hide private]
 
__init__(self, fname)
Initialize the class.
source code
 
__str__(self)
Return (reconstructs) a GenePop textual representation.
source code
 
start_read(self)
Start parsing a file containing a GenePop file.
source code
 
skip_header(self)
Skip the Header. To be done after a re-open.
source code
 
seek_position(self, pop, indiv)
Seek a certain position in the file.
source code
 
skip_population(self)
Skip the current population. Returns true if there is another pop.
source code
 
get_individual(self)
Get the next individual.
source code
 
remove_population(self, pos, fname)
Remove a population (by position).
source code
 
remove_locus_by_position(self, pos, fname)
Remove a locus by position.
source code
 
remove_loci_by_position(self, positions, fname)
Remove a set of loci by position.
source code
 
remove_locus_by_name(self, name, fname)
Remove a locus by name.
source code
 
remove_loci_by_name(self, names, fname)
Remove a loci list (by name).
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, fname)
(Constructor)

source code 
Initialize the class.
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

Return (reconstructs) a GenePop textual representation.

This might take a lot of memory. Marker length will be 3.

Overrides: object.__str__

seek_position(self, pop, indiv)

source code 

Seek a certain position in the file.

Arguments:
  • pop - pop position (0 is first)
  • indiv - individual in pop

get_individual(self)

source code 

Get the next individual.

Returns individual information if there are more individuals in the current population. Returns True if there are no more individuals in the current population, but there are more populations. Next read will be of the following pop. Returns False if at end of file.

remove_population(self, pos, fname)

source code 

Remove a population (by position).

Arguments:
  • pos - position
  • fname - file to be created with population removed

remove_locus_by_position(self, pos, fname)

source code 

Remove a locus by position.

Arguments:
  • pos - position
  • fname - file to be created with locus removed

remove_loci_by_position(self, positions, fname)

source code 

Remove a set of loci by position.

Arguments:
  • positions - positions
  • fname - file to be created with locus removed

remove_locus_by_name(self, name, fname)

source code 

Remove a locus by name.

Arguments:
  • name - name
  • fname - file to be created with locus removed

remove_loci_by_name(self, names, fname)

source code 

Remove a loci list (by name).

Arguments:
  • names - names
  • fname - file to be created with loci removed