Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.PopGen.GenePop.EasyController.EasyController Class Reference

List of all members.

Public Member Functions

def __init__
def get_basic_info
def test_hw_pop
def test_hw_global
def test_ld_all_pair
def estimate_nm
def get_heterozygosity_info
def get_genotype_count
def get_fis
def get_alleles
def get_alleles_all_pops
def get_allele_frequency
def get_multilocus_f_stats
def get_f_stats
def get_avg_fis
def get_avg_fst_pair
def get_avg_fst_pair_locus
def calc_ibd

Private Attributes

 _fname
 _controller
 __fst_pair_locus
 __allele_frequency

Detailed Description

Definition at line 19 of file EasyController.py.


Constructor & Destructor Documentation

def Bio.PopGen.GenePop.EasyController.EasyController.__init__ (   self,
  fname,
  genepop_dir = None 
)
Initializes the controller.

genepop_dir is the directory where GenePop is.

The binary should be called Genepop (capital G)

Definition at line 20 of file EasyController.py.

00020 
00021     def __init__(self, fname, genepop_dir = None):
00022         """Initializes the controller.
00023         
00024         genepop_dir is the directory where GenePop is.
00025 
00026         The binary should be called Genepop (capital G)
00027         
00028         """
00029         self._fname = fname
00030         self._controller = GenePopController(genepop_dir)
00031         self.__fst_pair_locus = {} #More caches like this needed!
00032         self.__allele_frequency = {} #More caches like this needed!


Member Function Documentation

def Bio.PopGen.GenePop.EasyController.EasyController.calc_ibd (   self,
  is_diplo = True,
  stat = "a",
  scale = "Log",
  min_dist = 0.00001 
)

Definition at line 178 of file EasyController.py.

00178 
00179     def calc_ibd(self, is_diplo = True, stat="a", scale="Log", min_dist=0.00001):
00180         if is_diplo:
00181             return self._controller.calc_ibd_diplo(self._fname, stat, scale, min_dist)
00182         else:
00183             return self._controller.calc_ibd_haplo(self._fname, stat, scale, min_dist)
Estimate Nm. Just a simple bridge.

Definition at line 68 of file EasyController.py.

00068 
00069     def estimate_nm(self):
00070         """ Estimate Nm. Just a simple bridge.
00071         """
00072         return self._controller.estimate_nm(self._fname)

def Bio.PopGen.GenePop.EasyController.EasyController.get_allele_frequency (   self,
  pop_pos,
  locus_name 
)

Definition at line 129 of file EasyController.py.

00129 
00130     def get_allele_frequency(self, pop_pos, locus_name):
00131         if len(self.__allele_frequency) == 0:
00132             geno_freqs = self._controller.calc_allele_genotype_freqs(self._fname)
00133             pop_iter, loc_iter = geno_freqs
00134             for locus_info in loc_iter:
00135                 if locus_info[0] == None:
00136                     self.__allele_frequency[locus_info[0]] = None, None
00137                 else:
00138                     self.__allele_frequency[locus_info[0]] = locus_info[1:]
00139         info = self.__allele_frequency[locus_name]
00140         pop_name, freqs, total = info[1][pop_pos]
00141         allele_freq = {}
00142         alleles = info[0]
00143         for i in range(len(alleles)):
00144             allele_freq[alleles[i]] = freqs[i]
00145         return total, allele_freq
00146 

def Bio.PopGen.GenePop.EasyController.EasyController.get_alleles (   self,
  pop_pos,
  locus_name 
)
Returns the alleles for a certain population and locus.

Definition at line 110 of file EasyController.py.

00110 
00111     def get_alleles(self, pop_pos, locus_name):
00112         """Returns the alleles for a certain population and locus.
00113 
00114         """
00115         geno_freqs = self._controller.calc_allele_genotype_freqs(self._fname)
00116         pop_iter, loc_iter = geno_freqs
00117         pop_iter = list(pop_iter)
00118         return pop_iter[pop_pos][1][locus_name][2].keys()

Returns the alleles for a certain population and locus.

Definition at line 119 of file EasyController.py.

00119 
00120     def get_alleles_all_pops(self, locus_name):
00121         """Returns the alleles for a certain population and locus.
00122 
00123         """
00124         geno_freqs = self._controller.calc_allele_genotype_freqs(self._fname)
00125         pop_iter, loc_iter = geno_freqs
00126         for locus_info in loc_iter:
00127             if locus_info[0] == locus_name:
00128                 return locus_info[1]

Definition at line 165 of file EasyController.py.

00165 
00166     def get_avg_fis(self):
00167         return self._controller.calc_diversities_fis_with_identity(self._fname)[1]

Definition at line 168 of file EasyController.py.

00168 
00169     def get_avg_fst_pair(self):
00170         return self._controller.calc_fst_pair(self._fname)[1]

Definition at line 171 of file EasyController.py.

00171 
00172     def get_avg_fst_pair_locus(self, locus):
00173         if len(self.__fst_pair_locus) == 0:
00174             iter = self._controller.calc_fst_pair(self._fname)[0]
00175             for locus_info in iter:
00176                 self.__fst_pair_locus[locus_info[0]] = locus_info[1]
00177         return self.__fst_pair_locus[locus]

Definition at line 33 of file EasyController.py.

00033 
00034     def get_basic_info(self):
00035         f=open(self._fname)
00036         rec = GenePop.read(f)
00037         f.close()
00038         return rec.pop_list, rec.loci_list

Here is the call graph for this function:

Returns F stats for a locus

    Returns Fis(CW), Fst, Fit, Qintra, Qinter

Definition at line 155 of file EasyController.py.

