gpt4 book ai didi

python - 如何拆分字符串(输入)并将每个部分用作字典值?

转载 作者:太空宇宙 更新时间:2023-11-04 03:55:50 25 4
gpt4 key购买 nike

<分区>

所以我想写一个程序来检查 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 个以上的字母,我想知道如何操纵我的代码来处理它?我希望有人理解这个问题。提前致谢!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com