amino-acidsbiologydnarnatranscriptiontranslationdna-sequencesdna-stranddna-transcription-translationmessenger-rnamrnatranslates
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.0 KiB
71 lines
2.0 KiB
#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 with a start and stop codon")
|
|
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)
|
|
truncated = start_to_stop(messenger_rna)
|
|
|
|
if len(truncated) % 3 != 0:
|
|
print("The mRNA strand isn't divisible by 3.")
|
|
quit()
|
|
|
|
print(translation(truncated))
|