Created
May 25, 2020 21:14
-
-
Save biodunalfet/15479561ea4902c360ee7866080d489a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A cell's genetic composition determines what it does or the structure it has. An activated gene produces | |
a messenger RNA which in turn is converted to a peptide in the ribosomal complex. The nucleotide sequence on the gene | |
can allow us to predict the sequence of amino acid in peptides that is obtained from that gene. | |
The Template or antisense is the strand that gets transcribed i.e complimentary to mRNA | |
while the coding and sense refer to the strand that is NOT transcribed i.e similar to mRNA""" | |
"""This program help to determine the amino acid sequence in a gene whether the user has mRNA, sense DNA | |
or antisense DNA sequence. Moreover, it can also help in determining the portion of the gene that proteins are obtained | |
""" | |
peptide_dict = { | |
'AUA':'Ile', 'AUC':'Ile', 'AUU':'Ile', 'AUG':'Met', | |
'ACA':'Thr', 'ACC':'Thr', 'ACG':'Thr', 'ACU':'Thr', | |
'AAC':'Asn', 'AAU':'Asn', 'AAA':'Lys', 'AAG':'Lys', | |
'AGC':'Ser', 'AGU':'Ser', 'AGA':'Arg', 'AGG':'Arg', | |
'CUA':'Leu', 'CUC':'Leu', 'CUG':'Leu', 'CUU':'Leu', | |
'CCA':'Pro', 'CCC':'Pro', 'CCG':'Pro', 'CCU':'Pro', | |
'CAC':'His', 'CAU':'His', 'CAA':'Gln', 'CAG':'Gln', | |
'CGA':'Arg', 'CGC':'Arg', 'CGG':'Arg', 'CGU':'Arg', | |
'GUA':'Val', 'GUC':'Val', 'GUG':'Val', 'GUU':'Val', | |
'GCA':'Ala', 'GCC':'Ala', 'GCG':'Ala', 'GCU':'Ala', | |
'GAC':'Asp', 'GAU':'Asp', 'GAA':'Glu', 'GAG':'Glu', | |
'GGA':'Gly', 'GGC':'Gly', 'GGG':'Gly', 'GGU':'Gly', | |
'UCA':'Ser', 'UCC':'Ser', 'UCG':'Ser', 'UCU':'Ser', | |
'UUC':'Phe', 'UUU':'Phe', 'UUA':'Leu', 'UUG':'Leu', | |
'UAC':'Tyr', 'UAU':'Tyr', 'UAA':'*', 'UAG':'*', | |
'UGC':'Cys', 'UGU':'Cys', 'UGA':'*', 'UGG':'Trp', | |
} | |
def main(): | |
print(mrna_to_amino_acid("AUGACUAAGUAA")) | |
enter1 = int(input("Please enter 1 if you have the Coding or Sense DNA sequence. \n" | |
"Enter 2 for the Template or Antisense DNA sequence. \n" | |
"Enter 3 for Messenger RNA sequence: ")) | |
if enter1 == 1: | |
c_dna_to_mrna() | |
elif enter1 == 2: | |
t_dna_to_c_dna() | |
elif enter1 == 3: | |
mrna_to_peptide() | |
else: | |
print("Please enter the appropriate number") | |
def t_dna_to_c_dna(): | |
""" | |
This coverts the DNA base to the corresponding RNA base | |
T -> P -> A | |
A -> Q -> T | |
C -> R -> G | |
G -> S -> C | |
""" | |
t_dna = str(input("Please enter the Template DNA sequence: ")) | |
t_dna = t_dna.upper() | |
c_dna = "" | |
for i in t_dna: | |
if (i == 'A'): | |
c_dna = c_dna + 'T' | |
elif (i == 'T'): | |
c_dna = c_dna + 'A' | |
elif (i == 'C'): | |
c_dna = c_dna + 'G' | |
elif (i == 'G'): | |
c_dna = c_dna + 'C' | |
return c_dna | |
def c_dna_to_mrna(): | |
""" This program converts coding DNA sequence to messenger RNA sequence """ | |
c_dna = str(input("Please enter the Coding DNA sequence: ")) | |
c_dna = c_dna.upper() | |
mrna = dna_to_mrna(c_dna) | |
print("The messenger RNA sequence is " + str(mrna) + ".") | |
mrna_to_amino_acid(mrna) | |
# print("The Peptide sequence is " + str(amino_acid) + ".") | |
def dna_to_mrna(c_dna): | |
""" | |
This coverts the DNA base to the corresponding RNA base | |
T -> A | |
A -> U | |
C -> G | |
G -> C | |
""" | |
mrna = "" | |
for i in c_dna: | |
if (i == 'A'): | |
mrna = mrna + 'U' | |
elif (i == 'T'): | |
mrna = mrna + 'A' | |
elif (i == 'C'): | |
mrna = mrna + 'G' | |
elif (i == 'G'): | |
mrna = mrna + 'C' | |
return mrna | |
def mrna_to_peptide(): | |
""" This program converts to messenger RNA sequence to the corresponding peptide""" | |
merna = str(input("Please enter the Messenger RNA sequence: ")) | |
mrna = merna.upper() | |
mrna_to_amino_acid(mrna) | |
def mrna_to_amino_acid(mrna): | |
# i = 0 | |
# while | |
# codone = mran[current 3] | |
# if codone is start === start recording | |
# if codone is stop and recording is ongoing, stop and print the recorded amino acid | |
# if codone is not start and stop | |
# else continue looping and increment i by 3 | |
# if at end of mran exit the loop and print amino acid | |
# AUGACUAAGUAA | |
i: int = 0 | |
continueLooping = True | |
record = "" # our current amino acid/peptide | |
recording = False # to track if we've hit a start codone | |
mranLength = len(mrna) # the length of the mran | |
while continueLooping == True: | |
if (i + 3 <= mranLength): # check to see if we're at the end of the mran | |
condone = mrna[i: i + 3] # pick the current mran by selecting 3 characters from the index, i | |
if (condone == "AUG"): # if codone is a start codone | |
recording = True # we set the recording state to true | |
record = peptide_dict[condone] # get amino acid from dictionary using codone as the key, then add to the record | |
elif (peptide_dict[condone] == "*" and recording == True): # if codone is a stop codone and we are in recording state | |
recording = False # set the recording state to False (because we are no longer recording) | |
print("Peptide sequence recorded: " + record) # print our current recorded amino acid | |
record = "" # clear our record for new amino acids to be encountered | |
else: # if codone is neither start nor stop | |
if (recording): # have we encountered a start codone? if yes, | |
record = record + "-" + peptide_dict[condone] # get amino acid from dictionary using codone as the key, then add to the record | |
i = i + 3 # increment our index by 3 | |
else: # we are at the end of the mrna | |
if (recording == True): # if we are still recording at this time | |
print(record) # print whatever we have recorded | |
break # then we exit the loop | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment