2 changed files with 199 additions and 0 deletions
-
132amino_acids.py
-
67converter.py
@ -0,0 +1,132 @@ |
|||||
|
def codons_to_acids(list_of_codons): |
||||
|
newlist = [] |
||||
|
for i in list_of_codons: |
||||
|
if i == "GUU": |
||||
|
newlist.append("Valine") |
||||
|
if i == "GUC": |
||||
|
newlist.append("Valine") |
||||
|
if i == "GUA": |
||||
|
newlist.append("Valine") |
||||
|
if i == "GUG": |
||||
|
newlist.append("Valine") |
||||
|
if i == "GCU": |
||||
|
newlist.append("Alanine") |
||||
|
if i == "GCC": |
||||
|
newlist.append("Alanine") |
||||
|
if i == "GCA": |
||||
|
newlist.append("Alanine") |
||||
|
if i == "GCG": |
||||
|
newlist.append("Alanine") |
||||
|
if i == "GAU": |
||||
|
newlist.append("Aspartic Acid") |
||||
|
if i == "GAC": |
||||
|
newlist.append("Aspartic Acid") |
||||
|
if i == "GAA": |
||||
|
newlist.append("Glutamic Acid") |
||||
|
if i == "GAG": |
||||
|
newlist.append("Glutamic Acid") |
||||
|
if i == "GGU": |
||||
|
newlist.append("Glycine") |
||||
|
if i == "GGC": |
||||
|
newlist.append("Glycine") |
||||
|
if i == "GGA": |
||||
|
newlist.append("Glycine") |
||||
|
if i == "GGG": |
||||
|
newlist.append("Glycine") |
||||
|
if i == "UUU": |
||||
|
newlist.append("Phenylalanine") |
||||
|
if i == "UUC": |
||||
|
newlist.append("Phenylalanine") |
||||
|
if i == "UUA": |
||||
|
newlist.append("Leucine") |
||||
|
if i == "UUG": |
||||
|
newlist.append("Leucine") |
||||
|
if i == "UCU": |
||||
|
newlist.append("Serine") |
||||
|
if i == "UCC": |
||||
|
newlist.append("Serine") |
||||
|
if i == "UCA": |
||||
|
newlist.append("Serine") |
||||
|
if i == "UCG": |
||||
|
newlist.append("Serine") |
||||
|
if i == "UAU": |
||||
|
newlist.append("Tyrosine") |
||||
|
if i == "UAC": |
||||
|
newlist.append("Tyrosine") |
||||
|
if i == "UAA": |
||||
|
newlist.append("STOP") |
||||
|
if i == "UAG": |
||||
|
newlist.append("STOP") |
||||
|
if i == "UGU": |
||||
|
newlist.append("Cysteine") |
||||
|
if i == "UGC": |
||||
|
newlist.append("Cysteine") |
||||
|
if i == "UGA": |
||||
|
newlist.append("STOP") |
||||
|
if i == "UGG": |
||||
|
newlist.append("Tryptophan") |
||||
|
if i == "CUU": |
||||
|
newlist.append("Leucine") |
||||
|
if i == "CUC": |
||||
|
newlist.append("Leucine") |
||||
|
if i == "CUA": |
||||
|
newlist.append("Leucine") |
||||
|
if i == "CUG": |
||||
|
newlist.append("Leucine") |
||||
|
if i == "CCU": |
||||
|
newlist.append("Proline") |
||||
|
if i == "CCC": |
||||
|
newlist.append("Proline") |
||||
|
if i == "CCA": |
||||
|
newlist.append("Proline") |
||||
|
if i == "CCG": |
||||
|
newlist.append("Proline") |
||||
|
if i == "CAU": |
||||
|
newlist.append("Histidine") |
||||
|
if i == "CAC": |
||||
|
newlist.append("Histidine") |
||||
|
if i == "CAA": |
||||
|
newlist.append("Glutamine") |
||||
|
if i == "CAG": |
||||
|
newlist.append("Glutamine") |
||||
|
if i == "CGU": |
||||
|
newlist.append("Arginine") |
||||
|
if i == "CGC": |
||||
|
newlist.append("Arginine") |
||||
|
if i == "CGA": |
||||
|
newlist.append("Arginine") |
||||
|
if i == "CGG": |
||||
|
newlist.append("Arginine") |
||||
|
if i == "AUU": |
||||
|
newlist.append("Isoleucine") |
||||
|
if i == "AUC": |
||||
|
newlist.append("Isoleucine") |
||||
|
if i == "AUA": |
||||
|
newlist.append("Isoleucine") |
||||
|
if i == "AUG": |
||||
|
newlist.append("Methionine") |
||||
|
if i == "ACU": |
||||
|
newlist.append("Threonine") |
||||
|
if i == "ACC": |
||||
|
newlist.append("Threonine") |
||||
|
if i == "ACA": |
||||
|
newlist.append("Threonine") |
||||
|
if i == "ACG": |
||||
|
newlist.append("Threonine") |
||||
|
if i == "AAU": |
||||
|
newlist.append("Asparagine") |
||||
|
if i == "AAC": |
||||
|
newlist.append("Asparagine") |
||||
|
if i == "AAA": |
||||
|
newlist.append("Lysine") |
||||
|
if i == "AAG": |
||||
|
newlist.append("Lysine") |
||||
|
if i == "AGU": |
||||
|
newlist.append("Serine") |
||||
|
if i == "AGC": |
||||
|
newlist.append("Serine") |
||||
|
if i == "AGA": |
||||
|
newlist.append("Arginine") |
||||
|
if i == "AGG": |
||||
|
newlist.append("Arginine") |
||||
|
return newlist |
||||
@ -0,0 +1,67 @@ |
|||||
|
#This program turns a strand of DNA into mRNA, which is then converted into amino acids using a codon chart |
||||
|
#MIT License as usual |
||||
|
#Ravi Shah 2020 |
||||
|
from amino_acids import codons_to_acids |
||||
|
|
||||
|
stop_index = "NaN" |
||||
|
|
||||
|
def find_stop(mrna): |
||||
|
if "UAA" in mrna: |
||||
|
print("UAA STOP codon found") |
||||
|
stop_index = mrna.index("UAA") |
||||
|
elif "UAG" in mrna: |
||||
|
print("UAG STOP codon found") |
||||
|
stop_index = mrna.index("UAG") |
||||
|
elif "UGA" in mrna: |
||||
|
print("UGA STOP codon found") |
||||
|
stop_index = mrna.index("UGA") |
||||
|
else: |
||||
|
print("No STOP codon found. Exiting...") |
||||
|
quit() |
||||
|
return stop_index |
||||
|
|
||||
|
def transcription(dna): |
||||
|
res = [] |
||||
|
newlist = [] |
||||
|
res[:] = dna |
||||
|
|
||||
|
for i in res: |
||||
|
if i == "G": |
||||
|
newlist.append("C") |
||||
|
elif i == "C": |
||||
|
newlist.append("G") |
||||
|
elif i == "A": |
||||
|
newlist.append("U") |
||||
|
elif i == "T": |
||||
|
newlist.append("A") |
||||
|
|
||||
|
mrna_strand = ''.join(newlist) |
||||
|
return mrna_strand |
||||
|
|
||||
|
def start_to_stop(mrna): |
||||
|
global stop_index |
||||
|
try: |
||||
|
start_index = mrna.index("AUG") |
||||
|
inter_rna = mrna[start_index:] |
||||
|
stop_index = find_stop(inter_rna) |
||||
|
final_rna = inter_rna[0:stop_index+3] |
||||
|
return(final_rna) |
||||
|
except: |
||||
|
print("Please enter a valid DNA strand") |
||||
|
quit() |
||||
|
|
||||
|
def translation(final_rna): |
||||
|
print("The mRNA strand is:", final_rna) |
||||
|
n = 3 |
||||
|
res = [final_rna[i:i+n] for i in range(0, len(final_rna), n)] |
||||
|
print("The codons are:", res) |
||||
|
list_of_amino_acids = codons_to_acids(res) |
||||
|
print("There are", len(list_of_amino_acids), "amino acids translated from this mRNA strand.") |
||||
|
return list_of_amino_acids |
||||
|
|
||||
|
strand = input("Enter the DNA strand to be transcribed and translated: ") |
||||
|
strand = strand.upper() |
||||
|
messenger_rna = transcription(strand) |
||||
|
thing = start_to_stop(messenger_rna) |
||||
|
print("Here are the amino acids:") |
||||
|
print(translation(thing)) |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue