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

in c++ with result please Summary analyze a set of DNA strands for validity, CG

ID: 3872952 • Letter: I

Question


in c++ with result please

Summary analyze a set of DNA strands for validity, CG percentage, and overall stability Write a complete C++ program to analyze a set of DNA strands input from the keyboard. For each strand, output the strand followed by validity, CG percentage, and overall stability For example, given this input sequence CCGA ACTGATGC ACTGATTX TTCAA Your program should output the following ccca: valid, cc-75, highly stable ACTGATGC: valid, CG-50%, stable ACTGATXc: invalid TTCAA: valid, co-20*, unstable In terms of overall stability, if the CG percentage is 75 or greater, than the DNA strand is considered 'highly stable' If the CG percentage is e 75 but 50 or greater, it's considered "stable Less than 50 but 25 or greater is considered 'less stable': And a CG percentage

Explanation / Answer

#include<iostream>
#include<vector>
#include<string>
#include<sstream>
using namespace std;

main()
{
// declaring variables
vector<string> dnaname;
vector<int> dnaper;
int index = 0, cg, per,flag;
string dna;
  
cin >> dna;
  
// as long as dna is not #
while(dna!="#"){
  
cg = 0;
flag = 0;
  
// looping through each character in dna
for(int i=0;i<dna.length();i++)
{
// if it is c or g then incrementing cg by 1
if(dna[i]=='C' || dna[i]=='G')
cg++;
// else if it is neither t nor a then it is invalid character.
// Setting the flag and not considering it further
else if(dna[i]!='T' and dna[i]!='A')
flag = 1;
}
  
// pusing dna to vector
dnaname.push_back(dna);
  
// valid dna and calculating percentage
if(flag == 0)
{
per = (cg*1.0/dna.length())*100;
dnaper.push_back(per);
}
//not considering it further hence pushing -1
else
{
dnaper.push_back(-1);
}
cin >> dna;
}
  
// looping through each dna and printing output
for(int i=0;i<dnaname.size();i++)
{
cout << dnaname[i];
if(dnaper[i]>=75)
cout << ": valid, CG=" << dnaper[i] << "%, highly stable"<< endl;
else if(dnaper[i]>=50)
cout << ": valid, CG=" << dnaper[i] << "%, stable"<< endl;
else if(dnaper[i]>=25)
cout << ": valid, CG=" << dnaper[i] << "%, less stable"<< endl;
else if(dnaper[i]==-1)
cout << ": invalid" << endl;
else
cout << ": valid, CG=" << dnaper[i] << "%, unstable"<< endl;
}
}

#include<iostream>
#include<vector>
#include<string>
#include<sstream>
using namespace std;

main()
{
// declaring variables
vector<string> dnaname;
vector<int> dnaper;
int index = 0, cg, per,flag;
string dna;
  
cin >> dna;
  
// as long as dna is not #
while(dna!="#"){
  
cg = 0;
flag = 0;
  
// looping through each character in dna
for(int i=0;i<dna.length();i++)
{
// if it is c or g then incrementing cg by 1
if(dna[i]=='C' || dna[i]=='G')
cg++;
// else if it is neither t nor a then it is invalid character.
// Setting the flag and not considering it further
else if(dna[i]!='T' and dna[i]!='A')
flag = 1;
}
  
// pusing dna to vector
dnaname.push_back(dna);
  
// valid dna and calculating percentage
if(flag == 0)
{
per = (cg*1.0/dna.length())*100;
dnaper.push_back(per);
}
//not considering it further hence pushing -1
else
{
dnaper.push_back(-1);
}
cin >> dna;
}
  
// looping through each dna and printing output
for(int i=0;i<dnaname.size();i++)
{
cout << dnaname[i];
if(dnaper[i]>=75)
cout << ": valid, CG=" << dnaper[i] << "%, highly stable"<< endl;
else if(dnaper[i]>=50)
cout << ": valid, CG=" << dnaper[i] << "%, stable"<< endl;
else if(dnaper[i]>=25)
cout << ": valid, CG=" << dnaper[i] << "%, less stable"<< endl;
else if(dnaper[i]==-1)
cout << ": invalid" << endl;
else
cout << ": valid, CG=" << dnaper[i] << "%, unstable"<< endl;
}
}

  SAMPLE OUTPUT   CCGA   ACTGATGC   ACTGATXC   TTCAA   #  CCGA: valid, CG=75%, highly stable  ACTGATGC: valid, CG=50%, stable  ACTGATXC: invalid  TTCAA: valid, CG=20%, unstable