0% found this document useful (0 votes)
69 views4 pages

In-Linear-Time: Check This Web Site

The document provides code to translate an mRNA sequence into a protein sequence. It defines a dictionary that maps codons to amino acids or stop signals. The amino_acids function takes an mRNA string as input. It splits the mRNA into codons, looks up each codon in the dictionary, appends the corresponding amino acids or stop signal to a list, and returns the protein sequence list. It also counts the number of amino acids before a stop codon is reached.

Uploaded by

snyawose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views4 pages

In-Linear-Time: Check This Web Site

The document provides code to translate an mRNA sequence into a protein sequence. It defines a dictionary that maps codons to amino acids or stop signals. The amino_acids function takes an mRNA string as input. It splits the mRNA into codons, looks up each codon in the dictionary, appends the corresponding amino acids or stop signal to a list, and returns the protein sequence list. It also counts the number of amino acids before a stop codon is reached.

Uploaded by

snyawose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Check this Web site

https://stackoverflow.com/questions/2488889/how-can-i-merge-two-lists-and-sort-them-working-
in-linear-time

### START FUNCTION

def linear_merge(list1, list2):

# your code here

finalList = []

for item in list1:

finalList.append(item)

for item in list2:

finalList.append(item)

finalList.sort()

return finalList

### END FUNCTION


def amino_acids(mrna):

# your code here

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
Advanced List Exercises 2¶
Instructions to Students
 Do not add or remove cells in this notebook. Do not edit or remove the ### START
FUNCTION or ### END FUNCTION comments. Do not add any code outside of the
functions you are required to edit. Doing any of this will lead to a mark of 0%!
 Answer the questions according to the specifications provided.

### START FUNCTION

def amino_acids(mrna):

# your code here

aa_dict = {'CUU': 'Leu', 'UAG': '---', 'ACA': 'Thr', 'AAA': 'Lys', 'AUC': 'Ile',

'AAC': 'Asn','AUA': 'Ile', 'AGG': 'Arg', 'CCU': 'Pro', 'ACU': 'Thr',

'AGC': 'Ser','AAG': 'Lys', 'AGA': 'Arg', 'CAU': 'His', 'AAU': 'Asn',

'AUU': 'Ile','CUG': 'Leu', 'CUA': 'Leu', 'CUC': 'Leu', 'CAC': 'His',

'UGG': 'Trp','CAA': 'Gln', 'AGU': 'Ser', 'CCA': 'Pro', 'CCG': 'Pro',

'CCC': 'Pro', 'UAU': 'Tyr', 'GGU': 'Gly', 'UGU': 'Cys', 'CGA': 'Arg',

'CAG': 'Gln', 'UCU': 'Ser', 'GAU': 'Asp', 'CGG': 'Arg', 'UUU': 'Phe',
'UGC': 'Cys', 'GGG': 'Gly', 'UGA':'---', 'GGA': 'Gly', 'UAA': '---',

'ACG': 'Thr', 'UAC': 'Tyr', 'UUC': 'Phe', 'UCG': 'Ser', 'UUA': 'Leu',

'UUG': 'Leu', 'UCC': 'Ser', 'ACC': 'Thr', 'UCA': 'Ser', 'GCA': 'Ala',

'GUA': 'Val', 'GCC': 'Ala', 'GUC': 'Val', 'GGC':'Gly', 'GCG': 'Ala',

'GUG': 'Val', 'GAG': 'Glu', 'GUU': 'Val', 'GCU': 'Ala', 'GAC': 'Asp',

'CGU': 'Arg', 'GAA': 'Glu', 'AUG': 'Met', 'CGC': 'Arg'}

mrna_list = [aa_dict[mrna[i:i + 3]] for i in range(0, len(mrna) - 1, 3)]

count = 0

while True:

if mrna_list[count] == '---':

mrna_list = mrna_list[:count]

break

else:

count += 1

conversion_result = tuple(mrna_list)

return [conversion_result, count]

### END FUNCTION

You might also like