MatchAligner Class Reference

#include <MatchAligner.h>

Inheritance diagram for MatchAligner:

Inheritance graph
[legend]
Collaboration diagram for MatchAligner:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MatchAligner (int numCols, int bandExtension, ScoreTable *pTable, ostream &outputStream)
virtual ~MatchAligner ()
void operator() (const char *pQuery, int queryStart, int queryEnd, const char *pSubject, int subjectStart, int subjectEnd)
virtual void createAlignment (Alignment &alignment, const char *pQuery, int queryStart, int queryEnd, const char *pSubject, int subjectStart, int subjectEnd)
virtual void formatAlignment (Alignment &alignment, const char *pQuery, int queryStart, int queryEnd, const char *pSubject, int subjectStart, int subjectEnd)
bool matchChar (const char a, const char b)
void outputAlignmentColumn (const char queryChar, const char AlignChar, const char subjectChar, int queryNext, int subjectNext)
void outputAlignmentLine (void)

Protected Attributes

ostream & outputStream_
char * pBufSeq1_
char * pBufAlign_
char * pBufSeq2_
char * pCursorSeq1_
char * pCursorAlign_
char * pCursorSeq2_
int numCols_
int bandExtension_
ScoreTablepTable_

Static Protected Attributes

static StaticScoreTable tableDNA_
static StaticScoreTable tableBlosum62_

Detailed Description

Definition at line 203 of file MatchAligner.h.


Constructor & Destructor Documentation

MatchAligner::MatchAligner ( int  numCols,
int  bandExtension,
ScoreTable pTable,
ostream &  outputStream 
)

Definition at line 193 of file MatchAligner.cpp.

00196                           :
00197   numCols_(numCols),
00198   bandExtension_(bandExtension),
00199   pTable_(pTable),
00200   outputStream_(outputStream)
00201 {
00202   pBufSeq1_= new char [numCols+1];
00203   pBufSeq2_= new char [numCols+1];
00204   pBufAlign_= new char [numCols+1];
00205   pBufSeq1_[numCols]='\0';
00206   pBufSeq2_[numCols]='\0';
00207   pBufAlign_[numCols]='\0';
00208 } // ~MatchAligner::MatchAligner

MatchAligner::~MatchAligner (  )  [virtual]

Definition at line 211 of file MatchAligner.cpp.

References pBufAlign_, pBufSeq1_, and pBufSeq2_.

00212 {
00213   delete [] pBufSeq1_;
00214   delete [] pBufSeq2_;
00215   delete [] pBufAlign_;
00216 } // ~MatchAligner::~MatchAligner


Member Function Documentation

void MatchAligner::operator() ( const char *  pQuery,
int  queryStart,
int  queryEnd,
const char *  pSubject,
int  subjectStart,
int  subjectEnd 
)

Definition at line 221 of file MatchAligner.cpp.

References createAlignment(), and formatAlignment().

00223 {
00224 
00225   Alignment alignment;
00226   createAlignment
00227     ( alignment, 
00228       pQuery, queryStart, queryEnd, 
00229       pSubject, subjectStart, subjectEnd );
00230 
00231   formatAlignment
00232     ( alignment, 
00233       pQuery, queryStart, queryEnd, 
00234       pSubject, subjectStart, subjectEnd );
00235 
00236 } // ~void MatchTaskAlign::align

Here is the call graph for this function:

void MatchAligner::createAlignment ( Alignment alignment,
const char *  pQuery,
int  queryStart,
int  queryEnd,
const char *  pSubject,
int  subjectStart,
int  subjectEnd 
) [virtual]

Reimplemented in MatchAlignerTranslated.

Definition at line 240 of file MatchAligner.cpp.

References alignBreakGapQuery, alignBreakGapSubject, bandExtension_, PathMatrix< PATH_TYPE >::fillIn(), pTable_, Alignment::totalScore_, and PathMatrix< PATH_TYPE >::traceBack().

Referenced by main(), and operator()().

