##############################################
#  Program creates RNA codon dictionary and reads in
#  DNA sequences. Then converts DNA sequence to RNA 
#  and translates an RNA sequence into 
#  a sequence of amino acids.
##############################################

def read_DNA(filename):
    """
    Function reads multiple DNA sequences to decode 
    from filename and returns sequences in DNA_list
    """
    f_in = open(filename, 'r')
    DNA_list = []
    for line in f_in:
        DNA_list.append(line.strip().upper())
    return DNA_list

def build_codon_dict():
    """
    Function creates RNA codon to amino acid 
    map (dictionary) from txt file
    """
#################################################
#  YOUR CODE GOES HERE: input
#    Read in file named 'RNA_codons.txt' and create
#    dictionary named: 'RNA_dict' from lines. 
#    Dictionary key will be first word (3 letters}
#    of each line. Values will be a list of 3 other
#    words in each line of text file
#    Hint: 
#       f_in = open('RNA_codons.txt') opens file
#       Use .split() to split each line into  4 words
##################################################
    return RNA_dict
#
#
# Read in DNA sequences from file into list
#
DNA_list = read_DNA( 'DNA_seq_random.txt') 
DNA_in  = DNA_list[0]   # Assign first line in DNA file 
print ('\n\nDNA sequence is:', DNA_in)
#
# Convert DNA sequence to RNA sequence
RNA_in = DNA_in.replace('T','U')
#
#
##############################################################
#
# YOUR CODE GOES HERE:
#  For the converted RNA sequence (RNA_in)  print out 
#  the sequence of amino acids using the RNA dictionary,
#  using pseudo-code steps below:
#  0. Print out DNA and RNA seqeuence you are de-coding.
#  1. Find the start codon sequence. If no starting codon 
#     found, print 'No starting codon found for this sequence'
#  2. From there, decode each 3 following letter codon to find 
#      corresponding amino acid abreviation fom dictionary.
#  3  Print amino acid (on same line) and continue to next codon.
#  3. Stop when you reach stop codon.
#
#  Output should look something like this:
#
#  DNA sequence is: ATGGAGCGTGCTGGTCCCCTAGGTAATGCCGCCTCCCGAATTTAA
#  RNA sequence is: AUGGAGCGUGCUGGUCCCCUAGGUAAUGCCGCCUCCCGAAUUUAA 
#  Amino acid sequence for this RNA sequence is:
#      Met-Glu-Arg-Ala-Gly-Pro-Leu-Gly-Asp-Ala-Ala-Ser-Arg-Ile-
#
#   
################################################################ 

 
           
        
        

