Reputation: 1
Hello i tried doing this problem from ROSALIND but when i put the example rna sequence (AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA) it produced me the wrong output "['M', 'M', 'N', 'I']" instead of the suggested "MAMAPRTEINSTRING".I tried to modify the code but still not it did not give me the desired output.I would like some help if someone can.
Here is my code:
**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)**
Thanks for your time!
Upvotes: 0
Views: 227
Reputation: 1109
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().
Upvotes: 0