00155 
00156     def get_f_stats(self, locus_name):
00157         """ Returns F stats for a locus
00158 
00159             Returns Fis(CW), Fst, Fit, Qintra, Qinter
00160         """
00161         loci_iter =  self._controller.calc_fst_all(self._fname)[1]
00162         for name, fis, fst, fit, qintra, qinter in loci_iter:
00163             if name == locus_name:
00164                 return fis, fst, fit, qintra, qinter

def Bio.PopGen.GenePop.EasyController.EasyController.get_fis (   self,
  pop_pos,
  locus_name 
)
Returns the Fis for a certain population and locus

   Below CW means Cockerham and Weir and RH means Robertson and Hill. 

   Returns a pair:
   dictionary [allele] = (repetition count, frequency, Fis CW )
       with information for each allele
   a triple with total number of alleles, Fis CW, Fis RH

Definition at line 93 of file EasyController.py.

00093 
00094     def get_fis(self, pop_pos, locus_name):
00095         """Returns the Fis for a certain population and locus
00096 
00097            Below CW means Cockerham and Weir and RH means Robertson and Hill. 
00098 
00099            Returns a pair:
00100            dictionary [allele] = (repetition count, frequency, Fis CW )
00101                with information for each allele
00102            a triple with total number of alleles, Fis CW, Fis RH
00103 
00104 
00105         """
00106         geno_freqs = self._controller.calc_allele_genotype_freqs(self._fname)
00107         pop_iter, loc_iter = geno_freqs
00108         pops = list(pop_iter)
00109         return pops[pop_pos][1][locus_name][2:]

def Bio.PopGen.GenePop.EasyController.EasyController.get_genotype_count (   self,
  pop_pos,
  locus_name 
)
Returns the genotype counts for a certain population and locus

Definition at line 84 of file EasyController.py.

00084 
00085     def get_genotype_count(self, pop_pos, locus_name):
00086         """Returns the genotype counts for a certain population and locus
00087 
00088         """
00089         geno_freqs = self._controller.calc_allele_genotype_freqs(self._fname)
00090         pop_iter, loc_iter = geno_freqs
00091         pop_iter = list(pop_iter)
00092         return pop_iter[pop_pos][1][locus_name][0]

Returns the heterozygosity info for a certain locus on a population.

   Returns (Expected homozygotes, observed homozygotes,
    Expected heterozygotes, observed heterozygotes)

Definition at line 73 of file EasyController.py.

00073 
00074     def get_heterozygosity_info(self, pop_pos, locus_name):
00075         """Returns the heterozygosity info for a certain locus on a population.
00076 
00077            Returns (Expected homozygotes, observed homozygotes,
00078                     Expected heterozygotes, observed heterozygotes)
00079         """
00080         geno_freqs = self._controller.calc_allele_genotype_freqs(self._fname)
00081         pop_iter, loc_iter = geno_freqs
00082         pops = list(pop_iter)
00083         return pops[pop_pos][1][locus_name][1]

Returns the multilocus F stats

    Explain averaging.
    Returns Fis(CW), Fst, Fit

Definition at line 147 of file EasyController.py.

00147 
00148     def get_multilocus_f_stats(self):
00149         """ Returns the multilocus F stats
00150 
00151             Explain averaging.
00152             Returns Fis(CW), Fst, Fit
00153         """
00154         return self._controller.calc_fst_all(self._fname)[0]

def Bio.PopGen.GenePop.EasyController.EasyController.test_hw_global (   self,
  test_type = "deficiency",
  enum_test = True,
  dememorization = 10000,
  batches = 20,
  iterations = 5000 
)

Definition at line 51 of file EasyController.py.

00051 
00052         dememorization = 10000, batches = 20, iterations = 5000):
00053         if test_type=="deficiency":
00054             pop_res, loc_res, all = self._controller.test_global_hz_deficiency(self._fname,
00055                 enum_test, dememorization, batches, iterations)
00056         else:
00057             pop_res, loc_res, all = self._controller.test_global_hz_excess(self._fname,
00058                 enum_test, dememorization, batches, iterations)
00059         return list(pop_res), list(loc_res), all

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.PopGen.GenePop.EasyController.EasyController.test_hw_pop (   self,
  pop_pos,
  test_type = "probability" 
)

Definition at line 39 of file EasyController.py.

00039 
00040     def test_hw_pop(self, pop_pos, test_type = "probability"):
00041         if test_type=="deficiency":
00042             hw_res = self._controller.test_pop_hz_deficiency(self._fname)
00043         elif test_type=="excess":
00044             hw_res = self._controller.test_pop_hz_excess(self._fname)
00045         else:
00046             loci_res, hw_res, fisher_full = self._controller.test_pop_hz_prob(self._fname, ".P")
00047         for i in range(pop_pos-1):
00048             hw_res.next()
00049         return hw_res.next()

Here is the call graph for this function:

def Bio.PopGen.GenePop.EasyController.EasyController.test_ld_all_pair (   self,
  locus1,
  locus2,
  dememorization = 10000,
  batches = 20,
  iterations = 5000 
)

Definition at line 61 of file EasyController.py.

00061 
00062         dememorization = 10000, batches = 20, iterations = 5000):
00063         all_ld = self._controller.test_ld(self._fname, dememorization, batches, iterations)[1]
00064         for ld_case in all_ld:
00065             (l1, l2), result = ld_case
00066             if (l1==locus1 and l2==locus2) or (l1==locus2 and l2==locus1):
00067                 return result

Here is the caller graph for this function:


Member Data Documentation

Definition at line 31 of file EasyController.py.

Definition at line 30 of file EasyController.py.

Definition at line 29 of file EasyController.py.

Definition at line 28 of file EasyController.py.


The documentation for this class was generated from the following file: