我试图在我的 cds 中找到起始和终止密码子。我使用了正则表达式,但是当我运行这个 python 脚本时,我得到了一个空的终止密码子列表。任何帮助是极大的赞赏。
std_code = {"TTT":"F|Phe","TTC":"F|Phe","TTA":"L|Leu","TTG":"L|Leu","TCT":"S|Ser","TCC":"S|Ser",
"TCA":"S|Ser","TCG":"S|Ser", "TAT":"Y|Tyr","TAC":"Y|Tyr","TAA":"*|Stp","TAG":"*|Stp",
"TGT":"C|Cys","TGC":"C|Cys","TGA":"*|Stp","TGG":"W|Trp", "CTT":"L|Leu","CTC":"L|Leu",
"CTA":"L|Leu","CTG":"L|Leu","CCT":"P|Pro","CCC":"P|Pro","CCA":"P|Pro","CCG":"P|Pro",
"CAT":"H|His","CAC":"H|His","CAA":"Q|Gln","CAG":"Q|Gln","CGT":"R|Arg","CGC":"R|Arg",
"CGA":"R|Arg","CGG":"R|Arg", "ATT":"I|Ile","ATC":"I|Ile","ATA":"I|Ile","ATG":"M|Met",
"ACT":"T|Thr","ACC":"T|Thr","ACA":"T|Thr","ACG":"T|Thr", "AAT":"N|Asn","AAC":"N|Asn",
"AAA":"K|Lys","AAG":"K|Lys","AGT":"S|Ser","AGC":"S|Ser","AGA":"R|Arg","AGG":"R|Arg",
"GTT":"V|Val","GTC":"V|Val","GTA":"V|Val","GTG":"V|Val","GCT":"A|Ala","GCC":"A|Ala",
"GCA":"A|Ala","GCG":"A|Ala", "GAT":"D|Asp","GAC":"D|Asp","GAA":"E|Glu",
"GAG":"E|Glu","GGT":"G|Gly","GGC":"G|Gly","GGA":"G|Gly","GGG":"G|Gly"}
cds = ("ATGCTAGCGGTAAATCGTGAATAGGCCTAA")
for i in range (0, len(cds),3):
print cds[i:i+3]
def translate (cds, std_code):
protein = ""
for i in range (0,len(cds),3):
codon = cds[i:i+3]
protein = protein + std_code[codon]
return protein
print translate(cds, std_code)
def codon_usage(cds):
usage = {}
for i in range(0,len(cds),3):
codon = cds[i:i+3]
if usage.has_key(codon):
usage[codon] += 1
else:
usage[codon] = 1
return usage
print codon_usage(cds)
import re
pat = '(ATG)+?(?:TAA|TGA|TAG)'
reg = re.compile(pat)
def stop_codons(cds, messages=None,s=0,reg=reg):
stop_codons = []
while True:
ma = reg.search(cds[s:])
if ma:
if ma.group(1) == 'ATG':
break
else:
stop_codons.append(ma.group.upper())
s = s + ma.start() + 1
else:
break
return stop_codons
print stop_codons(cds, messages=None, s=0,reg=reg)