PopGen Genepop

(Difference between revisions)
Jump to: navigation, search
m
(Ongoing development of documentation)
Line 1: Line 1:
=Genepop support.=
+
Two interfaces are supplied: A general, more complex and more efficient one (GenePopController) and a simplified, more easy to use, not complete and not so efficient version (EasyController). EasyController might not be able to handle very large files, by virtue of its interface.
  
Genepop support is actually 2 things: The support for the file format, the de facto standard in frequency analysis in population genetics and the support for the application itself.
+
The more complex interface assumes more proficient Python developers (e.g., by the use of iterators) and for now it is not documented. But even for experienced Python developers, EasyController can be convenient as long as the required functionality is exposed in EasyController and its performance is deemed acceptable.
  
==File format==
+
In order for the controllers to be used, Genepop has to be installed in the system, it can be dowloaded from [http://kimura.univ-montp2.fr/~rousset/Genepop.htm here].
  
The current implementation of the parser reads the whole file to a memory structure. This might not be acceptable for very big files with thousands of individuals and thousands of loci. An iterator version is under construction.
+
==EasyController tutorial==
  
The parser is strict regarding the format (i.e., the individual identifier is expected to terminate in a comma). Some applications are less strict, but there is no intention for now to support a relaxed version of the specification.
+
Before we start, lets test the installation (for this you need a genepop formated file):
  
According to the specification, the last individual of each population is also the subpopulation identifier. This is not great design and in reality users many times forget this. As such the expectation that the last individual id is the subpopulation id many times does not happen.
+
<python>
 +
from Bio.PopGen.GenePop.EasyController import EasyController
  
==Application support==
+
ctrl = EasyController(your_file_here)
 +
print ctrl.get_basic_info()
 +
</python>
  
Two interfaces are supplied: A general, more complex and more efficient one (GenePopController) and a simplified, more easy to use, not complete and not so efficient version (EasyController)
+
Replace your_file_here with the name and path to your file. If you get a '''IOError: Genepop not found''' then Biopython cannot find your Genepop executable. If Genepop is not on the PATH, you can add it to the constructor line, i.e.
 +
 
 +
<python>
 +
ctrl = EasyController(your_file_here, path_to_genepop_here)
 +
</python>
 +
 
 +
If everything is working, now we can go on and use Genepop. For the examples below, we will use the genepop file [http://biopython.open-bio.org/SRC/biopython/Tests/PopGen/big.gen big.gen] made available with the unit tests.

Revision as of 11:01, 3 July 2009

Two interfaces are supplied: A general, more complex and more efficient one (GenePopController) and a simplified, more easy to use, not complete and not so efficient version (EasyController). EasyController might not be able to handle very large files, by virtue of its interface.

The more complex interface assumes more proficient Python developers (e.g., by the use of iterators) and for now it is not documented. But even for experienced Python developers, EasyController can be convenient as long as the required functionality is exposed in EasyController and its performance is deemed acceptable.

In order for the controllers to be used, Genepop has to be installed in the system, it can be dowloaded from here.

EasyController tutorial

Before we start, lets test the installation (for this you need a genepop formated file):

from Bio.PopGen.GenePop.EasyController import EasyController
 
ctrl = EasyController(your_file_here)
print ctrl.get_basic_info()

Replace your_file_here with the name and path to your file. If you get a IOError: Genepop not found then Biopython cannot find your Genepop executable. If Genepop is not on the PATH, you can add it to the constructor line, i.e.

ctrl = EasyController(your_file_here, path_to_genepop_here)

If everything is working, now we can go on and use Genepop. For the examples below, we will use the genepop file big.gen made available with the unit tests.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox