Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Codons.txt (file contents) uuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugu

ID: 3861177 • Letter: C

Question

C++

Codons.txt (file contents)

uuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaauuuuucuuauugcuucuccuacugauuaucauaaugguugucguagugucuuccucaucgccucccccaccgacuaccacaacggcugccgcagcguauuacuaauagcaucaccaacagaauaacaaa

Codon_list.txt (file contents)

(IN C++)

Write a program that helps match codons to their corresponding amino acids and vice versa. You will use structures, vectors and classes to accomplish this You will be given two text files: (contents of both files can be found below) Codon list.txt and Codons.txt. be found belo) One of the text files, Codon list.txt, will contain a list of amino acids and their corresponding codons. You will read this file and store the amino acids and their corresponding codons using a class, a vector and a structure to accomplish this Once you have stored this information, you will read another file: Codons.txt. You will check through the file and make sure that it contains no character other than a, u, g and c If it does, display an error message and exit. If it doesn't, proceed A codon is made up of three characters. Read the file Codons.txt and using your class, figure out and store the amino acids in a data structure. Once that is complete, prompt the user: Select one of the following: DA Display all the amino acids found in the file SF Search amino acid (prompts the user to enter the name of an amino acid, displays the number of times it appears in Codons.txt) SC Search amino acid using codon SA Search codon using amino acid E to exit (Only exit the program if the user enters E. Otherwise, keep displaying the menu.)

Explanation / Answer

AACid.h

#ifndef AAcid_H
#define AAcid_H
#include <string>

using namespace std;

class AAcid{
  
private:
string nme, abb, formulatingSeq;
  
public:
AAcid(string abb, string nme, string formulatingSeq);
string getNme();
void setNme(string nme);
string getAbbs();
void setAbbs(string thAbbs);
string getFormulaes();
void setFormulaes(string thFormulaes);
};

#endif

AminoTst.cpp

#include "AAcid.h"

using namespace std;

AAcid::AAcid(string abb, string nme, string formulatingSeq){
setNme(nme);
setAbbs(abb);
setFormulaes(formulatingSeq);
}

void AAcid::setNme(string thNme){
nme = thNme;
}

void AAcid::setAbbs(string thAbbs){
abb = thAbbs;
}

void AAcid::setFormulaes(string thFormulaes){
formulatingSeq = thFormulaes;
}

string AAcid::getNme(){return nme;}
string AAcid::getAbbs(){return abb;}
string AAcid::getFormulaes(){return formulatingSeq;}

AminoMains.cpp

#include <iostream>
#include <stdlib.h>
#include <fstream>
#include "AAcid.h"

using namespace std;

string getDNAFL(string fName);
string getTstDNA();
string transRNA(string dnas);
string codAmino(string cod, string codDataBase[][2]);
AAcid * getAmino(string abb, AAcid * aapntr[]);
bool isCodonStrt(string cod);
bool isCodonStp(string cod);
bool isLst(string aming, string ttlAmino[], int ttlCntr);

const int CODONS_TTL = 64;

int main(int argc, char *argv[])
{
  
if(argc != 2){
cout << " To use this program, type ./HW_Amino <fName>" << endl;
cout <<"Alternatively, type ./HW_Amino "test" to run program with sample dnas strand" << endl;
return 1;
}
  
  
string codDataBase[CODONS_TTL][2] = {
{"uuu","Phe"},{"uuc","Phe"},
{"uua","Leu"},{"uug","Leu"},{"cuu","Leu"},{"cuc","Leu"},{"cua","Leu"},{"cug","Leu"},
{"auu","Ile"},{"auc","Ile"},{"aua","Ile"},
{"aug","Met"},   
{"guu","Val"},{"guc","Val"},{"gua","Val"},{"gug","Val"},
{"ucu","Ser"},{"ucc","Ser"},{"uca","Ser"},{"ucg","Ser"},{"agu","Ser"},{"agc","Ser"},
{"ccu","Pro"},{"ccc","Pro"},{"cca","Pro"},{"ccg","Pro"},
{"acu","Thr"},{"acc","Thr"},{"aca","Thr"},{"acg","Thr"},
{"gcu","Ala"},{"gcc","Ala"},{"gca","Ala"},{"gcg","Ala"},
{"uau","Tyr"},{"uac","Tyr"},
{"uaa","TER"},{"uag","TER"},{"uga","TER"},
{"cau","His"},{"cac","His"},
{"caa","Gln"},{"cag","Gln"},
{"aau","Asn"},{"aac","Asn"},
{"aaa","Lys"},{"aag","Lys"},
{"gau","Asp"},{"gac","Asp"},
{"gaa","Glu"},{"gag","Glu"},
{"ugu","Cys"},{"ugc","Cys"},
{"ugg","Trp"},
{"cgu","Arg"},{"cgc","Arg"},{"cga","Arg"},{"cgg","Arg"},{"aga","Arg"},{"agg","Arg"},
{"ggu","Gly"},{"ggc","Gly"},{"gga","Gly"},{"ggg","Gly"}
};
  
AAcid Phe("Phe","Phenylalanine","C6H5CH2CH(NH2)COOH"),
Leu("Leu","Leucine","HO2CCH(NH2)CH2CH(CH3)2"),
Ile("Ile","Isoleucine","HO2CCH(NH2)CH(CH3)CH2CH3"),
Met("Met", "Methionine", "HO2CCH(NH2)CH2CH2SCH3"),
Val("Val", "Valine", "C5H11NO2"),
Ser("Ser", "Serine", "HO2CCH(NH2)CH2OH"),
Pro("Pro", "Proline", "C5H9NO2"),
Thr("Thr", "Threonine", "HO2CCH(NH2)CH(OH)CH3"),
Ala("Ala", "Alanine", "CH3CH(NH2)COOH"),
Tyr("Tyr", "Tyrosine", "C9H11NO3"),
His("His", "Histidine", "C6H9N3O2"),
Gln("Gln", "Glycine", "C2H5NO2"),
Asn("Asn", "Asparagine", "C4H8N2O3"),
Lys("Lys", "Lysine", "HO2CCH(NH2)(CH2)4NH2"),
Asp("Asp", "Aspartic Acid", "HOOCCH(NH2)CH2COOH"),
Glu("Glu", "Glutamic Acid", "C5H9NO4"),
Cys("Cys", "Cysteine", "HO2CCH(NH2)CH2SH"),
Trp("Trp", "Tryptophan", "C11H12N2O2"),
Arg("Arg", "Arginine", "C6H14N4O2"),
Gly("Gly", "Glycine", "NH2CH2COOH");
  
AAcid * phen_P = &Phe, * leu_PP = &Leu, * ile_PP = &Ile, * met_PP = &Met,
* val_PP = &Val, * ser_PP = &Ser, * pro_PP = &Pro, * thr_PP = &Thr,
* ala_PP = &Ala, * tyr_PP = &Tyr, * hys_PP = &His, * glnn_PP = &Gln,
* asn_PP = &Asn, * lys_PP = &Lys, * asp_PP = &Asp, * lu_PP = &Glu,
* sys_PP = &Cys, * trp_PP = &Trp, * argss_PP = &Arg, * glyt_P = &Gly;
  
AAcid * aapntr[] = {phen_P, leu_PP, ile_PP, met_PP, val_PP, ser_PP, pro_PP,
thr_PP, ala_PP, tyr_PP, hys_PP, glnn_PP, asn_PP, lys_PP,
asp_PP, lu_PP, sys_PP, trp_PP, argss_PP, glyt_P};

string dnas, rnas, codonT, acidT, ttlAcid[20], mainIP = argv[1];
int nob = 0, ttlAcid = 0;
bool rec = false, isFrstSeq = true;
AAcid * acid_PP;

  
if(mainIP.compare("test") == 0)
dnas = getTstDNA();
else
dnas = getDNAFL(argv[1]);
  
rnas = transRNA(dnas);
  
  
  
cout << endl;
while(nob < rnas.size()){   
codonT = rnas.substr(nob,3);
if(isCodonStrt(codonT))
rec = true;
if(isCodonStp(codonT)){
rec = false;
isFrstSeq = true;
cout << endl;
}
if(rec){
acidT = codAmino(codonT,codDataBase);
if(!isLst(acidT,ttlAcid,ttlAcid)){
ttlAcid[ttlAcid] = acidT;
ttlAcid++;
}
if(isFrstSeq){
cout << acidT;
isFrstSeq = false;
} else
cout << "-" << acidT;
nob +=3;
}
else
nob++;
}
  
  
cout << endl;
for(int nob = 0; nob < ttlAcid; nob++){
acid_PP = getAmino(ttlAcid[nob],aapntr);
cout << (*acid_PP).getAbbs()<< " " << (*acid_PP).getNme() << " " << (*acid_PP).getFormulaes();
cout << endl;
}
  
return 0;
}


bool isLst(string aming, string ttlAmino[], int ttlCntr){
bool res = false;
for(int nob = 0; nob < ttlCntr; nob++){
if(aming.compare(ttlAmino[nob]) == 0)
res = true;
}
return res;
}

string getTstDNA(){
return "atggtttatggtctctgaattaatctccatgttttatcactaa";
}

string getDNAFL(string fName){
string dat;
ifstream inputFile;
inputFile.open(fName.c_str());
if(inputFile){
inputFile >> dat;
getline(inputFile,dat);
inputFile.close();
} else
cout << "ERROR: Cannot find file " << fName << endl;
return dat;
}

string transRNA(string dnas){
for(int nob = 0; nob < dnas.size(); nob++){
if(dnas[nob] == 't')
dnas[nob] = 'u';
}
return dnas;
}

bool isCodonStrt(string cod){
bool res = false;
if(cod.compare("aug") == 0)
res = true;
return res;
}

bool isCodonStp(string cod){
bool res = false;
if(cod.compare("uaa") == 0 || cod.compare("uag") == 0 || cod.compare("uga") == 0)
res = true;
return res;
}

string codAmino(string cod, string codDataBase[][2]){
string res;
bool searchin = false;
for(int nob = 0; nob < CODONS_TTL; nob++){
if(cod.compare(codDataBase[nob][0]) == 0){
res = codDataBase[nob][1];
searchin = true;
}
}
if(!searchin)
cout << "ERROR: Cannot find aming for cod << " << cod << endl;
return res;   
}

AAcid * getAmino(string abb, AAcid * aapntr[]){
AAcid * res;
if(abb.compare("Phe") == 0)
res = aapntr[0];
if(abb.compare("Leu") == 0)
res = aapntr[1];
if(abb.compare("Ile") == 0)
res = aapntr[2];
if(abb.compare("Met") == 0)
res = aapntr[3];
if(abb.compare("Val") == 0)
res = aapntr[4];
if(abb.compare("Ser") == 0)
res = aapntr[5];
if(abb.compare("Pro") == 0)
res = aapntr[6];
if(abb.compare("Thr") == 0)
res = aapntr[7];
if(abb.compare("Ala") == 0)
res = aapntr[8];
if(abb.compare("Tyr") == 0)
res = aapntr[9];
if(abb.compare("His") == 0)
res = aapntr[10];
if(abb.compare("Gln") == 0)
res = aapntr[11];
if(abb.compare("Asn") == 0)
res = aapntr[12];
if(abb.compare("Lys") == 0)
res = aapntr[13];
if(abb.compare("Asp") == 0)
res = aapntr[14];
if(abb.compare("Glu") == 0)
res = aapntr[15];
if(abb.compare("Cys") == 0)
res = aapntr[16];
if(abb.compare("Trp") == 0)
res = aapntr[17];
if(abb.compare("Arg") == 0)
res = aapntr[18];
if(abb.compare("Gly") == 0)
res = aapntr[19];
return res;
}

Please rate the answer if it helped......Thankyou

Hope it helps.....