-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplc.py
More file actions
84 lines (73 loc) · 2.13 KB
/
splc.py
File metadata and controls
84 lines (73 loc) · 2.13 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
import pyperclip as pc
codons = {
'AUG': 'M', 'UGG': 'W',
'UUU': 'F', 'UUC': 'F',
'UUA': 'L', 'UUG': 'L', 'CUU': 'L', 'CUC': 'L', 'CUA': 'L', 'CUG': 'L',
'AUU': 'I', 'AUC': 'I', 'AUA': 'I',
'GUU': 'V', 'GUC': 'V', 'GUA': 'V', 'GUG': 'V',
'UCU': 'S', 'UCC': 'S', 'UCA': 'S', 'UCG': 'S', 'AGU': 'S', 'AGC': 'S',
'CCU': 'P', 'CCC': 'P', 'CCA': 'P', 'CCG': 'P',
'ACU': 'T', 'ACC': 'T', 'ACA': 'T', 'ACG': 'T',
'GCU': 'A', 'GCC': 'A', 'GCA': 'A', 'GCG': 'A',
'UAU': 'Y', 'UAC': 'Y',
'CAU': 'H', 'CAC': 'H',
'CAA': 'Q', 'CAG': 'Q',
'AAU': 'N', 'AAC': 'N',
'AAA': 'K', 'AAG': 'K',
'GAU': 'D', 'GAC': 'D',
'GAA': 'E', 'GAG': 'E',
'UGU': 'C', 'UGC': 'C',
'CGU': 'R', 'CGC': 'R', 'CGA': 'R', 'CGG': 'R', 'AGA': 'R', 'AGG': 'R',
'GGU': 'G', 'GGC': 'G', 'GGA': 'G', 'GGG': 'G',
'UAA': 'Stop', 'UAG': 'Stop', 'UGA': 'Stop'
}
def fasta(lines):
data = {}
label = ""
seq = ""
for line in lines:
if line.startswith(">"):
if label:
data[label] = seq
label = line[1:]
seq = ""
else:
seq += line.strip()
if label:
data[label] = seq
return data
def remove(dna, introns):
for intron in introns:
dna = dna.replace(intron, '')
return dna
def transcribe(dna):
return dna.replace('T', 'U')
def translate(mrna):
protein = []
for i in range(0, len(mrna), 3):
codon = mrna[i:i+3]
if len(codon) == 3:
aa = codons.get(codon, '')
if aa == 'Stop':
break
protein.append(aa)
return ''.join(protein)
def process(data):
parsed = fasta(data)
dna = list(parsed.values())[0]
introns = list(parsed.values())[1:]
exons = remove(dna, introns)
mrna = transcribe(exons)
protein = translate(mrna)
return protein
if __name__ == "__main__":
lines = []
while True:
line = input().strip()
if line == 'q':
break
lines.append(line)
result = process(lines)
print('---\n'+result)
pc.copy(result)
print('copied to clipboard')