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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string seq1; //first dna sequence
string seq2; //string to compare to first sequence
int match1, match2, match3, match4, match5 = 2;
int mmatch1, mmatch2, mmatch3, mmatch4 = 3;
int mismatch1, mismatch2, mismatch3, mismatch4, mismatch5, mismatch6, mismatch7, mismatch8, mismatch9 = -2;
int i,j;
cout << "Enter an DNA sequence: "<<endl;
cin >> seq1;
cout<<"Enter a DNA seqence for comparison:"<<endl;
cin>> seq2;
char c = toupper(seq1[i]);
char b = toupper(seq2[j]);
char a;
for (i =0 ; i<seq1.length(); i++)
{
if (c=='A'&& b == 'A') //match
{
a+= match1;
}
else if (c=='A'&& b == 'T') //match
{
a+= match2;
}
else if (c=='A'&& b == 'C') //mismatch
{
a+= mismatch1;
}
else if (c=='A'&& b == 'G')//mismatch
{
a +=mismatch2;
}
else if (b=='A'&& c == 'A') //match
{
a+= match3;
}
else if (c=='T'&& b == 'A') //match
{
a+= match4;
}
else if (c=='T'&& b == 'T') //match
{
a+= match5;
}
else if (c=='T'&& b == 'G') //mismatch
{
a +=mismatch3;
}
else if (c=='G'&& b == 'G') //match
{
a+= mmatch1;
}
else if (c=='G'&& b == 'C')
{
a+= mmatch2;
}
else if (c=='G'&& b == 'A')
{
a +=mismatch4;
}
else if (c=='G'&& b == 'T')
{
a +=mismatch5;
}
else if (b=='G'&& c == 'C')
{
a+= mmatch3;
}
else if (b=='C'&& c == 'C')
{
a+= mmatch4;
}
else if (b=='A'&& c == 'C')
{
a +=mismatch6;
}
else if (b=='T'&& c == 'C')
{
a +=mismatch7;
}
else if (c =='T' && b == 'C')
{
a +=mismatch8;
}
else
{
a +=mismatch9;
}
}
int ATscore = match1+match2+match3+match4+match5; //score for matching A/T values
int CGscore= mmatch1+mmatch2+mmatch3+mmatch4; //score for matching C/G Values
int misscore = mismatch1+mismatch2+mismatch3+mismatch4+mismatch5+mismatch6+mismatch7+mismatch8+mismatch9; //score for mismatches and gaps
int totalscore = ATscore+CGscore+misscore; //total score
cout<<"The A/T score is " << ATscore<<endl;
cout<< "The C/G score is " <<CGscore<< endl;
cout<<"The mistmatch/gap score is"<<misscore<<endl;
cout<<"The total score is "<< totalscore<< endl;
return 0;
}
|