Most FASTA files you will encounter will contain multiple sequences. Further, for genes you will often get 3’ and 5’ untranslated sequences (UTRs) flanking the coding sequence. In this exercise you will be writing a function for parsing a multiple-sequence FASTA file and translating each sequence, locating the coding sequence in between the UTRs. Finally, you will look at the prevalence of amino acids across the different sequences.
Biological Learning Objectives
Computational Learning Objectives
for loopfor or while loop, terminating early if necessary~/qbXX-answers/day2-morning/python_dictionaries.ipynb.sequences.fa and codons.tsv into ~/qbXX-answers/day2-morning/ (but do not submit them with your answer)10 pts total
%cd ~/qxx-answers/day2-morning/
Building on the code for reading in a single FASTA sequence, adapt it to read in multiple sequences from a single FASTA file, storing each sequence in a dictionary using the sequence name as the key. Wrap this code in a function such that it takes a file name as the only function argument and returns the dictionary of sequences.
.startswith()Wrap the code for reading in the codon table into a function, taking a file name in as the argument and returning the dictionary of codon/amin acid pairs.
Write a function for translating the CDS sequences into amino acid sequences. This function will need to take in two arguments, the codon table and the DNA sequence. The DNA sequences contain untranslated sequences (UTRs) at the start and end so you will need to step through the sequences to find the first methionine (M). Likewise, you will need to stop when you encounter the first step codon (*) rather than translating through the end of the sequence.
while loop may be useful for this task, but it is not required as for loops can also workFinally, put it all together, loading in the FASTA sequences and codon table, and translating the into amino acids. Once you have the amino acid sequences, count the number of times each amino acid is used. Finally, convert these counts into percentages and write them to a tab-separated file with the first column being the amino acid letter and the second column being the percent usage.
.setdefault may be useful for intializing you count dictionary for each new amino acid