Question

C++ Help

Task B: Translation

Growing peptide chain LysAsp Incoming RNA bound to Amino Acid Outgoing empty tRNAC TRNAİ TRNAI MessengerRNA Ribosome PeptideWhile a nucleotide is the basic unit of information, three nucleotides, or codon, is the basic unit of storage. The reason for this is that each gene codes for a protein, and all proteins are made from 20 amino acids. Recall that there are 4 different bases that make up dna. Thus, three bases can encode for 4x4x4 = 64 different symbols. Two base pairs can only encode for 4x4 = 16 symbols, which is not enough.Second position UGU cys UAUty uGC UAA Stop UGA Stop A CAU his cGC arg A Uuc Phe UCU UUA UUGUCG UAG Stop UGG trp CC uCCU CUU lFor this task, you will need the following dictionary file: codons.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 (taken from dna2b.txt), 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.

For this task, you will need to have two ifstream objects open. One for the dna file, and one for the dictionary of codons file. The same code segment from Task A can be adapted to read dna2b.txtsince we only read it once. However, for each codon in each of the DNA strand, we need to perform a dictionary lookup. It would not be very efficient to open, read, and close the file each time. The reason is because repetitive file access can become expensive and slow in the long run. The better alternative is to open the file once with one ifstream object, pass it by reference, and reset the file pointer to the beginning for each look up. This can be done with seekg(0). Below is an example that shows how to read from a file that has two fields per line where the delimiter is a space. You can modify this code to perform a look-up in codons.tsv.

void dictionary_read(ifstream &dict) {
    string key, value;
    dict.clear(); // reset error state
    dict.seekg(0); // return file pointer to the beginning
    while (dict >> key >> value) {
        cout << "key: " << key << endl;
        cout << "value: " << value << endl;
    }
}

I need help with this i only get 1 point when i upload what i have

#include
#include
#include
using namespace std;

// dont change the void everyone has done and they where still wrong

void dictionary_read(ifstream &dict) {
string key, value;
dict.clear(); // reset error state
dict.seekg(2); // return file pointer to the beginning
while (dict >> key >> value) {
cout << "key: " << key << endl;
cout << "value: " << value << endl;
}
}

//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

//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 (fin.fail()) {
cerr << "File cannot be read, opened, or does not exist.\n";
exit(1);
}
dictionary_read(fin);

//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;
}

codon.tsv(below)

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

dna2b.txt (below)

TTCGCTGGAGCCGGGCGTTACCTAAACGTTATTTCACGGAAGCTT
CCTCTAAGATTTGTTTGATACGTTACTTGTGCAGTCGAAGCTTTG
AACCGGTTAGTTTACTAGTAATTATTACTGTTAGTCAATATTGTG
ATGGGTTTTCGAGAGGGCAGGTGATACAGAATCTGAGATGCACAC
GACTAAGGTTACTGAGGGATGCACCAGACTTTACAGTTGAGACAG
GGACAACACGCGCTTGGCTAGTACCCGCCAAACATGATTACATAT
GAGGAGCGATACCCTTGCCGTCGCCTAGGTTCCGCCCCGATCCGT
TTTGAGTGCTACGTGAAACAGAGCACGTTGCAAATTTAGCCACTG

thats the error you will get

On input:
  TTCGCTGGAGCCGGGCGTTACCTAAACGTTATTTCACGGAAGCTT

Received output:
  TTCGCTGGAGCCGGGCGTTACCTAAACGTTATTTCACGGAAGCTT AAGCGACCUCGGCCCGCAAUGGAUUUGCAAUAAAGUGCCUUCGAA amino-acid chain: Met-Asp-Leu-Gln

While expected:
  Met-Asp-Leu-Gln

if you start it with this below

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

 

 
string dictionary_read(ifstream &dict, string searchkey) {
string key, value;
dict.clear(); // reset error state
dict.seekg(0); // return file pointer to the beginning
while (dict >> key >> value) {
if (searchkey.compare(key) == 0) {
return value;
}
}
return "";
}

Second position UGU cys UAUty uGC UAA Stop UGA Stop A CAU his cGC arg A Uuc Phe UCU UUA UUGUCG UAG Stop UGG trp CC uCCU CUU le CCproCAA CGG CGA CUA AUU AUC ile AUA ACU ACC thAAAys AGG asn AGU AGC Ser AGA arg G AUG met ACG asp GGC GUC aGCA GAG gyA 9h CGA GCG GAA Initiation □ Termination Pearson Education, Inc.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

Here is the program

#include <iostream>
#include <fstream>
#include <string>
using namespace std;


string dictionary_read(ifstream &dict, string searchkey) {
string key, value;
dict.clear(); // reset error state
dict.seekg(0); // return file pointer to the beginning
while (dict >> key >> value) {
if (searchkey.compare(key) == 0) {
return value;
}
}
return "";
}

//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


//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;
}

