|
#include <iostream> |
|
#include <string> |
|
#include <vector> |
|
#include <algorithm> |
|
|
|
using namespace std; |
|
|
|
const string DNA = "ACTGCGACGGTACGCTTCGACGTAG"; |
|
const size_t taille = DNA.size(); |
|
|
|
size_t m = 3; |
|
vector<string> v; |
|
|
|
bool checkDNA(string &s); |
|
string takeStrings(const string &s,size_t i, size_t m); |
|
void FindSequenceDNA(vector<string>&s,string sq); |
|
size_t incrementValue(size_t &m); |
|
|
|
int main(){ |
|
|
|
string DNAuser; |
|
cout << "Introduce the DNA: "; |
|
cin >> DNAuser; |
|
|
|
bool request; |
|
cout << boolalpha; |
|
request = DNAuser.find_first_not_of("AGCT"); |
|
cout << request << endl; |
|
|
|
vector<string> vectorSq; |
|
size_t auxiliar = 0; |
|
string r; |
|
size_t ocurrencies = DNA.size()-2; |
|
cout << "DNA: " << DNA << endl; |
|
while(auxiliar<ocurrencies){ // This gonna be works with the ocurriences, from 1 to end. |
|
r = takeStrings(DNA,auxiliar,auxiliar+m); |
|
auxiliar++; |
|
if(r.size()==m){ |
|
vectorSq.push_back(r); |
|
} |
|
} |
|
for(size_t i = 0; i< vectorSq.size(); i++){ |
|
cout << vectorSq[i] << endl; |
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
string takeStrings(const string &s,size_t i, size_t m){ |
|
string result; |
|
size_t aux=i; |
|
if(s.size()==0){ |
|
cout << "String is empty." << endl; |
|
} |
|
else{ |
|
for(;i<s.size()&&i!=m;i++){ |
|
result+=s[i]; |
|
aux++; |
|
} |
|
|
|
} |
|
return result; |
|
} |
|
|
|
void FindSequenceDNA(vector<string>&s,string sq){ |
|
if(s.size()==0){ |
|
cout << "DNA invalid." << endl; |
|
} |
|
else{ |
|
for(size_t i=0;i<s.size();i++){ |
|
if(sq==s[i]){ |
|
cout << "function: " << endl; |
|
cout << s[i] << endl; |
|
} |
|
} |
|
} |
|
|
|
} |
|
|
|
bool checkDNA(string &s){ |
|
bool res; |
|
if(s.size()==0 || s.size()<3){ |
|
cout << "DNA invalid" << endl; |
|
} |
|
else{ |
|
for(size_t i=0;i<s.size();i++){ |
|
if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') |
|
{ |
|
res = true; |
|
} |
|
else{ |
|
res= false; |
|
} |
|
} |
|
} |
|
return res; |
|
} |
|
|
|
size_t incrementValue(size_t &m){ |
|
if(m<DNA.size()){ |
|
m++; |
|
} |
|
return m; |
|
} |