Beispiel #1
0
def setup_80freq():
    pop = Population()
    for i in range(600):
        ind = pop.founder_individual()
        ind.genotypes = [[[1], [1]]]
    for i in range(400):
        ind = pop.founder_individual()
        ind.genotypes = [[[2], [1]]]
    return pop
Beispiel #2
0
def setup_80freq():
    pop = Population()
    for i in range(600):
        ind = pop.founder_individual()
        ind.genotypes = [ [ [1],[1] ] ]
    for i in range(400):
        ind = pop.founder_individual()
        ind.genotypes = [ [ [2],[1] ] ]
    return pop
Beispiel #3
0
def test_major_allele():
    pop = Population()

    # 2000 A alleles
    for x in range(1000):
        ind = pop.founder_individual()
        ind.genotypes = [(Alleles([1]), Alleles([1]))]
    # 500 A alleles, 500 B
    for x in range(500):
        ind = pop.founder_individual()
        ind.genotypes = [(Alleles([1]), Alleles([2]))]
    assert pop.major_allele((0, 0)) == 1
Beispiel #4
0
def test_allele_list():
    pop = Population()
    loc = 0, 0
    # 2000 A alleles
    for x in range(1000):
        ind = pop.founder_individual()
        ind.genotypes = [(Alleles([1]), Alleles([1]))]
    # 500 A alleles, 500 B
    for x in range(500):
        ind = pop.founder_individual()
        ind.genotypes = [(Alleles([1]), Alleles([2]))]
    assert sorted(pop.allele_list(loc)) == [1] * 2500 + [2] * 500
Beispiel #5
0
def test_major_allele():
    pop = Population()

    # 2000 A alleles
    for x in range(1000):
        ind = pop.founder_individual()
        ind.genotypes = [ (Alleles([1]), Alleles([1]) )]
    # 500 A alleles, 500 B
    for x in range(500):
        ind = pop.founder_individual()
        ind.genotypes = [ (Alleles([1]), Alleles([2]) )]
    assert pop.major_allele((0,0)) == 1
Beispiel #6
0
def test_allele_list():
    pop = Population()
    loc = 0,0
    # 2000 A alleles
    for x in range(1000):
        ind = pop.founder_individual()
        ind.genotypes = [ (Alleles([1]), Alleles([1]) )]
    # 500 A alleles, 500 B
    for x in range(500):
        ind = pop.founder_individual()
        ind.genotypes = [ (Alleles([1]), Alleles([2]) )]
    assert sorted(pop.allele_list(loc)) == [1]*2500 + [2]*500
Beispiel #7
0
def test_ld():
    # Data from Hartl & Clark, Table 2.2 (pg 85)
    haplotypes = chain([Alleles(['A','B'])] * 25,
        [Alleles(['A','b'])] * 475, [Alleles(['a','B'])] * 475,
        [Alleles(['a','b'])] * 9025)

    pop = Population()
    for chroms in grouper(haplotypes,2):
        ind = pop.founder_individual()
        ind.genotypes = [chroms]

    known_D = 0
    assert pop.ld( (0,0), (0,1), method='D') == known_D