Beispiel #1
0
def test_2_genotype_breeding_1():
    mg1 = MultiGenotype(G('Aa'), G('Bb'))
    mg2 = MultiGenotype(G('Aa'), G('Bb'))
    assert mg1.breed(mg2) == [
        'AABB', 'AABb', 'AaBB', 'AaBb', 'AAbB', 'AAbb', 'AabB', 'Aabb', 'aABB',
        'aABb', 'aaBB', 'aaBb', 'aAbB', 'aAbb', 'aabB', 'aabb'
    ]
Beispiel #2
0
def test_2_genotype_breeding_2():
    mg1 = MultiGenotype(G('ff'), G('cC'))
    mg2 = MultiGenotype(G('fF'), G('cc'))
    assert mg1.breed(mg2) == [
        'ffcc',
        'ffcc',
        'fFcc',
        'fFcc',
        'ffCc',
        'ffCc',
        'fFCc',
        'fFCc',
        'ffcc',
        'ffcc',
        'fFcc',
        'fFcc',
        'ffCc',
        'ffCc',
        'fFCc',
        'fFCc',
    ]
Beispiel #3
0
def create_multi_gene_table(mg_a: MultiGenotype, mg_b: MultiGenotype):
    document = Document()

    document.add_paragraph(f"P ♀ {str(mg_a)} x ♂ {str(mg_b)}")

    square_size = len(mg_a.genotypes) * len(mg_b.genotypes)

    table = document.add_table(rows=square_size + 1, cols=square_size + 1)

    def set_cell(row, col, val):
        table.rows[row].cells[col].text = val

    multi_genotype_breeding_results = mg_a.breed(mg_b)

    genotype_variations_a_temp = list(
        product(*[str(g) for g in mg_a.genotypes]))
    genotype_variations_b_temp = list(
        product(*[str(g) for g in mg_b.genotypes]))

    genotype_variations_a = ["".join(x) for x in genotype_variations_a_temp]
    genotype_variations_b = ["".join(x) for x in genotype_variations_b_temp]

    set_cell(0, 0, "♀ \ ♂")

    for i, genotype in enumerate(genotype_variations_a):
        set_cell(i + 1, 0, genotype)

    for i, genotype in enumerate(genotype_variations_b):
        set_cell(0, i + 1, genotype)

    element_counter = 0
    for row in range(square_size):
        for column in range(square_size):
            set_cell(row + 1, column + 1,
                     multi_genotype_breeding_results[element_counter])
            element_counter += 1

    document.save('mgene_sample.docx')
Beispiel #4
0
def test_misshapen_multi_genotypes():
    mg1 = MultiGenotype(G('kK'), G('Ll'))
    mg2 = MultiGenotype(G('kk'), G('ll'), G('cC'))
    with pytest.raises(ValueError):
        mg1.breed(mg2)
Beispiel #5
0
def test_2_genotypes():
    assert str(MultiGenotype(G('Aa'), G('cc'))) == 'Aacc'
Beispiel #6
0
def test_incompatible_multi_genotypes():
    mg1 = MultiGenotype(G('kK'), G('yY'))
    mg2 = MultiGenotype(G('kk'), G('sS'))
    with pytest.raises(ValueError):
        mg1.breed(mg2)
Beispiel #7
0
def test_no_duplicate_genotype_classes():
    with pytest.raises(ValueError):
        MultiGenotype(G('Zz'), G('ZZ'))
Beispiel #8
0
def test_equality_2():
    assert MultiGenotype(G('bb'), G('cc')) != MultiGenotype(G('BB'), G('CC'))
Beispiel #9
0
def test_equality_1():
    assert MultiGenotype(G('ll'), G('Aa')) == MultiGenotype(G('ll'), G('Aa'))
Beispiel #10
0
def test_wrong_args():
    with pytest.raises(ValueError):
        MultiGenotype(G('Cc'), 42)
Beispiel #11
0
def test_3_genotypes():
    assert str(MultiGenotype(G('kK'), G('FF'), G('Rr'))) == 'kKFFRr'
Beispiel #12
0
from table_gen import create_multi_gene_table
from gene_convenience import create_genotype as g
from gene import MultiGenotype

MGenotype1 = MultiGenotype(g("Aa"), g("Bb"))
MGenotype2 = MultiGenotype(g("Aa"), g("Bb"))

create_multi_gene_table(MGenotype1, MGenotype2)