def test_equality(): assert GeneAllele('J') == GeneAllele('J')
def test_genotype_identity(): a = GeneAllele('h') b = GeneAllele('H') assert Genotype(a, b) == Genotype(a, b)
def test_different_value_case_are_not_same(): assert GeneAllele('F') != GeneAllele('f')
def test_incorrect_non_gene_allele_arguments(): a = GeneAllele('k') b = 42 with pytest.raises(ValueError): Genotype(a, b)
def test_to_str(): a = GeneAllele('C') b = GeneAllele('c') g = Genotype(a, b) assert str(g) == 'Cc'
def test_incorrect_genotype_identity(): a = GeneAllele('l') b = GeneAllele('L') assert Genotype(a, b) != Genotype(b, a)
def test_incorrect_different_gene_allele_types(): a = GeneAllele('z') b = GeneAllele('c') with pytest.raises(ValueError): Genotype(a, b)
def test_sample_genotype_1(): verbose_genotype = Genotype(GeneAllele('C'), GeneAllele('c')) convenient_genotype = create_genotype('Cc') assert convenient_genotype == verbose_genotype
def create_genotype(genotype_str: str): if type(genotype_str) != str: raise ValueError('genotype_str must be a string!') if len(genotype_str) != 2: raise ValueError('genotype_str must have length of 2 characters!') return Genotype(GeneAllele(genotype_str[0]), GeneAllele(genotype_str[1]))
def test_gender_breeding_with_XX_XY_chromosome(): f = XXGenotype(GeneAllele("A"),GeneAllele("a")) m = XYGenotype(GeneAllele("A")) results = [str(g) for g in gender_breed(f, m)] assert results == ["X^AX^A","X^AY","X^aX^A","X^aY"]
def test_sample_breeding_a(): a = Genotype(GeneAllele('Z'), GeneAllele('z')) b = Genotype(GeneAllele('Z'), GeneAllele('z')) breeding_results = [str(genotype) for genotype in breed(a, b)] assert breeding_results == ['ZZ', 'Zz', 'zZ', 'zz']
#!/usr/bin/env python3 from gene_convenience import create_genotype as G from gene import XYGenotype, XXGenotype, GeneAllele from table_gen import create_table, create_gender_table # create_table(G('Aa'), G('Aa')) create_gender_table(XXGenotype(GeneAllele('A'), GeneAllele('a')), XYGenotype(GeneAllele('a')))
def test_xy_genotype(): m = XYGenotype(GeneAllele('H')) assert m.gene_allele.value == 'H'
def test_xx_genotype_mismatched_gene_alleles(): with pytest.raises(ValueError): XXGenotype(GeneAllele('k'), GeneAllele('l'))
def test_xx_genotype_wrong_arg_type(): with pytest.raises(ValueError): XXGenotype(GeneAllele('c'), 39)
def test_xx_genotype(): f = XXGenotype(GeneAllele('L'), GeneAllele('l')) assert f.gene_allele_a.value == 'L' and f.gene_allele_b.value == 'l'