MatchAlgorithmGapped Class Reference

#include <MatchStoreGapped.h>

Inheritance diagram for MatchAlgorithmGapped:

Inheritance graph
[legend]
Collaboration diagram for MatchAlgorithmGapped:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MatchAlgorithmGapped (int maxGap, int maxInsert, int minToProcess, int numRepeats)
virtual void generateMatches (HitListVector &hitList, MatchAdder &addMatch)
void findMatchesInRange (HitListVector::iterator first, HitListVector::iterator last, MatchAdder &addMatch)

Private Attributes

int maxGap_
int maxInsert_
int minToProcess_
int maxQueryDiff_
int minHitsForMatch_

Detailed Description

Definition at line 80 of file MatchStoreGapped.h.


Constructor & Destructor Documentation

MatchAlgorithmGapped::MatchAlgorithmGapped ( int  maxGap,
int  maxInsert,
int  minToProcess,
int  numRepeats 
) [inline]

Definition at line 84 of file MatchStoreGapped.h.

00084                                                                    :
00085     maxGap_( maxGap ),
00086     maxInsert_( maxInsert ), 
00087     minToProcess_( minToProcess ),
00088     MatchAlgorithm( numRepeats )
00089     {}


Member Function Documentation

void MatchAlgorithmGapped::generateMatches ( HitListVector hitList,
MatchAdder addMatch 
) [virtual]

Implements MatchAlgorithm.

Definition at line 84 of file MatchStoreGapped.cpp.

00085 {
00086 
00087   if (hitList.size()==0) return;
00088   
00089   if (sortNeeded_)
00090   {
00091     sort( hitList.begin(), hitList.end(), LessThanSubject() );
00092   } // ~if 
00093 
00094   minHitsForMatch_ = max(2,minToProcess_ / stepLength_);
00095   maxQueryDiff_ = maxGap_ + stepLength_;
00096 
00097   bool inRun(false);
00098 
00099   HitListVector::iterator pFirstMatch( hitList.begin() );
00100   
00101   for ( int i(0) ; i < ((int)hitList.size()) - 1 ; ++i )
00102   {
00103     if (    ( hitList[i+1].subjectNum == hitList[i].subjectNum ) 
00104               && ( hitList[i+1].diff - hitList[i].diff  <=maxInsert_ )) 
00105     {
00106       if ( inRun==false ) 
00107       { 
00108         pFirstMatch = static_cast<HitList::iterator>(&hitList[i]); 
00109         inRun=true;
00110       } // ~if
00111     } // ~if
00112     else 
00113     {
00114       if (inRun==true)
00115         findMatchesInRange
00116         ( pFirstMatch, 
00117           static_cast<HitList::iterator>(&hitList[i+1]),
00118           addMatch );
00119       inRun=false;
00120     } // ~else if
00121 
00122   } // ~for
00123 
00124   if (inRun==true)
00125     findMatchesInRange( pFirstMatch, hitList.end(), addMatch );
00126 
00127   return;
00128 
00129 } // ~findMatch

void MatchAlgorithmGapped::findMatchesInRange ( HitListVector::iterator  first,
HitListVector::iterator  last,
MatchAdder addMatch 
)

Definition at line 133 of file MatchStoreGapped.cpp.

00135 {
00136 
00137   if (first == last) return;
00138   // This means that single hit matches will not be reported, but you
00139   // can get these with MatchStoreUngapped
00140 
00141   sort( first, last, LessThanQuery() );
00142 
00143   //  cout << "sortedHits:" <<endl;
00144   //  for (HitListVector::iterator j(first); j!=last ; ++j)
00145   // cout << j << " " << j->subjectNum << ": " << j->queryPos << " " 
00146   // << j->diff+j->queryPos << endl;
00147 
00148 
00149   int lastQueryPos, numBases, gapSize; 
00150   SequenceOffset subjectStart, subjectEnd;
00151 
00152   while ( last-first >= minHitsForMatch_ )
00153   {
00154     //    cout << last-first << " left to go.\n";
00155     lastQueryPos = first->queryPos;
00156     numBases = wordLength_;
00157     HitListVector::iterator i(first);
00158 
00159     while(++i!=last)
00160     {
00161 
00162       gapSize = i->queryPos - lastQueryPos;
00163       //   cout << lastQueryPos << "|" << i->queryPos << endl; 
00164       if ( gapSize > maxQueryDiff_ ) break;
00165       numBases += min (wordLength_, gapSize );
00166       lastQueryPos = i->queryPos;
00167     } // ~while
00168   
00169     if (numBases>=minToProcess_)
00170     { 
00171       i--;
00172       //      cout << "addMatch: "  <<     first->queryPos << " " <<
00173       //  i->queryPos + wordLength_ - 1 << " " <<
00174       //  first->diff + first->queryPos << " " <<
00175       //i->diff + i->queryPos + wordLength_ - 1 << endl;
00176 
00177       subjectStart = first->diff + first->queryPos;
00178       subjectEnd= i->diff + i->queryPos + wordLength_ - 1; 
00179 
00180       // Put in the test below, as repetitive queries can occasionally
00181       // cause it to be false, which causes a crash at the alignment stage
00182       // TC 29.5.2
00183       if (subjectEnd>subjectStart)
00184       {
00185         addMatch 
00186         ( 
00187          first->subjectNum,
00188          numBases,
00189          first->queryPos,
00190          i->queryPos + wordLength_ - 1,
00191          subjectStart,
00192          subjectEnd
00193          );
00194       } // ~if
00195       i++;
00196     } // ~if
00197 
00198     first = i;
00199   
00200   } // ~while
00201 
00202 } // ~findMatchesInRange


Member Data Documentation

int MatchAlgorithmGapped::maxGap_ [private]

Definition at line 100 of file MatchStoreGapped.h.

int MatchAlgorithmGapped::maxInsert_ [private]

Definition at line 101 of file MatchStoreGapped.h.

int MatchAlgorithmGapped::minToProcess_ [private]

Definition at line 102 of file MatchStoreGapped.h.

int MatchAlgorithmGapped::maxQueryDiff_ [private]

Definition at line 103 of file MatchStoreGapped.h.

int MatchAlgorithmGapped::minHitsForMatch_ [private]

Definition at line 104 of file MatchStoreGapped.h.


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