Question
For this task, you will need the following dictionary file: codon.tsv. It contains 64 lines, each with two columns. In the first column are the
For this task, you will need the following dictionary file: codon.tsv. It contains 64 lines, each with two columns. In the first column are the codons, and in the second are the corresponding amino acid. Your task is to write a program called Translatase.cpp that given strands of DNA (such as those in Task A), outputs to the console the corresponding amino-acid chain. Feel free to use your code from Task A to convert the DNA into mRNA to match the codons in the dictionary. Notice that there are 4 special codons: Met, which stands for Methionine, and 3 Stop codons. Methionine is the first amino acid in every protein chain and as such serves as the Start codon. This means that translation does not begin until the AUG codon, which encodes for methionine, has been read. The three Stop codons, UAA, UGA, and UAG, are not included in the protein chain and simply signify the end of translation. The rules of formatting are as follows:
- Use the three-letter abreviation from the dictionary for each amino acid
- Insert a hyphen after each amino acid except for the last
- The first amino acid should always be Met
- Stop codons should not be inserted e. g. tacaacact would produce Met-Leu.
codon.tsv list:
GCU Ala GCC Ala GCA Ala GCG Ala CGU Arg CGC Arg CGA Arg CGG Arg AGA Arg AGG Arg AAU Asn AAC Asn GAU Asp GAC Asp UGU Cys UGC Cys CAA Gln CAG Gln GAA Glu GAG Glu GGU Gly GGC Gly GGA Gly GGG Gly CAU His CAC His AUU Ile AUC Ile AUA Ile AUG Met UUA Leu UUG Leu CUU Leu CUC Leu CUA Leu CUG Leu AAA Lys AAG Lys UUU Phe UUC Phe CCU Pro CCC Pro CCA Pro CCG Pro UCU Ser UCC Ser UCA Ser UCG Ser AGU Ser AGC Ser ACU Thr ACC Thr ACA Thr ACG Thr UGG Trp UAU Tyr UAC Tyr GUU Val GUC Val GUA Val GUG Val UAA Stop UGA Stop UAG Stop
Part A: From ffarazs
#include
//function to convert character from DNA to RNA(finding complement) char DNAbase_to_mRNAbase(char dna){
if(toupper(dna)=='A') //if A the convert to U return 'U'; else if(toupper(dna)=='T') //if T the convert to A return 'A'; else if(toupper(dna)=='C') //if C the convert to G return 'G'; else if(toupper(dna)=='G') //if G the convert to C return 'C'; else //Else return space return ' '; }
string DNA_to_mRNA(string input){ string output="";//initialising output to empty string
//below I provided two methods use that you feel comfortable /*for(char& c : input) { output=output+DNAbase_to_mRNAbase(c); }*/ //looping through each value and converting character by character for(int i = 0; i < input.size(); ++i) { output=output+DNAbase_to_mRNAbase(input[i]);//adding converted to } //returning converted string return output; } //main function int main(){ //open file ifstream fin("dna.txt"); string strand; //if there is problem in opening file print error message if (fin.fail()) { cerr << "File cannot be read, opened, or does not exist. "; exit(1); } //loop for each line untill end of file is reached while(getline(fin, strand)) { cout << DNA_to_mRNA(strand) << endl; //calling function to convert DNA to RNA } fin.close();//closing file return 0; }
Thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started