void CSamMdFormatter::FormatDeletion( const char * t, int count ) { FormatTerminal(); m_data += "^"; while( count-- ) { char ref = CIupacnaBase( CNcbi8naBase( t++ ) ); switch( ref ) { case 'A': case 'C': case 'G': case 'T': m_data += ref; break; default: m_data += 'N'; } } }
void CSamMdFormatter::FormatAligned( const char * s, const char * t, int count ) { while( count-- ) { char query = *s++; char subj = CIupacnaBase( CNcbi8naBase( t++ ) ); if( query == subj ) { ++m_keepCount; } else { FormatTerminal(); switch( subj ) { case 'A': case 'C': case 'G': case 'T': m_data += subj; break; default: m_data += 'N'; } } } }
static CIupacnaBase Any() { return CIupacnaBase('N'); }
int CAlignTest::Execute() { CScoreTbl scoreTbl( m_identityScore, m_mismatchScore, m_gapOpeningScore, m_gapExtentionScore ); auto_ptr<IAligner> aligner( CreateAligner( m_algo, &scoreTbl ) ); CAlignerBase::SetPrintDebug( true ); if( m_flags & fAlign_colorspace ) THROW( logic_error, "Colorspace option is not immplemented" ); if( GetArgIndex() + 2 > GetArgCount() ) THROW( runtime_error, "Two sequences are required!" ); if( m_offsetQuery < 0 || m_offsetSubject < 0 ) THROW( runtime_error, "Offset should never be negative" ); const char * qs = GetArg( GetArgIndex() ); const char * ss = GetArg( GetArgIndex() + 1 ); int ql = strlen( qs ); int sl = strlen( ss ); cerr << DISPLAY( qs ) << DISPLAY( ql ) << endl; cerr << DISPLAY( ss ) << DISPLAY( sl ) << endl; if( ql == 0 || sl == 0 ) THROW( runtime_error, "Sequences should have at least one base!" ); vector<char> query; vector<char> subject; query.reserve( ql ); subject.reserve( sl ); while( *qs ) query.push_back( CNcbi8naBase( CIupacnaBase( *qs++ ) ) ); while( *ss ) subject.push_back( CNcbi8naBase( CIupacnaBase( *ss++ ) ) ); qs = &query[0]; ss = &subject[0]; qs += m_offsetQuery; ql -= m_offsetQuery; ss += m_offsetSubject; sl -= m_offsetSubject; if( ql <= 0 || sl <= 0 ) THROW( runtime_error, "Offset is too big" ); if( GetFlags( fQuery_reverse ) ) { qs = qs + ql; ql = -ql; } if( GetFlags( fSubject_reverse ) ) { ss = ss + sl; sl = -sl; } int aflags = CAlignerBase::fComputePicture | CAlignerBase::fComputeScore | CAlignerBase::fPictureSubjectStrand; aligner->SetBestPossibleQueryScore( min( ql, sl ) * m_identityScore ); aligner->Align( CSeqCoding::eCoding_ncbi8na, qs, ql, CSeqCoding::eCoding_ncbi8na, ss, sl, aflags ); const CAlignerBase& abase = aligner->GetAlignerBase(); cout << ( GetFlags( fQuery_reverse ) ? 3 : 5 ) << "'=" << abase.GetQueryString() << "=" << ( GetFlags( fQuery_reverse ) ? 5 : 3 ) << "'\n"; cout << " " << abase.GetAlignmentString() << " " << " i=" << abase.GetIdentityCount() << ", m=" << abase.GetMismatchCount() << ", g=" << abase.GetIndelCount() << ", s=" << abase.GetRawScore() << "/" << abase.GetBestQueryScore() << "=" << abase.GetScore() << "%\n"; cout << "5'=" << abase.GetSubjectString() << "=3'\n"; return 0; }