IAligner * CAlignTest::NewAligner( EAlignmentAlgo algo, int xdropoff ) const { // if( xdropoff == 0 ) return new CAligner_HSP(); switch( algo ) { case eAlignment_fast: return new CAligner_fast(); case eAlignment_HSP: return new CAligner_HSP(); case eAlignment_SW: do { auto_ptr<CAligner_SW> swalign( new CAligner_SW() ); swalign->SetMatrix().resize( 2*xdropoff + 1 ); return swalign.release(); } while(0); break; default: THROW( logic_error, "Bad value for m_algo" ); } }
int main (int argc, char *argv[]) { char seq1[ MAXSEQ ]; // input seq1 char seq2[ MAXSEQ ]; // input seq2 char bts1[ MAXSEQ ]; // back trace seq1 char bts2[ MAXSEQ ]; // back trace seq2 char aln[ MAXSEQ ]; // the one line alignment string int swas; // smith-waterman alginment score int c; // options char infile1[ MAXFNL ]; // input file1 char infile2[ MAXFNL ]; // input file2 int simple; // output controls // options while ( ( c = getopt( argc, argv, "ha:b:i:j:s" ) ) != EOF ) switch (c) { case 'h': usage(); break; case 'a': strcpy(seq1, optarg); break; case 'b': strcpy(seq2, optarg); break; case 'i': strcpy(infile1, optarg); break; case 'j': strcpy(infile2, optarg); break; case 's': simple = 1; break; } if ( argc == 1 ) { usage(); } // check if sequences were passed by file if ( ( infile1[0] != '\0' ) && ( infile2[0] != '\0' ) ) { readseq( infile1, seq1 ); readseq( infile2, seq2 ); } // check if sequences are ready if ( ( seq1[0] == '\0' ) || ( seq2[0] == '\0' ) ) { printf("Error: insufficent input sequences found!\n"); usage(); } // covert sequences to UPPER case upper( seq1 ); upper( seq2 ); // do smith-waterman alignment swas = swalign( seq1, seq2, bts1, bts2, aln ); // output alignment if ( simple == 1 ) { printf("%d\n", swas); puts(bts1); puts(aln); puts(bts2); } else { printf("Smith-Waterman Alignment:\n\n"); printf("Score:\t%d\n\n", swas); print_align( bts1, bts2, aln ); } }