0

您好,我尝试从 ROSALIND 解决这个问题,但是当我输入示例 rna 序列 (AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA) 时,它产生了错误的输出“['M', 'M', 'N', 'I']”而不是建议的“MAMAPRTEINSTRING “。我试图修改代码,但仍然没有给我想要的输出。如果有人可以的话,我想要一些帮助。

这是我的代码:

**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)** 

谢谢你的时间!

4

1 回答 1

0

The statement ("CAU" or "CAC") evaluates to "CAU".:

>>> ("CAU" or "CAC")
'CAU'

Thus your elif statements will only ever check the first codon in the list. You can fix this by rewriting your statements to this format:

elif dna_seq[x:x+3] == "CAU" or dna_seq[x:x+3] "CAC":

But much better would be to make a dictionary where your codons are the keys and the values are the amino acids corresponding to that codon. Then build your protein sequence by getting the value of a codon from the dictionary and add it your list.

Finally, don't name a variable in python list. It overwrites the built in function list().

于 2021-12-20T09:41:37.403 回答