This repository has been archived by the owner on Oct 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blood_type_offspring.py
executable file
·79 lines (74 loc) · 1.92 KB
/
blood_type_offspring.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
import os
phenotypes = ['O', 'A', 'B', 'AB',]
genotypes = ['OO', 'AO', 'BO', 'AB',]
pmap = {
'O': 'OO',
'A': 'AO',
'B': 'BO',
'AB': 'AB',
}
gmap = {
'OO': 'O',
'AO': 'A',
'OA': 'A',
'AA': 'A',
'BO': 'B',
'OB': 'B',
'BB': 'B',
'AB': 'AB',
'BA': 'AB',
}
if __name__ == '__main__':
N = 0
"""
choices = []
for pheno in phenotypes:
choice = "Type {0} blood".format(pheno)
choices.append(choice)
print(choices)
"""
letters = "ABCDEF"
outfile = 'bbq-' + os.path.splitext(os.path.basename(__file__))[0] + '-questions.txt'
print('writing to file: '+outfile)
f = open(outfile, 'w')
for pheno1 in phenotypes:
for pheno2 in phenotypes:
answers = set()
N += 1
number = "{0}. ".format(N)
question = '<span style="font-family: times new roman, times; font-size: large;">'
question += 'For the ABO blood group in humans, the i<sup>A</sup> and i<sup>B</sup> alleles are codominant and the i allele is recessive. '
question += "If a female ♀ with <u>type {0} blood</u> marries a male ♂ with <u>type {1} blood</u>, ".format(pheno1, pheno2)
question += "which of the following blood types could their children possibly have? "
question += "Check all that apply.</span>"
print(number+question)
geno1 = pmap[pheno1]
geno2 = pmap[pheno2]
for allele1 in geno1:
for allele2 in geno2:
geno = allele1+allele2
pheno = gmap[geno]
answers.add(pheno)
#print(answers)
f.write("MA\t"+question+"\t")
answermap = {}
i = 0
choices = []
for pheno in phenotypes:
choice = "Type {0} blood".format(pheno)
choices.append(choice)
f.write(choice+"\t")
if pheno in answers:
answermap[choice] = True
f.write("Correct\t")
prefix = '*'
else:
answermap[choice] = False
prefix = ''
f.write("Incorrect\t")
print("{0}{1}. {2}".format(prefix, letters[i], choice))
i += 1
print("\n")
f.write("\n")
f.close()