void get_amino_rep(ifstream &fin, string str) {
//ifstream fin("codons.tsv");
cout << " amino-acid chain: ";
string amino;
int start_flag=0;
for (int i=0; i<(str.size()-2); i=i+3){
//cout << i<< "-"<< str.substr(i, 3)<< ",";
amino = dictionary_read(fin, str.substr(i, 3));
if(start_flag == 0 && amino.compare("Met") == 0) {
start_flag = 1;
cout << amino;
continue;
}
if(start_flag == 1) {
if(amino.compare("Stop") == 0) {
// End the chain as Stop codon is found
break;
}
cout << "-" << amino;
}
}
//fin.close();
}

int main(){
//open file
ifstream fin("dna2b.txt");
ifstream fincodons("codons.tsv");
string strand;
string aa;
//if there is problem in opening file print error message
if (fin.fail()) {
cerr << "File dna2b.txt cannot be read, opened, or does not exist.\n";
exit(1);
}
  
if (fincodons.fail()) {
cerr << "File codons.tsv cannot be read, opened, or does not exist.\n";
exit(1);
}
  
//loop for each line untill end of file is reached
while(getline(fin, strand)) {
cout << strand << " ";
aa=DNA_to_mRNA(strand);//calling function to convert DNA to RNA
cout << aa;
size_t found = aa.find("AUG");
// If "AUG" codon found, start to find amino chain.
if (found != string::npos) {
get_amino_rep(fincodons, aa.substr(found));
} else {
cout << " - AUG codon not found.";
}
cout <<endl;
}
fin.close();//closing file
fincodons.close(); //closing codons file
return 0;
}

Here is the program output

tacaacact AUGUUGUGA amino-acid chain: Met-Leu
tactggaagtccgatcaaatc AUGACCUUCAGGCUAGUUUAG amino-acid chain: Met-Thr-Phe-Arg-Leu-Val
tacatgacgagcccacggtaggggctactcatt AUGUACUGCUCGGGUGCCAUCCCCGAUGAGUAA amino-acid chain: Met-Tyr-Cys-Ser-Gly-Ala-Ile-Pro-Asp-Glu
GCTAATGAATTT CGAUUACUUAAA - AUG codon not found.
CCGCCTTTACAA GGCGGAAAUGUU amino-acid chain: Met
TCCTGAGGTGTTG AGGACUCCACAAC - AUG codon not found.
GCGCAGCCTCTAGCGTGTTATCCC CGCGUCGGAGAUCGCACAAUAGGG - AUG codon not found.
GTTCGAAAATTCCGGGA CAAGCUUUUAAGGCCCU - AUG codon not found.
CTGGATGAAGCTTGTACTGAGAACAAT GACCUACUUCGAACAUGACUCUUGUUA amino-acid chain: Met-Thr-Leu-Val
CTCAGCTCTTAGGGAGGCGTGAGGATG GAGUCGAGAAUCCCUCCGCACUCCUAC - AUG codon not found.
TGACATCCAAGCCTTGTTA ACUGUAGGUUCGGAACAAU - AUG codon not found.
CATTAGGTAC GUAAUCCAUG amino-acid chain: Met
AGCGACCGTTGTGC UCGCUGGCAACACG - AUG codon not found.
AATTCCCAGTAAACGCCA UUAAGGGUCAUUUGCGGU - AUG codon not found.
TGGTTTAACCG ACCAAAUUGGC - AUG codon not found.
GTATAGCTGAAGGATAGCGCACGC CAUAUCGACUUCCUAUCGCGUGCG - AUG codon not found.
TTTCCTCTGTTGTGACCAAGTACC AAAGGAGACAACACUGGUUCAUGG amino-acid chain: Met
CCAAATGGATCTTG GGUUUACCUAGAAC - AUG codon not found.
CAGCCTGGGGGGAGCGCGGAATAAGTCT GUCGGACCCCCCUCGCGCCUUAUUCAGA - AUG codon not found.
CACCCGACACGCGATACGATC GUGGGCUGUGCGCUAUGCUAG amino-acid chain: Met-Leu
GCGGATTACTACTGTGTCATT CGCCUAAUGAUGACACAGUAA amino-acid chain: Met-Met-Thr-Gln
GCACTACCAAACAA CGUGAUGGUUUGUU amino-acid chain: Met-Val-Cys
AGAAGGCATT UCUUCCGUAA - AUG codon not found.