00244 {
00245 
00246   const char* p1;
00247   const char* p2;
00248 
00249   int querySize(queryEnd-queryStart+1);
00250   int subjectSize(subjectEnd-subjectStart+1);
00251 
00252   //  int bandWidth;
00253   // int bandLength;
00254   int p1Size, p2Size;
00255 
00256   //  AlignBreakType gapInLargest, gapInSmallest;
00257   AlignBreakType p1Gap, p2Gap;
00258 
00259   // ensure *p1 <= *p2
00260   if (querySize<=subjectSize)
00261   {
00262     p1=pQuery; p2=pSubject;
00263     p1Size=querySize; p2Size = subjectSize;
00264     //    bandWidth  = subjectSize-querySize+1;
00265     //   bandLength = querySize;
00266     p1Gap=alignBreakGapQuery;
00267     p2Gap=alignBreakGapSubject;
00268   } // ~if
00269   else
00270   {
00271     p1=pSubject; p2=pQuery;
00272     p1Size= subjectSize; p2Size = querySize;
00273     //    bandWidth  = querySize-subjectSize+1;
00274     //   bandLength = subjectSize;
00275     p1Gap=alignBreakGapSubject;
00276     p2Gap=alignBreakGapQuery;
00277   } // ~else
00278 
00279   PathMatrix<PathType> path;
00280   ColumnFillerBasic doMatrix( p1, p1Size, p2, p2Size, bandExtension_, 
00281                               *pTable_ ); 
00282   // 0 = band ext
00283   alignment.totalScore_ = path.fillIn(doMatrix);
00284   // print(path);
00285   TraceBackerBasic doCell(p1Gap, p2Gap, alignment);
00286   path.traceBack(doCell); // 0 = band ext
00287   //  path.traceBack(doCell, bandExtension_, 
00288   //     p2Size-p1Size+bandExtension_); // 0 = band ext
00289 
00290 
00291 } // ~void MatchAligner::createAlignment

Here is the call graph for this function:

Here is the caller graph for this function:

void MatchAligner::formatAlignment ( Alignment alignment,
const char *  pQuery,
int  queryStart,
int  queryEnd,
const char *  pSubject,
int  subjectStart,
int  subjectEnd 
) [virtual]

Reimplemented in MatchAlignerTranslatedProtein, and MatchAlignerTranslatedDNA.

Definition at line 295 of file MatchAligner.cpp.

References alignBreakGapQuery, alignBreakGapSubject, alignBreakMismatch, numCols_, outputAlignmentColumn(), outputAlignmentLine(), outputStream_, pBufSeq1_, pCursorAlign_, pCursorSeq1_, pCursorSeq2_, and Alignment::totalScore_.

Referenced by operator()().

00299 {
00300 
00301   outputStream_ << "Alignment score: " << alignment.totalScore_ << endl;
00302 
00303   int queryNext(queryStart);
00304   int subjectNext(subjectStart);
00305 
00306   pCursorSeq1_ = &pBufSeq1_[numCols_]; // triggers reset to start of line
00307 
00308   *pBufSeq1_='\0'; // ensures 3 null strings are printed at first line break 
00309   //  *pBufSeq2_='\0'; // - this line not necessary??
00310   //  *pBufAlign_='\0'; // - this line not necessary??
00311 
00312   Alignment::iterator i(alignment.begin());
00313 
00314   while( i!=alignment.end() ) 
00315   {
00316     //    cout << queryNext << " " << subjectNext << endl;
00317     
00318     if (i->numMatches>0)
00319     { // TBD do these en masse?
00320       //      outputAlignmentColumn
00321       //        (*(pQuery++), '|', *(pSubject++), queryNext++, subjectNext++ ); 
00322       outputAlignmentColumn
00323       ( *pQuery, 
00324         ((tolower(*pQuery)==tolower(*pSubject))?'|':'x'), 
00325         *pSubject, 
00326         queryNext++, 
00327         subjectNext++ ); 
00328       pQuery++;
00329       pSubject++;
00330 
00331       //   queryNext++;
00332       //  subjectNext++;
00333     i->numMatches--;
00334     }
00335     else
00336     {
00337       if (i->breakType==alignBreakMismatch)
00338       {
00339         outputAlignmentColumn
00340           (*(pQuery++), 'x', *(pSubject++), queryNext++, subjectNext++ ); 
00341         //      queryNext++;
00342         //      subjectNext++;
00343       } // ~if
00344       else if (i->breakType==alignBreakGapQuery)
00345       {
00346         outputAlignmentColumn
00347           ( '-', ' ', *(pSubject++), queryNext, subjectNext++ ); 
00348         //      subjectNext++;
00349       } // ~else if
00350       else if (i->breakType==alignBreakGapSubject)
00351       {
00352         outputAlignmentColumn
00353           (*(pQuery++), ' ', '-', queryNext++, subjectNext ); 
00354         //      queryNext++;
00355       } // ~else if
00356       i++;
00357     } // ~else
00358 
00359   } // ~while
00360 
00361   *pCursorSeq1_='\0';
00362   *pCursorSeq2_='\0';
00363   *pCursorAlign_='\0';
00364 
00365   outputAlignmentLine();
00366 
00367 } // ~void MatchAligner::formatAlignment

Here is the call graph for this function:

Here is the caller graph for this function:

bool MatchAligner::matchChar ( const char  a,
const char  b 
) [inline]

Definition at line 224 of file MatchAligner.h.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), and MatchAlignerTranslatedProtein::formatAlignment().

00225   {
00226     return (tolower(a)==tolower(b));
00227   }

