dna = "ATGCACGTGCGCTCACTGCGAGCTGCGGCGCCGCACAGCTTCGTGGCGCTCTGGGCACCCCTGTTCCTGCTGCGCTCCGCCCTGGCCGACTTCAGCCTGGACAACGAGGTGCACTCGAGCTTCATCCACCGGCGCCTCCGCAGCCAGGAGCGGCGGGAGATGCAGCGCGAGATCCTCTCCATTTTGGGCTTGCCCCACCGCCCGCGCCCGCACCTCCAGGGCAAGCACAACTCGGCACCCATGTTCATGCTGGACCTGTACAACGCCATGGCGGTGGAGGAGGGCGGCGGGCCCGGCGGCCAGGGCTTCTCCTACCCCTACAAGGCCGTCTTCAGTACCCAGGGCCCCCCTCTGGCCAGCCTGCAAGATAGCCATTTCCTCACCGACGCCGACATGGTCATGAGCTTCGTCAACCTCGTGGAACATGACAAGGAATTCTTCCACCCACGCTACCACCATCGAGAGTTCCGGTTTGATCTTTCCAAGATCCCAGAAGGGGAAGCTGTCACGGCAGCCGAATTCCGGATCTACAAGGACTACATCCGGGAACGCTTCGACAATGAGACGTTCCGGATCAGCGTTTATCAGGTGCTCCAGGAGCACTTGGGCAGGGAATCGGATCTCTTCCTGCTCGACAGCCGTACCCTCTGGGCCTCGGAGGAGGGCTGGCTGGTGTTTGACATCACAGCCACCAGCAACCACTGGGTGGTCAATCCGCGGCACAACCTGGGCCTGCAGCTCTCGGTGGAGACGCTGGATGGGCAGAGCATCAACCCCAAGTTGGCGGGCCTGATTGGGCGGCACGGGCCCCAGAACAAGCAGCCCTTCATGGTGGCTTTCTTCAAGGCCACGGAGGTCCACTTCCGCAGCATCCGGTCCACGGGGAGCAAACAGCGCAGCCAGAACCGCTCCAAGACGCCCAAGAACCAGGAAGCCCTGCGGATGGCCAACGTGGCAGAGAACAGCAGCAGCGACCAGAGGCAGGCCTGTAAGAAGCACGAGCTGTATGTCAGCTTCCGAGACCTGGGCTGGCAGGACTGGATCATCGCGCCTGAAGGCTACGCCGCCTACTACTGTGAGGGGGAGTGTGCCTTCCCTCTGAACTCCTACATGAACGCCACCAACCACGCCATCGTGCAGACGCTGGTCCACTTCATCAACCCGGAAACGGTGCCCAAGCCCTGCTGTGCGCCCACGCAGCTCAATGCCATCTCCGTCCTCTACTTCGATGACAGCTCCAACGTCATCCTGAAGAAATACAGAAACATGGTGGTCCGGGCCTGTGGCTGCCACTAG" def trabslate_dna(sequence):
start_codon = 'ATG'
stop_codon = ('TAA', 'TAG', 'TGA' )
codontable = {
'ATA': 'I', 'ATC': 'I', 'ATT': 'I', 'ATG': 'M',
'ACA': 'T', 'ACC': 'T', 'ACG': 'T', 'ACT': 'T',
'AAC': 'N', 'AAT': 'N', 'AAA': 'K', 'AAG': 'K',
'AGC': 'S', 'AGT': 'S', 'AGA': 'R', 'AGG': 'R',
'CTA': 'L', 'CTC': 'L', 'CTG': 'L', 'CTT': 'L',
'CCA': 'P', 'CCC': 'P', 'CCG': 'P', 'CCT': 'P',
'CAC': 'H', 'CAT': 'H', 'CAA': 'Q', 'CAG': 'Q',
'CGA': 'R', 'CGC': 'R', 'CGG': 'R', 'CGT': 'R',
'GTA': 'V', 'GTC': 'V', 'GTG': 'V', 'GTT': 'V',
'GCA': 'A', 'GCC': 'A', 'GCG': 'A', 'GCT': 'A',
'GAC': 'D', 'GAT': 'D', 'GAA': 'E', 'GAG': 'E',
'GGA': 'G', 'GGC': 'G', 'GGG': 'G', 'GGT': 'G',
'TCA': 'S', 'TCC': 'S', 'TCG': 'S', 'TCT': 'S',
'TTC': 'F', 'TTT': 'F', 'TTA': 'L', 'TTG': 'L',
'TAC': 'Y', 'TAT': 'Y', 'TAA': '_', 'TAG': '_',
'TGC': 'C', 'TGT': 'C', 'TGA': '_', 'TGG': 'W'
}
start = sequence.find(start_codon)
codons = [] # Create a codon list to store codons generated from coding seq.
for i in range(start, len(sequence), ):
if sequence[i:i+] in stop_codons:
break
if sequence[i:i+] in codontable.keys():
codons.append(sequence[i:i+])
protein_sequence = ''.join([codontable[codon] for codon in codons]) #Translate condons to protein seq.
return "{0}_".format(protein_sequence) protein_seq = translate_DNA(dna)
print(protein_seq)
备注:文章摘自微信公众号“果子学生信”