Question: QUICK FIX PYTHON CODE HELP: The bellow code should be mostly right I just do not know how to print the protein. The program is
QUICK FIX PYTHON CODE HELP:
The bellow code should be mostly right I just do not know how to print the protein. The program is suppose to break up a big string of letters(gene) and then go through the genetic code and print the assigned one letter, the gene file is pretty big and it is expected to print out many letters.
How do I print the one letter protein codes? Also is it possbile to put the input stuff into a def tag? Thanks for the help!
genetic_code = { 'AUA':'I', 'AUC':'I', 'AUU':'I', 'AUG':'M', 'ACA':'T', 'ACC':'T', 'ACG':'T', 'ACU':'T', 'AAC':'N', 'AAU':'N', 'AAA':'K', 'AAG':'K', 'AGC':'S', 'AGU':'S', 'AGA':'R', 'AGG':'R', 'CUA':'L', 'CUC':'L', 'CUG':'L', 'CUU':'L', 'CCA':'P', 'CCC':'P', 'CCG':'P', 'CCU':'P', 'CAC':'H', 'CAU':'H', 'CAA':'Q', 'CAG':'Q', 'CGA':'R', 'CGC':'R', 'CGG':'R', 'CGU':'R', 'GUA':'V', 'GUC':'V', 'GUG':'V', 'GUU':'V', 'GCA':'A', 'GCC':'A', 'GCG':'A', 'GCU':'A', 'GAC':'D', 'GAU':'D', 'GAA':'E', 'GAG':'E', 'GGA':'G', 'GGC':'G', 'GGG':'G', 'GGU':'G', 'UCA':'S', 'UCC':'S', 'UCG':'S', 'UCU':'S', 'UUC':'F', 'UUU':'F', 'UUA':'L', 'UUG':'L', 'UAC':'Y', 'UAU':'Y', 'UAA':'_', 'UAG':'_', 'UGC':'C', 'UGU':'C', 'UGA':'_', 'UGG':'W',}
from gene import GENE
lines = GENE.split(' ')[2:] codons = ''
for line in lines: codons += line
codons = codons.replace('T','U') #print(codons)
def codons2protein(codons, genetic_code): protein = '' for i in range( 0, len(codons), 3 ): letter = codons[i:i+3] protein += genetic_code[ letter ] return protein def printResults(protein): print('The proteins for the list are:', protein)
def main(): printResults(protein)
if __name__ == "__main__": main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
