1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#include<iostream>
#include <string>
using namespace std;
int main()
{
int numberOfCodons;
int rnaLength;
int beginIndex;
int endIndex;
int i,j,k;
string codons[64] = {"UUU","UUC","UUA","UUG","UCU","UCC","UCA","UCG","UAU","UAC","UAA","UAG","UGU","UGC","UGA","UGG",
"CUU","CUC","CUA","CUG","CCU","CCC","CCA","CCG","CAU","CAC","CAA","CAG","CGU","CGC","CGA","CGG",
"AUU","AUC","AUA","AUG","ACU","ACC","ACA","ACG","AAU","AAC","AAA","AAG","AGU","AGC","AGA","AGG",
"GUU","GUC","GUA","GUG","GCU","GCC","GCA","GCG","GAU","GAC","GAA","GAG","GGU","GGC","GGA","GGG"};
string aminoAcids[64]={"Phenylalanine","Phenylalanine","Leucine","Leucine", "Serine","Serine","Serine","Serine","Tyrosine","Tyrosine", "Stop","Stop", "Cysteine","Cysteine","Stop", "Tryptophan",
"Leucine","Leucine","Leucine","Leucine","Proline","Proline","Proline","Proline","Histidine","Histidine","Glutamine","Glutamine","Arginine","Arginine","Arginine","Arginine",
"Isoleucine","Isoleucine","Isoleucine","Methionine","Threonine","Threonine","Threonine","Threonine","Asparagine","Asparagine","Lysine","Lysine","Serineine","Serineine","Arginine","Arginine",
"Valine","Valine","Valine","Valine","Alanine","Alanine","Alanine","Alanine","Aspartate","Aspartate","Glutamate","Glutamate","Glycine","Glycine","Glycine","Glycine"};
string codon=" ";
string protein=" ";
string RNA;
cout<<" To begin translation "<<endl;
cout<<"Please enter RNA sequence: "<<endl;
cin>>RNA;
cout<<endl;
rnaLength=RNA.length();
for(int i=0; i<RNA.length(); i+=3){
cout<<RNA[i];
if(i+1 < RNA.length())
cout<<RNA[i+1];
if(i+2 < RNA.length())
cout<<RNA[i+2];
cout<<" ";
}
cout<<endl;
numberOfCodons=rnaLength/3;
beginIndex=0;
cout<<"Total Number Of codons are: "<<numberOfCodons<<endl;
for (i=0; i<numberOfCodons;i++)
{
beginIndex=beginIndex;
endIndex=beginIndex+2;
for(j=beginIndex;j<endIndex;j++)
{
codon.append(string(1,RNA[j]));
//cout<<" ";
//cout<<codon<<endl;
}
for (k=0;k<64;k++)
{///////////this if statement is not working----------------------------
if(codon==codons[k])
{
protein.append(aminoAcids[k]);
}
}
beginIndex=beginIndex+3;
}
//heres the problem right here----------------------------
cout<<protein<<endl;
system("PAUSE");
return 0;
}
|