#ifndef __SWAT_PARAM_H__ #define __SWAT_PARAM_H__ #include #include #include float blosum62[4][4] = { /* a c g t */ /* a */{ 4.0, 0.0, 0.0, 0.0 }, /* c */{ 0.0, 9.0, -3.0, -1.0}, /* g */{ 0.0, -3.0, 6.0, -2.0}, /* t */{ 0.0, -1.0, -2.0, 5.0}}; void PrintResult(char *, char *, int, int, float, float); int char2index1(char); void PrintResult(char *outstr1, char *outstr2, int noutLen, int nCharsPerLine, float fopen_pa, float fext_pa) { int i, j, npos; int nstart1, nstart2; int nstartmiss; char *interstring; int ninterpos; int nflag; interstring = new char[noutLen]; if (interstring == NULL) { printf("Allocate interstring error!\n"); return; } ninterpos = 0; nflag = 0; nstartmiss = 0; nstart1 = 0; nstart2 = 0; for (i = 0; i < noutLen; i++) { if (nflag == 0) { if (outstr1[noutLen - 1 - i] != outstr2[noutLen - 1 - i]) { if (outstr1[noutLen - 1 - i] != '-') nstart1++; if (outstr2[noutLen - 1 - i] != '-') nstart2++; nstartmiss++; continue; } else { nflag = 1; } } if (outstr1[noutLen - 1 - i] == '-' || outstr2[noutLen - 1 - i] == '-') { interstring[ninterpos++] = ' '; } else if (outstr1[noutLen - 1 - i] != outstr2[noutLen - 1 - i]) { interstring[ninterpos++] = '.'; } else { interstring[ninterpos++] = '|'; } } int nOutLine = (noutLen - nstartmiss)/nCharsPerLine; for (i = 0; i < nOutLine; i++) { for (j = 0; j < nCharsPerLine; j++) { npos = i * nCharsPerLine + nstartmiss + j; printf("%c", outstr1[noutLen - 1 - npos]); } printf("\n"); for (j = 0; j < nCharsPerLine; j++) { npos = i * nCharsPerLine + j; printf("%c", interstring[npos]); } printf("\n"); for (j = 0; j < nCharsPerLine; j++) { npos = i * nCharsPerLine + nstartmiss + j; printf("%c", outstr2[noutLen - 1 - npos]); } printf("\n\n"); } int nRemainingCh = noutLen - nstartmiss - nOutLine * nCharsPerLine; if (nRemainingCh > 0) { for (j = 0; j < nRemainingCh; j++) { printf("%c", outstr1[nRemainingCh - 1 - j]); } printf("\n"); for (j = 0; j < nRemainingCh; j++) { npos = nOutLine * nCharsPerLine + j; printf("%c", interstring[npos]); } printf("\n"); for (j = 0; j < nRemainingCh; j++) { printf("%c", outstr2[nRemainingCh - 1 - j]); } printf("\n\n"); } printf("output string length: %d\n", noutLen - nstartmiss); printf("open gap penalty is: %.1f\n", fopen_pa); printf("extension gap penalty is: %.1f\n", fext_pa); return; } int char2index1(char inch) { int result; if ((inch == 'a') || (inch == 'A')) { result = 0; } else if ((inch == 'c') || (inch == 'C')) { result = 1; } else if ((inch == 'g') || (inch == 'G')) { result = 2; } else if ((inch == 't') || (inch == 'T')) { result = 3; } else { return -1; } return result; } #endif