I'm trying to create a python program that follows the codon translation and turn mRNA sequence into amino acids (see the dictionary). The system has to return an error of the string is not a multiplier of 3, and the the function should not produce any more amino acids once a stop codon (keys with a value of X in the dictionary) is found, and should not display 'X' in the output. I do not know how to incorporate the stop codon to stop the programming entirely, as well as the multiplier of 3 aspect in the code. Can someone give me any advice? Thank you so much! example: protfromRNA('GCCAACGCACCCACUUUUUUUUAGAAA') should return ANAPTFF
def protfromRNA(Seq):
GeneticCode = {'AAA':'K', 'AAC':'N', 'AAG':'K', 'AAU':'N',
'ACA':'T', 'ACC':'T', 'ACG':'T', 'ACU':'T',
'AGA':'R', 'AGC':'S', 'AGG':'R', 'AGU':'S',
'AUA':'I', 'AUC':'I', 'AUG':'M', 'AUU':'I',
'CAA':'Q', 'CAC':'H', 'CAG':'Q', 'CAU':'H',
'CCA':'P', 'CCC':'P', 'CCG':'P', 'CCU':'P',
'CGA':'R', 'CGC':'R', 'CGG':'R', 'CGU':'R',
'CUA':'L', 'CUC':'L', 'CUG':'L', 'CUU':'L',
'GAA':'E', 'GAC':'D', 'GAG':'E', 'GAU':'D',
'GCA':'A', 'GCC':'A', 'GCG':'A', 'GCU':'A',
'GGA':'G', 'GGC':'G', 'GGG':'G', 'GGU':'G',
'GUA':'V', 'GUC':'V', 'GUG':'V', 'GUU':'V',
'UAA':'X', 'UAC':'Y', 'UAG':'X', 'UAU':'Y',
'UCA':'S', 'UCC':'S', 'UCG':'S', 'UCU':'S',
'UGA':'X', 'UGC':'C', 'UGG':'W', 'UGU':'C',
'UUA':'L', 'UUC':'F', 'UUG':'L', 'UUU':'F'}
return ''.join(GeneticCode[i] if GeneticCode[i]!=X else '' for i in Seq)