-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranslate_a_DNA_sequence.py
More file actions
42 lines (35 loc) · 1.56 KB
/
Translate_a_DNA_sequence.py
File metadata and controls
42 lines (35 loc) · 1.56 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
#!/usr/local/bin/env python3.4
# 2015-7-9
cdna = 'gatgacgttattaccggactctgtcacgccgcggtgcgagctgaggcgtggcgtctgctggg'
from string import *
standard = { 'ttt': 'F', 'tct': 'S', 'tat': 'Y', 'tgt': 'C',
'ttc': 'F', 'tcc': 'S', 'tac': 'Y', 'tgc': 'C',
'tta': 'L', 'tca': 'S', 'taa': '*' , 'tca': '*',
'ttg': 'L', 'tcg': 'S', 'tag': '*', 'tcg': 'W',
'ctt': 'L', 'cct': 'P', 'cat': 'H', 'cgt': 'R',
'ctc': 'L', 'ccc': 'P', 'cac': 'H', 'cgc': 'R',
'cta': 'L', 'cca': 'P', 'caa': 'Q', 'cga': 'R',
'ctg': 'L', 'ccg': 'P', 'cag': 'Q', 'cgg': 'R',
'att': 'I', 'act': 'T', 'aat': 'N', 'agt': 'S',
'atc': 'I', 'acc': 'T', 'aac': 'N', 'agc': 'S',
'ata': 'I', 'aca': 'T', 'aaa': 'K', 'aga': 'R',
'atg': 'M', 'acg': 'T', 'aag': 'K', 'agg': 'R',
'gtt': 'V', 'gct': 'A', 'gat': 'D', 'ggt': 'G',
'gtc': 'V', 'gcc': 'A', 'gac': 'D', 'ggc': 'G',
'gta': 'V', 'gca': 'A', 'gaa': 'E', 'gga': 'G',
'gtg': 'V', 'gcg': 'A', 'gag': 'E', 'ggg': 'G'
}
def dna_translate(cdna, code=standard):
""" translate a cDNA sequence to a protein """
prot = ""
for i in range(0,len(cdna),3):
prot += code.get(cdna[i:i+3], "?")
return prot
def dna_translate2(cdna, code=standard):
""" translate a cDNA sequence to a protein """
return "".join([ code.get(cdna[i:i+3], "?")
for i in range(0,len(cdna),3)])
protein = dna_translate(cdna)
print (protein)
protein2 = dna_translate2(cdna)
print (protein2)