Add a comment
Know the answer?
Add Answer to:
C++ Help Task B: Translation While a nucleotide is the basic unit of information, three nucleotid...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The next DNA sequence is the MATRICE strand of a small gene. What is the complete...

    The next DNA sequence is the MATRICE strand of a small gene. What is the complete amino acid sequence of the encoded peptide? GTCATGGCAACATAG 5'-3 Standard Genetic Code First position (5'end) U Second position UAU Tyr UAC Tyr UCA Ser UAA StopUGA Stop UAG Stop UUU Phe UUC Phe UUA Leu UUG Leu UGU Cys UGC Cys UCU Ser UCC Ser UCG Ser UGG Trp CUU Leu CUC Leu CUA Leu CUG Leu CCU Pro CCC Pro CCA Pr CCG...

  • If mutations occur at random, and changes to 1st or 2nd "letter" of a codon usually...

    If mutations occur at random, and changes to 1st or 2nd "letter" of a codon usually changes the amino acid coded for, but changes to the 3rd "letter" rarely do, roughly what % of mutations should be synonymous? Second АТ G UUU Phe UCU Ser UAU Tyr UGU Cys U 0 C | Phe UCC Ser UAC Tyr UGC Cys C Leu UCA Ser UAA Stop UGA Stop UUG Leu UCG Ser UAG Stop UGG Trp G CUU Leu CCU...

  • Question 10 (15 points) Given the following sequence for a template strand of DNA 3 -...

    Question 10 (15 points) Given the following sequence for a template strand of DNA 3 - ATACTTTGTCGAGACCCGCTTCTTGCAGACTGGG A. Provide the mRNA sequence following transcription (include polarity) B. Provide the amino acid sequence using either the one letter or three letter abbreviations. Include polarity (N-or C-terminus) and be careful to start in the correct place: C. What if the "C" underlined above was changed to a T. What is the new codon? How does that affect the amino acid sequence? What...

  • The following genomic DNA sequence comes from the first exon of a human gene and contains...

    The following genomic DNA sequence comes from the first exon of a human gene and contains the 3'-end of the 5'-untranslated region and the start of a long open reading frame that codes for 200 amino acids (a.k.a. coding sequence). Note: There are no introns in this short portion and only one strand of the genomic DNA is shown. Which of the following answers lists the first three amino acids of the translated protein correctly? Seconed Position tyr ser leu...

  • Bring this DNA sequence to protein using the transcription (3pts) and translation (4 pts) processes. note:...

    Bring this DNA sequence to protein using the transcription (3pts) and translation (4 pts) processes. note: Pending the direction your DNA is located Second position UUU Ae UCU UCC cys DU Sey UAU UAC UAA UAG UGU UGC UGA UGG UUA tyr Stop Stop JC Stop CUU CUC his CUA 5 'ATGCCGACGCCATAA 3' Lleve esta secuencia de ADN hasta proteína mediante los procesos de transcripción (3pts) y traducción (4 pts). First position (5'-end) CUC AUU AUC ile AUA AUG met...

  • mestion 2 of 15 > Consider the sequencing chromatograms of the four variants of the alpha...

    mestion 2 of 15 > Consider the sequencing chromatograms of the four variants of the alpha chain of human hemoglobin. Normal Karachi Chongqing Swan River ddATP ddCTP ATD about us Careers privacy policy terms of use contact us help ddATP ddCTP ddGTP ddTTP You can use the codon table to decode each amino acid sequence. For example, the first triplet in each sequencing chromatogram is GTG, which encodes for Val. What is the nature of the amino acid change in...

  • 1. *A glycine residue is in position 210 of the tryptophan Second position synthetase enzyme of w...

    1. *A glycine residue is in position 210 of the tryptophan Second position synthetase enzyme of wild-type E. coli. If the codon specifying glycine is GGA, how many single-base substitutions will result in an amino acid change at position 210? (0.4 pt) UAU tyr uGC Juc Phe UCU UUA UAA Stop UGA St UAG Stop UGG trp CAU CUU leu | CCC pro ICAA gin | CGG CUG CCA ProCAc hisCCU AUC ile ACC AUG met ACG leu CCU CUC...

  • 7. (2 pts) Below is a DNA sequence encoding an mRNA strand. What are the first...

    7. (2 pts) Below is a DNA sequence encoding an mRNA strand. What are the first four amino acids that this sequence codes for? (Not that the coding strand has been labeled). 5'-TACTTCTGGCATATC-3' 3'-ATGAAGACCGTATAG-5' (coding) Second letter C AG UUU Phe UCU) UAU Tyrac Cys UUCS Ser UUG UACJ'Y UAA Stop UGA Stop UAG Stop UGG Trp CGU CAC) CGC CGA CGG CAU-His CUU CUC Leu CUA CUG J Pro CAAG CAGGI First letter DUO DOCUDUCUDUCU Third letter ACU AAU...

  • Some amino acids are post-translationally removed from the C-terminal end of the beta-lactamase enzyme from B....

    Some amino acids are post-translationally removed from the C-terminal end of the beta-lactamase enzyme from B. imaginarium (i.e. - after it is translated and released from the ribosome, a protease chews off a some amino acids).  The wild-type enzyme, which has had the amino acids removed from the C’-terminus, is 246 amino acids in length and the C-terminal amino acids are shown below aligned with the C-terminal amino acids of a frameshift mutant, which – due to a frameshift mutation -...

  • base pairing Done stand is positively charged and th one strand contains only purind e DNA...

    base pairing Done stand is positively charged and th one strand contains only purind e DNA elych o ly me h 40) En me that wind the DNA strands during replication A. helicase B. mucienne E primase D. DNA polymerase 41) The leading and the lasing and differ in that A) the leading strand is synthesized in the same direction is the movement of the replication fork, and the lagring strand is synthesized in the opposite direction B) the leading...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT