SlideShare a Scribd company logo
Please find the required program along with the comments against each line, also find the output
at last :
#include
#include
#include
#include
using namespace std;
void listCodonPositions(string dna, string codon){
vector positions; // holds all the positions that codon occurs within dna
size_t pos = dna.find(codon, 0); // finds the first occurance of codon
if(pos != string::npos) //if no codon is found
cout << pos << " " << flush;
else
cout << "No occurance" << flush;
while(pos != string::npos) //iterate till no occurance is found in a dna
{
pos = dna.find(codon,pos+1); //find next occurance
if(pos != string::npos) //if no codon is found
cout << pos << " " << flush;
}
cout << endl;
}
int main()
{
string humanDNA =
"CGCAAATTTGCCGGATTTCCTTTGCTGTTCCTGCATGTAGTTTAAACGAGATTGCCA
GCACCGGGTATCATTCACCATTTTTCTTTTCGTTAACTTGCCGTCAGCCTTTTCTTTGA
CCTCTTCTTTCTGTTCATGTGTATTTGCTGTCTCTTAGCCCAGACTTCCCGTGTCCTTT
CCACCGGGCCTTTGAGAGGTCACAGGGTCTTGATGCTGTGGTCTTCATCTGCAGGTG
TCTGACTTCCAGCAACTGCTGGCCTGTGCCAGGGTGCAGCTGAGCACTGGAGTGGAG
TTTTCCTGTGGAGAGGAGCCATGCCTAGAGTGGGATGGGCCATTGTTCATG";
string mouseDNA =
"CGCAATTTTTACTTAATTCTTTTTCTTTTAATTCATATATTTTTAATATGTTTACTAT
TAATGGTTATCATTCACCATTTAACTATTTGTTATTTTGACGTCATTTTTTTCTATTTC
CTCTTTTTTCAATTCATGTTTATTTTCTGTATTTTTGTTAAGTTTTCACAAGTCTAATA
TAATTGTCCTTTGAGAGGTTATTTGGTCTATATTTTTTTTTCTTCATCTGTATTTTTAT
GATTTCATTTAATTGATTTTCATTGACAGGGTTCTGCTGTGTTCTGGATTGTATTTTTC
TTGTGGAGAGGAACTATTTCTTGAGTGGGATGTACCTTTGTTCTTG";
string unknownDNA =
"CGCATTTTTGCCGGTTTTCCTTTGCTGTTTATTCATTTATTTTAAACGATATTTATAT
CATCGGGTTTCATTCACTATTTTTCTTTTCGATAAATTTTTGTCAGCATTTTCTTTTAC
CTCTTCTTTCTGTTTATGTTAATTTTCTGTTTCTTAACCCAGTCTTCTCGATTCTTATCT
ACCGGACCTATTATAGGTCACAGGGTCTTGATGCTTTGGTTTTCATCTGCAAGAGTCT
GACTTCCTGCTAATGCTGTTCTGTGTCAGGGTGCATCTGAGCACTGATGTGGAGTTTT
CTTGTGGATATGAGCCATTCATAGTGTGGGATGTGCCATAGTTCATG";
string codon;
cout << "Enter codon : " << endl;
cin >> codon;
char exit[] = "*";
while(strcmp(codon.c_str(),exit)!=0){
cout << "Occurances in humanDNA : "<< endl;
listCodonPositions(humanDNA,codon);
cout << "Occurances in mouseDNA : "<< endl;
listCodonPositions(mouseDNA,codon);
cout << "Occurances in unknownDNA : "<< endl;
listCodonPositions(unknownDNA,codon);
cout << "Enter codon : " << endl;
cin >> codon;
}
}
--------------------------------------------------------------------------------
OUTPUT :
Enter codon :
AAA
Occurances in humanDNA :
3 43
Occurances in mouseDNA :
No occurance
Occurances in unknownDNA :
43 91
Enter codon :
TGC
Occurances in humanDNA :
8 22 31 52 95 141 208 224 248 258 266 310
Occurances in mouseDNA :
269
Occurances in unknownDNA :
8 22 208 224 242 248 266 326
Enter codon :
*
Solution
Please find the required program along with the comments against each line, also find the output
at last :
#include
#include
#include
#include
using namespace std;
void listCodonPositions(string dna, string codon){
vector positions; // holds all the positions that codon occurs within dna
size_t pos = dna.find(codon, 0); // finds the first occurance of codon
if(pos != string::npos) //if no codon is found
cout << pos << " " << flush;
else
cout << "No occurance" << flush;
while(pos != string::npos) //iterate till no occurance is found in a dna
{
pos = dna.find(codon,pos+1); //find next occurance
if(pos != string::npos) //if no codon is found
cout << pos << " " << flush;
}
cout << endl;
}
int main()
{
string humanDNA =
"CGCAAATTTGCCGGATTTCCTTTGCTGTTCCTGCATGTAGTTTAAACGAGATTGCCA
GCACCGGGTATCATTCACCATTTTTCTTTTCGTTAACTTGCCGTCAGCCTTTTCTTTGA
CCTCTTCTTTCTGTTCATGTGTATTTGCTGTCTCTTAGCCCAGACTTCCCGTGTCCTTT
CCACCGGGCCTTTGAGAGGTCACAGGGTCTTGATGCTGTGGTCTTCATCTGCAGGTG
TCTGACTTCCAGCAACTGCTGGCCTGTGCCAGGGTGCAGCTGAGCACTGGAGTGGAG
TTTTCCTGTGGAGAGGAGCCATGCCTAGAGTGGGATGGGCCATTGTTCATG";
string mouseDNA =
"CGCAATTTTTACTTAATTCTTTTTCTTTTAATTCATATATTTTTAATATGTTTACTAT
TAATGGTTATCATTCACCATTTAACTATTTGTTATTTTGACGTCATTTTTTTCTATTTC
CTCTTTTTTCAATTCATGTTTATTTTCTGTATTTTTGTTAAGTTTTCACAAGTCTAATA
TAATTGTCCTTTGAGAGGTTATTTGGTCTATATTTTTTTTTCTTCATCTGTATTTTTAT
GATTTCATTTAATTGATTTTCATTGACAGGGTTCTGCTGTGTTCTGGATTGTATTTTTC
TTGTGGAGAGGAACTATTTCTTGAGTGGGATGTACCTTTGTTCTTG";
string unknownDNA =
"CGCATTTTTGCCGGTTTTCCTTTGCTGTTTATTCATTTATTTTAAACGATATTTATAT
CATCGGGTTTCATTCACTATTTTTCTTTTCGATAAATTTTTGTCAGCATTTTCTTTTAC
CTCTTCTTTCTGTTTATGTTAATTTTCTGTTTCTTAACCCAGTCTTCTCGATTCTTATCT
ACCGGACCTATTATAGGTCACAGGGTCTTGATGCTTTGGTTTTCATCTGCAAGAGTCT
GACTTCCTGCTAATGCTGTTCTGTGTCAGGGTGCATCTGAGCACTGATGTGGAGTTTT
CTTGTGGATATGAGCCATTCATAGTGTGGGATGTGCCATAGTTCATG";
string codon;
cout << "Enter codon : " << endl;
cin >> codon;
char exit[] = "*";
while(strcmp(codon.c_str(),exit)!=0){
cout << "Occurances in humanDNA : "<< endl;
listCodonPositions(humanDNA,codon);
cout << "Occurances in mouseDNA : "<< endl;
listCodonPositions(mouseDNA,codon);
cout << "Occurances in unknownDNA : "<< endl;
listCodonPositions(unknownDNA,codon);
cout << "Enter codon : " << endl;
cin >> codon;
}
}
--------------------------------------------------------------------------------
OUTPUT :
Enter codon :
AAA
Occurances in humanDNA :
3 43
Occurances in mouseDNA :
No occurance
Occurances in unknownDNA :
43 91
Enter codon :
TGC
Occurances in humanDNA :
8 22 31 52 95 141 208 224 248 258 266 310
Occurances in mouseDNA :
269
Occurances in unknownDNA :
8 22 208 224 242 248 266 326
Enter codon :
*

More Related Content

PDF
(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf
PDF
You can think of H as being heat energy added ( + ), or heat removed.pdf
PDF
wait, i am posting the solution.Solutionwait, i am posting the.pdf
PDF
There are many other contributing factors to the norms of culture th.pdf
PDF
Thermal dimorphism is the capacity to form different structures at d.pdf
PDF
The prime factor of 210=2357 Anyways, numbers can only be divid.pdf
PDF
The OSI Reference Model layers, in order from top to bottomD. Appl.pdf
PDF
Synchronous IO CPU waits till the IO proceeds.Asynchronous IO.pdf
(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf
You can think of H as being heat energy added ( + ), or heat removed.pdf
wait, i am posting the solution.Solutionwait, i am posting the.pdf
There are many other contributing factors to the norms of culture th.pdf
Thermal dimorphism is the capacity to form different structures at d.pdf
The prime factor of 210=2357 Anyways, numbers can only be divid.pdf
The OSI Reference Model layers, in order from top to bottomD. Appl.pdf
Synchronous IO CPU waits till the IO proceeds.Asynchronous IO.pdf

More from rdtraders2007 (20)

PDF
SolutionSolutionSolution.pdf
PDF
slope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdf
PDF
s(s^2-b^2)Solutions(s^2-b^2).pdf
PDF
Question not visible. Please update the question and then i can answ.pdf
PDF
Order the steps of the viral life cycle.1. viral entry into host.pdf
PDF
Listing of the type of alleles present in an organisms cellGenotyp.pdf
PDF
An Operating System (OS) is an interface between a computer user and.pdf
PDF
Internal Evidence General.pdf
PDF
In reaction # 3 either the cis or trans diol may .pdf
PDF
Intermolecular forces exist between molecules and.pdf
PDF
H2 concentration will decrease and H2O concentrat.pdf
PDF
elemental form of sodium and hydrogen is very rea.pdf
PDF
C. Both A and B are correct .pdf
PDF
C gained 2 hydrogen. It was reduced. It is theref.pdf
PDF
B. Li Solution B. Li .pdf
PDF
A is stronger acid because it give more H+ to sol.pdf
PDF
Error message number = int(input(Enter a number ))     Name.pdf
PDF
Dear,The answer is .7.SolutionDear,The answer is .7..pdf
PDF
Crayfish contain an exoskeleton which means it needs to get rid of i.pdf
PDF
BasicPizza.javapublic class BasicPizza { String type; String c.pdf
SolutionSolutionSolution.pdf
slope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdf
s(s^2-b^2)Solutions(s^2-b^2).pdf
Question not visible. Please update the question and then i can answ.pdf
Order the steps of the viral life cycle.1. viral entry into host.pdf
Listing of the type of alleles present in an organisms cellGenotyp.pdf
An Operating System (OS) is an interface between a computer user and.pdf
Internal Evidence General.pdf
In reaction # 3 either the cis or trans diol may .pdf
Intermolecular forces exist between molecules and.pdf
H2 concentration will decrease and H2O concentrat.pdf
elemental form of sodium and hydrogen is very rea.pdf
C. Both A and B are correct .pdf
C gained 2 hydrogen. It was reduced. It is theref.pdf
B. Li Solution B. Li .pdf
A is stronger acid because it give more H+ to sol.pdf
Error message number = int(input(Enter a number ))     Name.pdf
Dear,The answer is .7.SolutionDear,The answer is .7..pdf
Crayfish contain an exoskeleton which means it needs to get rid of i.pdf
BasicPizza.javapublic class BasicPizza { String type; String c.pdf

Recently uploaded (20)

PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
Cell Structure & Organelles in detailed.
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Types and Its function , kingdom of life
PDF
01-Introduction-to-Information-Management.pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Trump Administration's workforce development strategy
PDF
Updated Idioms and Phrasal Verbs in English subject
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
Cell Structure & Organelles in detailed.
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Microbial disease of the cardiovascular and lymphatic systems
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
UNIT III MENTAL HEALTH NURSING ASSESSMENT
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Classroom Observation Tools for Teachers
Cell Types and Its function , kingdom of life
01-Introduction-to-Information-Management.pdf
Paper A Mock Exam 9_ Attempt review.pdf.
Trump Administration's workforce development strategy
Updated Idioms and Phrasal Verbs in English subject
Final Presentation General Medicine 03-08-2024.pptx
What if we spent less time fighting change, and more time building what’s rig...
Anesthesia in Laparoscopic Surgery in India
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
STATICS OF THE RIGID BODIES Hibbelers.pdf
ChatGPT for Dummies - Pam Baker Ccesa007.pdf

Please find the required program along with the comments against eac.pdf

  • 1. Please find the required program along with the comments against each line, also find the output at last : #include #include #include #include using namespace std; void listCodonPositions(string dna, string codon){ vector positions; // holds all the positions that codon occurs within dna size_t pos = dna.find(codon, 0); // finds the first occurance of codon if(pos != string::npos) //if no codon is found cout << pos << " " << flush; else cout << "No occurance" << flush; while(pos != string::npos) //iterate till no occurance is found in a dna { pos = dna.find(codon,pos+1); //find next occurance if(pos != string::npos) //if no codon is found cout << pos << " " << flush; } cout << endl; } int main() { string humanDNA = "CGCAAATTTGCCGGATTTCCTTTGCTGTTCCTGCATGTAGTTTAAACGAGATTGCCA GCACCGGGTATCATTCACCATTTTTCTTTTCGTTAACTTGCCGTCAGCCTTTTCTTTGA CCTCTTCTTTCTGTTCATGTGTATTTGCTGTCTCTTAGCCCAGACTTCCCGTGTCCTTT CCACCGGGCCTTTGAGAGGTCACAGGGTCTTGATGCTGTGGTCTTCATCTGCAGGTG
  • 2. TCTGACTTCCAGCAACTGCTGGCCTGTGCCAGGGTGCAGCTGAGCACTGGAGTGGAG TTTTCCTGTGGAGAGGAGCCATGCCTAGAGTGGGATGGGCCATTGTTCATG"; string mouseDNA = "CGCAATTTTTACTTAATTCTTTTTCTTTTAATTCATATATTTTTAATATGTTTACTAT TAATGGTTATCATTCACCATTTAACTATTTGTTATTTTGACGTCATTTTTTTCTATTTC CTCTTTTTTCAATTCATGTTTATTTTCTGTATTTTTGTTAAGTTTTCACAAGTCTAATA TAATTGTCCTTTGAGAGGTTATTTGGTCTATATTTTTTTTTCTTCATCTGTATTTTTAT GATTTCATTTAATTGATTTTCATTGACAGGGTTCTGCTGTGTTCTGGATTGTATTTTTC TTGTGGAGAGGAACTATTTCTTGAGTGGGATGTACCTTTGTTCTTG"; string unknownDNA = "CGCATTTTTGCCGGTTTTCCTTTGCTGTTTATTCATTTATTTTAAACGATATTTATAT CATCGGGTTTCATTCACTATTTTTCTTTTCGATAAATTTTTGTCAGCATTTTCTTTTAC CTCTTCTTTCTGTTTATGTTAATTTTCTGTTTCTTAACCCAGTCTTCTCGATTCTTATCT ACCGGACCTATTATAGGTCACAGGGTCTTGATGCTTTGGTTTTCATCTGCAAGAGTCT GACTTCCTGCTAATGCTGTTCTGTGTCAGGGTGCATCTGAGCACTGATGTGGAGTTTT CTTGTGGATATGAGCCATTCATAGTGTGGGATGTGCCATAGTTCATG"; string codon; cout << "Enter codon : " << endl; cin >> codon; char exit[] = "*"; while(strcmp(codon.c_str(),exit)!=0){ cout << "Occurances in humanDNA : "<< endl; listCodonPositions(humanDNA,codon); cout << "Occurances in mouseDNA : "<< endl; listCodonPositions(mouseDNA,codon); cout << "Occurances in unknownDNA : "<< endl; listCodonPositions(unknownDNA,codon); cout << "Enter codon : " << endl;
  • 3. cin >> codon; } } -------------------------------------------------------------------------------- OUTPUT : Enter codon : AAA Occurances in humanDNA : 3 43 Occurances in mouseDNA : No occurance Occurances in unknownDNA : 43 91 Enter codon : TGC Occurances in humanDNA : 8 22 31 52 95 141 208 224 248 258 266 310 Occurances in mouseDNA : 269 Occurances in unknownDNA : 8 22 208 224 242 248 266 326 Enter codon : * Solution Please find the required program along with the comments against each line, also find the output at last : #include #include #include #include using namespace std; void listCodonPositions(string dna, string codon){
  • 4. vector positions; // holds all the positions that codon occurs within dna size_t pos = dna.find(codon, 0); // finds the first occurance of codon if(pos != string::npos) //if no codon is found cout << pos << " " << flush; else cout << "No occurance" << flush; while(pos != string::npos) //iterate till no occurance is found in a dna { pos = dna.find(codon,pos+1); //find next occurance if(pos != string::npos) //if no codon is found cout << pos << " " << flush; } cout << endl; } int main() { string humanDNA = "CGCAAATTTGCCGGATTTCCTTTGCTGTTCCTGCATGTAGTTTAAACGAGATTGCCA GCACCGGGTATCATTCACCATTTTTCTTTTCGTTAACTTGCCGTCAGCCTTTTCTTTGA CCTCTTCTTTCTGTTCATGTGTATTTGCTGTCTCTTAGCCCAGACTTCCCGTGTCCTTT CCACCGGGCCTTTGAGAGGTCACAGGGTCTTGATGCTGTGGTCTTCATCTGCAGGTG TCTGACTTCCAGCAACTGCTGGCCTGTGCCAGGGTGCAGCTGAGCACTGGAGTGGAG TTTTCCTGTGGAGAGGAGCCATGCCTAGAGTGGGATGGGCCATTGTTCATG"; string mouseDNA = "CGCAATTTTTACTTAATTCTTTTTCTTTTAATTCATATATTTTTAATATGTTTACTAT TAATGGTTATCATTCACCATTTAACTATTTGTTATTTTGACGTCATTTTTTTCTATTTC CTCTTTTTTCAATTCATGTTTATTTTCTGTATTTTTGTTAAGTTTTCACAAGTCTAATA TAATTGTCCTTTGAGAGGTTATTTGGTCTATATTTTTTTTTCTTCATCTGTATTTTTAT GATTTCATTTAATTGATTTTCATTGACAGGGTTCTGCTGTGTTCTGGATTGTATTTTTC TTGTGGAGAGGAACTATTTCTTGAGTGGGATGTACCTTTGTTCTTG"; string unknownDNA =
  • 5. "CGCATTTTTGCCGGTTTTCCTTTGCTGTTTATTCATTTATTTTAAACGATATTTATAT CATCGGGTTTCATTCACTATTTTTCTTTTCGATAAATTTTTGTCAGCATTTTCTTTTAC CTCTTCTTTCTGTTTATGTTAATTTTCTGTTTCTTAACCCAGTCTTCTCGATTCTTATCT ACCGGACCTATTATAGGTCACAGGGTCTTGATGCTTTGGTTTTCATCTGCAAGAGTCT GACTTCCTGCTAATGCTGTTCTGTGTCAGGGTGCATCTGAGCACTGATGTGGAGTTTT CTTGTGGATATGAGCCATTCATAGTGTGGGATGTGCCATAGTTCATG"; string codon; cout << "Enter codon : " << endl; cin >> codon; char exit[] = "*"; while(strcmp(codon.c_str(),exit)!=0){ cout << "Occurances in humanDNA : "<< endl; listCodonPositions(humanDNA,codon); cout << "Occurances in mouseDNA : "<< endl; listCodonPositions(mouseDNA,codon); cout << "Occurances in unknownDNA : "<< endl; listCodonPositions(unknownDNA,codon); cout << "Enter codon : " << endl; cin >> codon; } } -------------------------------------------------------------------------------- OUTPUT : Enter codon : AAA Occurances in humanDNA : 3 43
  • 6. Occurances in mouseDNA : No occurance Occurances in unknownDNA : 43 91 Enter codon : TGC Occurances in humanDNA : 8 22 31 52 95 141 208 224 248 258 266 310 Occurances in mouseDNA : 269 Occurances in unknownDNA : 8 22 208 224 242 248 266 326 Enter codon : *