所以我想写一个程序来检查 DNA 是否突变,我不太清楚如何解释,所以这就是它所说的:
写一个程序来确定患者的 DNA 序列是否有突变从而导致氨基酸序列发生变化。你的程序应该像这样工作:
Enter original DNA: AAT
Enter patient DNA: AAC
The patient's amino acid sequence is not mutated.
Enter original DNA: AATTGTTCTTCT
Enter patient DNA: AACTGCAGCTCA
The patient's amino acid sequence is not mutated.
Enter original DNA: TGTCATGCCTTATTAGAAAACGGTGAG
Enter patient DNA: TGTCATGTCTTATTAGAAAAAGGTGAG
The patient's amino acid sequence is mutated.
这是我使用的文本文件的一部分:
The mappings from codon to amino acid are available in a file, called codon_amino.txt, an excerpt of which is shown here:
AAC N
AAG K
AAT N
GCG A
GCT A
GGA G
GGC G
GGG G
GGT G
所以这是我到目前为止的代码:
n = {}
for line in open('codons.txt'):
codon, codons = line.split()
n[codon] = codons
org = input('Enter original DNA: ')
pat = input('Enter patient DNA: ')
if n[org] == n[pat]:
print("The patient's amino acid sequence is not mutated.")
else:
print("The patient's amino acid sequence is mutated.")
所以我的代码在第一个例子中运行良好,只使用了 3 个字母,但接下来的两个字母超过 3 个,我想知道如何操纵我的代码来处理它?我希望有人能理解这个问题。先感谢您!