forked from 4dsolutions/Python5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenetics.py
More file actions
217 lines (191 loc) · 6.14 KB
/
genetics.py
File metadata and controls
217 lines (191 loc) · 6.14 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 16 10:07:57 2015
@author: kurner, 4dsolutions (.net)
(copyleft MIT license, 2015)
Example: Rich Data Structures
(for learning Python, including sqlite3)
Source:
http://www.soc-bdr.org/rds/authors/unit_tables_conversions_and_genetic_dictionaries/e5202/index_en.html
Any errors you discover in transcribing will be mine, please
let me know and I'll correct my copy as well.
kirby.urner@gmail.com
Re: "Rich Data Structures"
https://mail.python.org/pipermail/edu-sig/2006-June/006608.html
(a more obvious need now that "big data" examples are in demand,
for learning map/reduce techniques etc.). Indeed, we have many
public raw data sets. A goal is to have some already in Python,
as ready-to-go native data types. As here. This is not "big
data", just data.
Another experiment:
https://mail.python.org/pipermail/edu-sig/2012-December/010709.html
(same caveats about errors)
Adding to PythonAnywhere/thekirbster account for sharing with <guild />
classes etc. You may wish to contribute to Github projects from your
PythonAnywhere account.
"""
amino_acid_abbrevs = \
dict(
Phe = 'Phenyalinine',
Leu = 'Leucine',
Ser = 'Serine',
Tyr = 'Tyrosine',
Cys = 'Cysteine',
Trp = 'Tryptophan',
Pro = 'Proline',
His = 'Histidine',
Gln = 'Glutamine',
Arg = 'Arginine',
Ile = 'Isoleucine',
Met = 'Methionine',
Thr = 'Threonine',
Asn = 'Asparagine',
Lys = 'Lysine',
Val = 'Valine',
Ala = 'Alanine',
Asp = 'Aspartate',
Glu = 'Glutamate',
Cly = 'Glycine')
combos = [(a, b, c) for a in ('G','U','A','C')
for b in ('G','U','A','C')
for c in ('G','U','A','C')]
# Also see:
# https://flic.kr/p/BeVwN2
# (American Scientist Vol. 97)
mRNA = \
{
('G', 'G', 'G') : 'Gly',
('G', 'G', 'U') : 'Gly',
('G', 'G', 'A') : 'Gly',
('G', 'G', 'C') : 'Gly',
('G', 'U', 'G') : 'Val',
('G', 'U', 'U') : 'Val',
('G', 'U', 'A') : 'Val',
('G', 'U', 'C') : 'Val',
('G', 'A', 'G') : 'Glu',
('G', 'A', 'U') : 'Asp',
('G', 'A', 'A') : 'Glu',
('G', 'A', 'C') : 'Asp',
('G', 'C', 'G') : 'Ala',
('G', 'C', 'U') : 'Ala',
('G', 'C', 'A') : 'Ala',
('G', 'C', 'C') : 'Ala',
('U', 'G', 'G') : 'Trp',
('U', 'G', 'U') : 'Cys',
('U', 'G', 'A') : 'STOP',
('U', 'G', 'C') : 'Cys',
('U', 'U', 'G') : 'Leu',
('U', 'U', 'U') : 'Phe',
('U', 'U', 'A') : 'Leu',
('U', 'U', 'C') : 'Phe',
('U', 'A', 'G') : 'STOP',
('U', 'A', 'U') : 'Tyr',
('U', 'A', 'A') : 'STOP',
('U', 'A', 'C') : 'Tyr',
('U', 'C', 'G') : 'Ser',
('U', 'C', 'U') : 'Ser',
('U', 'C', 'A') : 'Ser',
('U', 'C', 'C') : 'Ser',
('A', 'G', 'G') : 'Arg',
('A', 'G', 'U') : 'Ser',
('A', 'G', 'A') : 'Arg',
('A', 'G', 'C') : 'Ser',
('A', 'U', 'G') : 'Met',
('A', 'U', 'U') : 'Ile',
('A', 'U', 'A') : 'Ile',
('A', 'U', 'C') : 'Ile',
('A', 'A', 'G') : 'Lys',
('A', 'A', 'U') : 'Asn',
('A', 'A', 'A') : 'Lys',
('A', 'A', 'C') : 'Asn',
('A', 'C', 'G') : 'Thr',
('A', 'C', 'U') : 'Thr',
('A', 'C', 'A') : 'Thr',
('A', 'C', 'C') : 'Thr',
('C', 'G', 'G') : 'Arg',
('C', 'G', 'U') : 'Arg',
('C', 'G', 'A') : 'Arg',
('C', 'G', 'C') : 'Arg',
('C', 'U', 'G') : 'Leu',
('C', 'U', 'U') : 'Leu',
('C', 'U', 'A') : 'Leu',
('C', 'U', 'C') : 'Leu',
('C', 'A', 'G') : 'Gln',
('C', 'A', 'U') : 'His',
('C', 'A', 'A') : 'Gln',
('C', 'A', 'C') : 'His',
('C', 'C', 'G') : 'Pro',
('C', 'C', 'U') : 'Pro',
('C', 'C', 'A') : 'Pro',
('C', 'C', 'C') : 'Pro'}
# [Ibid, www.soc-bdr.org] from Table 5. Genetic Code:
# mRNA condon -> tRNA anti-codon
# DNA column dropped (computable, replace mRNA U with T)
# last column also not included.
tRNA = \
{
('U','U','U'):(('A','A','A'), ('A','A','G')),
('U','U','C'):(('A','A','G'),),
('U','U','A'):(('A','A','U'),),
('U','U','G'):(('A','A','U'),('A','A','C')),
('U','C','U'):(('A','G','I'),('A','G','G'), ('A','G','A')),
('U','C','C'):(('A','G','I'),('A','G','G')),
('U','C','A'):(('A','G','I'),('A','G','U')),
('U','C','G'):(('A','G','C'),('A','G','U')),
('U','A','U'):(('A','U','A'),('A','U','G'),),
('U','A','C'):(('A','U','G'),),
('U','A','A'):(('A','U','U'),),
('U','A','G'):(('A','U','C'),('A','U','U')),
('U','G','U'):(('A','C','A'),('A','C','G')),
('U','G','C'):(('A','C','G'),),
('U','G','A'):(('A','C','U'),),
('U','G','G'):(('A','C','C'),),
('C','U','U'):(('G','A','I'),('G','A','G'),('G','A','A')),
('C','U','C'):(('G','A','I'),('G','A','G')),
('C','U','A'):(('G','A','I'),('G','A','U')),
('C','U','G'):(('G','A','C'),('G','A','U')),
('C','C','U'):(('G','G','I'),('G','G','G'),('G','G','A')),
('C','C','C'):(('G','G','I'),('G','G','G')),
('C','C','A'):(('G','G','I'),('G','G','U')),
('C','C','G'):(('G','G','C'),('G','G','U')),
('C','A','U'):(('G','U','A'),('G','U','G')),
('C','A','C'):(('G','U','G'),),
('C','A','A'):(('G','U','U'),),
('C','A','G'):(('G','U','C'),('G','U','U')),
('C','G','U'):(('G','C','I'),('G','C','G'),('G','C','A')),
('C','G','C'):(('G','C','I'),('G','C','G')),
('C','G','A'):(('G','C','I'),('G','C','U')),
('C','G','G'):(('G','C','C'),('G','C','U')),
('A','U','U'):(('U','A','I'),('U','A','G'),('U','A','A')),
('A','U','C'):(('U','A','I'),('U','A','G')),
('A','U','A'):(('U','A','I'),('U','A','U')),
('A','U','G'):(('U','A','C'),),
('A','C','U'):(('U','G','I'),('U','G','G'),('U','G','A')),
('A','C','C'):(('U','G','I'),('U','G','G')),
('A','C','A'):(('U','G','I'),('U','G','U')),
('A','C','G'):(('U','G','C'),('U','G','U')),
('A','A','U'):(('U','U','A'),('U','U','G')),
('A','A','C'):(('U','U','G'),),
('A','A','A'):(('U','U','U'),),
('A','A','G'):(('U','U','C'),('U','U','U')),
('A','G','U'):(('U','C','A'),('U','C','G')),
('A','G','C'):(('U','C','G'),),
('A','G','A'):(('U','C','U'),),
('A','G','G'):(('U','C','C'),('U','C','U')),
('G','U','U'):(('C','A','I'),('C','A','G'),('C','A','A')),
('G','U','C'):(('C','A','I'),('C','A','G')),
('G','U','A'):(('C','A','I'),('C','A','U')),
('G','U','G'):(('C','A','C'),('C','A','U')),
('G','C','U'):(('C','G','I'),('C','G','G'),('C','G','A')),
('G','C','C'):(('C','G','I'),('C','G','G')),
('G','C','A'):(('C','G','I'),('C','G','U')),
('G','C','G'):(('C','G','C'),('C','G','U')),
('G','A','U'):(('C','U','G'),('C','U','A')),
('G','A','C'):(('C','U','G'),),
('G','A','A'):(('C','U','U'),),
('G','A','G'):(('C','U','U'),('C','U','C')),
('G','G','U'):(('C','C','I'),('C','C','G'),('C','C','A')),
('G','G','C'):(('C','C','I'),('C','C','G')),
('G','G','A'):(('C','C','I'),('C','C','U')),
('G','G','G'):(('C','C','C'),('C','C','U'))
}