Changes

From Genome Analysis Wiki
Jump to navigationJump to search
Line 55: Line 55:  
= Getting the genotypes from a genotype index and a given ploidy =
 
= Getting the genotypes from a genotype index and a given ploidy =
    +
  The genotype index is computed by a summation of a series which is
 +
  monotonically decreasing.  This allows you to compute the inverse function
 +
  from index to the ordered genotypes by using a "water rapids algorithm" with
 +
  decreasing height of each mini water fall.
 +
 
   std::vector<int32_t> bcf_ip2g(int32_t genotype_index, uint32_t no_ploidy)
 
   std::vector<int32_t> bcf_ip2g(int32_t genotype_index, uint32_t no_ploidy)
 
   {
 
   {
Line 66: Line 71:  
         {
 
         {
 
             int32_t i = choose(pth+allele_index-1, pth);
 
             int32_t i = choose(pth+allele_index-1, pth);
             if (i>=leftover_genotype_index)
+
             if (i>=leftover_genotype_index || allele_index==max_allele_index)
 
             {
 
             {
 
                 if (i>leftover_genotype_index) --allele_index;
 
                 if (i>leftover_genotype_index) --allele_index;
1,102

edits

Navigation menu