你好,我试着从ROSALIND做这个问题,但是当我把rna序列(AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA)放在示例中时,它给了我错误的输出“M”、“M”、“N”、“I”,而不是建议的"MAMAPRTEINSTRING".I试图修改代码,但它仍然没有给我想要的输出。如果有人可以的话,我希望得到一些帮助。
这是我的代码:
**dna_seq = input("PLace your RNA sequence here(it must not exceed 1kb):")
list = []
for x in range (0,len(dna_seq),3):
if dna_seq[x:x+3] == "AUG":
list.append("M")
elif dna_seq[x:x+3] == ("UUU" or "UUC"):
list.append("F")
elif dna_seq[x:x+3] == ("UUA" or "UUG" or "CUU" or "CUC" or "CUA" or "CUG"):
list.append("L")
elif dna_seq[x:x+3] == ("AUU" or "AUC" or "AUA"):
list.append("I")
elif dna_seq[x:x+3] == ("GUA" or "GUG" or "GUC" or "GUU"):
list.append("V")
elif dna_seq[x:x+3] == ("UCA" or "UCU" or "UCG" or "UCC"):
list.append("S")
elif dna_seq[x:x+3] == ("CCU" or "CCA" or "CCC" or "CCG" or "AGU" or "AGC"):
list.append("P")
elif dna_seq[x:x+3] == ("ACA" or "ACU" or "ACG" or "ACC"):
list.append("T")
elif dna_seq[x:x+3] == ("GCU" or "GCA" or "GCG" or "GCC"):
list.append("A")
elif dna_seq[x:x+3] == ("UAU" or "UAC"):
list.append("Y")
elif dna_seq[x:x+3] == ("UAA" or "UAG" or "UGA"):
list.append("STOP")
elif dna_seq[x:x+3] == ("CAU" or "CAC"):
list.append("H")
elif dna_seq[x:x+3] == ("CAA" or "CAG"):
list.append("Q")
elif dna_seq[x:x+3] == ("AAU" or"AAC"):
list.append("N")
elif dna_seq[x:x+3] == ("AAA" or "AAG"):
list.append("K")
elif dna_seq[x:x+3] == ("GAU" or "GAC"):
list.append("D")
elif dna_seq[x:x+3] == ("GAA" or "GAG"):
list.append("E")
elif dna_seq[x:x+3] == ("UGU" or "UGC"):
list.append("C")
elif dna_seq[x:x+3] == ("UGG"):
list.append("W")
elif dna_seq[x:x+3] == ("CGA" or "CGG" or "CGC" or "CGU" or "AGA" or "AGG"):
list.append("R")
elif dna_seq[x:x+3] == ("GGU" or "GGC" or "GGA" or "GGG"):
list.append("G")
print(list)** 耽误您时间,实在对不起!
发布于 2021-12-20 09:41:37
声明("CAU“或"CAC")评价为”CAU“:
>>> ("CAU" or "CAC")
'CAU'因此,您的elif语句将只检查列表中的第一个密码子。您可以通过将语句重写为以下格式来解决此问题:
elif dna_seq[x:x+3] == "CAU" or dna_seq[x:x+3] "CAC":但更好的做法是制作一本字典,其中你的密码子是键,值是对应于密码子的氨基酸。然后,通过从字典中获取密码子的值来构建蛋白质序列,并将其添加到您的列表中。
最后,不要在python列表中指定变量。它覆盖内置的函数列表()。
https://stackoverflow.com/questions/70411943
复制相似问题