Here is the caller graph for this function:

void MatchAligner::outputAlignmentColumn ( const char  queryChar,
const char  AlignChar,
const char  subjectChar,
int  queryNext,
int  subjectNext 
)

Definition at line 370 of file MatchAligner.cpp.

References numCols_, outputAlignmentLine(), pBufAlign_, pBufSeq1_, pBufSeq2_, pCursorAlign_, pCursorSeq1_, and pCursorSeq2_.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), MatchAlignerTranslatedProtein::formatAlignment(), and formatAlignment().

00372 {
00373     if (pCursorSeq1_==&pBufSeq1_[numCols_])
00374     {
00375       if (*pBufSeq1_!='\0')
00376         outputAlignmentLine();
00377       sprintf( pBufSeq1_, "Q:%9.9d ", queryNext );
00378       sprintf( pBufAlign_, "            " ); // should be 12 spaces
00379       sprintf( pBufSeq2_, "S:%9.9d ", subjectNext );
00380       pCursorSeq1_ = &pBufSeq1_[12];
00381       pCursorSeq2_ = &pBufSeq2_[12];
00382       pCursorAlign_ = &pBufAlign_[12];
00383 
00384     } // ~if
00385   *(pCursorSeq1_++)  = queryChar;
00386   *(pCursorAlign_++) = alignChar;
00387   *(pCursorSeq2_++)  = subjectChar;
00388 } // ~void MatchAligner::outputAlignmentColumn

Here is the call graph for this function:

Here is the caller graph for this function:

void MatchAligner::outputAlignmentLine ( void   ) 

Definition at line 393 of file MatchAligner.cpp.

References outputStream_, pBufAlign_, pBufSeq1_, and pBufSeq2_.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), MatchAlignerTranslatedProtein::formatAlignment(), formatAlignment(), and outputAlignmentColumn().

00394 {
00395   outputStream_ << pBufSeq1_ << endl << pBufAlign_ << endl 
00396                 << pBufSeq2_ << endl << endl;
00397 } // ~void MatchTaskAlign::outputAlignmentLine( void )

Here is the caller graph for this function:


Member Data Documentation

ostream& MatchAligner::outputStream_ [protected]

Definition at line 237 of file MatchAligner.h.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), MatchAlignerTranslatedProtein::formatAlignment(), formatAlignment(), and outputAlignmentLine().

char* MatchAligner::pBufSeq1_ [protected]

Definition at line 241 of file MatchAligner.h.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), MatchAlignerTranslatedProtein::formatAlignment(), formatAlignment(), outputAlignmentColumn(), outputAlignmentLine(), and ~MatchAligner().

char* MatchAligner::pBufAlign_ [protected]

Definition at line 242 of file MatchAligner.h.

Referenced by outputAlignmentColumn(), outputAlignmentLine(), and ~MatchAligner().

char* MatchAligner::pBufSeq2_ [protected]

Definition at line 243 of file MatchAligner.h.

Referenced by outputAlignmentColumn(), outputAlignmentLine(), and ~MatchAligner().

char* MatchAligner::pCursorSeq1_ [protected]

Definition at line 246 of file MatchAligner.h.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), MatchAlignerTranslatedProtein::formatAlignment(), formatAlignment(), and outputAlignmentColumn().

char* MatchAligner::pCursorAlign_ [protected]

Definition at line 247 of file MatchAligner.h.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), MatchAlignerTranslatedProtein::formatAlignment(), formatAlignment(), and outputAlignmentColumn().

char* MatchAligner::pCursorSeq2_ [protected]

Definition at line 248 of file MatchAligner.h.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), MatchAlignerTranslatedProtein::formatAlignment(), formatAlignment(), and outputAlignmentColumn().

int MatchAligner::numCols_ [protected]

Definition at line 251 of file MatchAligner.h.

Referenced by MatchAlignerTranslatedDNA::formatAlignment(), MatchAlignerTranslatedProtein::formatAlignment(), formatAlignment(), and outputAlignmentColumn().

int MatchAligner::bandExtension_ [protected]

Definition at line 252 of file MatchAligner.h.

Referenced by MatchAlignerTranslated::createAlignment(), and createAlignment().

StaticScoreTable MatchAligner::tableDNA_ [static, protected]

Definition at line 254 of file MatchAligner.h.

StaticScoreTable MatchAligner::tableBlosum62_ [static, protected]

Definition at line 255 of file MatchAligner.h.

ScoreTable* MatchAligner::pTable_ [protected]

Definition at line 257 of file MatchAligner.h.

Referenced by MatchAlignerTranslated::createAlignment(), and createAlignment().


The documentation for this class was generated from the following files:
Generated on Fri Dec 21 13:18:19 2007 for ssaha by  doxygen 1.5.2