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
/
overhang_type.py
executable file
·72 lines (56 loc) · 1.7 KB
/
overhang_type.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
#!/usr/bin/env python
import sys
import random
import restrictlib
def writeQuestion(enzyme_class, overhang_type):
name = restrictlib.html_monospace(enzyme_class.__name__)
cut_description = restrictlib.html_monospace(restrictlib.format_enzyme(enzyme_class))
question = "11. The restriction enzyme <b>{0}</b> cuts the sequence: {1}. ".format(name, cut_description)
question += "Which one of the following is the "
question += "correct name for the type of cut this enzyme produces? "
overhang = enzyme_class.overhang()
answer = None
choices = []
if overhang_type is True:
answer = overhang
choices.append("5' overhang")
choices.append("3' overhang")
choices.append("blunt")
else:
if overhang.endswith("overhang"):
answer = "sticky end"
elif overhang == "blunt":
answer = "blunt end"
choices.append("overhang end")
choices.append("hanger end")
choices.append("blunt end")
choices.append("straight edge")
choices.append("sticky end")
if answer is None:
print("ERROR")
print("ERROR")
print("ERROR")
sys.exit(1)
print(question)
#============================
random.shuffle(choices)
charlist = "ABCDE"
for i in range(len(choices)):
choice_msg = choices[i]
letter = charlist[i]
prefix = ""
if choice_msg == answer:
prefix = "*"
print("{0}{1}. {2}".format(prefix, letter, choice_msg))
print("")
if __name__ == '__main__':
if len(sys.argv) >= 2:
overhang_type = False
else:
#just the name
overhang_type = True
enzyme_names = restrictlib.get_enzyme_list()
for enzyme_name in enzyme_names:
enzyme_class = restrictlib.enzyme_name_to_class(enzyme_name)
writeQuestion(enzyme_class, overhang_type)
#A. 5'-TGCA-3' B. 5'-CTGCA-3' C. 5'-TGCAG-3' D. 5'-ACGT-3'