Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

The function to be built, amino_acids, must return a list of a tuple and an integer when given a string of mRNA code.

def amino_acids(mrna):
    protein = ""  # Start with empty protein string
    translation = {"AUG": "Met", "CCA": "Pro", "CCU": "Pro"}  # Which codon translates for which amino acid
    stop_codons = {"UGA"}  # Define stop codons
    while mrna:  # Repeat loop while mRNA isn't exhausted
        codon = mrna[:3]  # Select first three codes
        mrna = mrna[3:]  # Remove current codon from mRNA
        if codon in stop_codons:
            break  # Break loop if triple is a stop codon
        amino_acid = translation[codon]  # Translate codon into its amino acid
        protein += amino_acid  # Add the amino acid to the protein string
    return protein

print(amino_acids("AUGCCACCUUGA"))
Comment

PREVIOUS NEXT
Code Example
Python :: py environment variables register in flask 
Python :: reduce dataframe merge 
Python :: python code to increase cpu utilization 
Python :: python extraer ultimo elemento lista 
Python :: add last item of array at the first index of the array python 
Python :: how to get wikipedia page link in python 
Python :: python website example 
Python :: print 
Python :: how to loop through every character in a string 
Python :: copy along additional dimension numpy 
Python :: create django model field based on another field 
Python :: python send image client 
Python :: python divide all values in list 
Python :: string to list 
Python :: convert iso 8601 to milliseconds python 
Python :: most occurring element in array python 
Python :: get diagonals of 2d array 
Python :: Exiting from python Command Line 
Python :: python identify image mode 
Python :: bytestring python 
Python :: import combination 
Python :: python find all occurrence in string 
Python :: spacy french stopwords 
Python :: django get form id from request 
Python :: print index in for loop python 
Python :: foreign key django createview 
Python :: theme_use() tkinter theme usage 
Python :: python replace in string 
Python :: python sh command 
Python :: fill_between matplotlib 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =