Changes

From Genome Analysis Wiki
Jump to navigationJump to search
Line 102: Line 102:     
= Algorithm for enumerating the genotypes given A ploidy and alleles =
 
= Algorithm for enumerating the genotypes given A ploidy and alleles =
 +
 +
    uint32_t no = 0 // some global variable
 +
    void print_genotypes(uint32_t A, uint32_t P, std::string genotype)
 +
    {
 +
        if (genotype.size()==P)
 +
        {
 +
            std::cerr << no << ") " << genotype << "\n";
 +
            ++no;
 +
        }
 +
        else
 +
        {
 +
            for (uint32_t a=0; a<A; ++a)
 +
            {
 +
                std::string s(1,(char)(a+65));
 +
                s.append(genotype);
 +
                print_genotypes(a+1, P, s);
 +
            }
 +
        }
 +
    }
1,102

edits

Navigation menu