ColumnFiller3D Class Reference

#include <MatchAligner.h>

Collaboration diagram for ColumnFiller3D:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ColumnFiller3D (const char **p1Trans, int p1Size, int p1FinalFrame, const char **p2Trans, int p2Size, int p2FinalFrame, int bandExtension, const ScoreTable &scoreTable)
ScoreType operator() (PathMatrix< PathType3D > &matrix)
template<bool canGoW>
ScoreType getScoreW (int j, int k, int l)
template<bool canGoSW>
ScoreType getScoreSW (int j, int k, int l)
template<bool canGoN>
ScoreType getScoreN (int j, int k, int l)
template<bool canGoSW>
ScoreType getScorePrevFrame1 (int j, int k, int l)
template<bool canGoN>
ScoreType getScorePrevFrame2 (int j, int k, int l)
template<bool canMatch>
ScoreType getScoreChar (int i, int j, int k, int l)
template<bool canGoW, bool canGoSW, bool canGoN, bool canMatch>
void fillCell3D (PathMatrix< PathType3D > &matrix, int i, int j)

Private Attributes

const char * p1_ [gNumReadingFrames]
const char * p2_ [gNumReadingFrames]
vector< vector< char > > p1Translations_
vector< vector< char > > p2Translations_
int bandExtension_
int bandWidth_
int bandLength_
int colSize_
int finalFrame1_
int finalFrame2_
int numFrames1_
int numFrames2_
CellFiller3D fillCell_
ScoreMaker getScore_
vector< ScoreType3Dv1_
vector< ScoreType3Dv2_
vector< ScoreType3D > * pLast_
vector< ScoreType3D > * pCurrent_
vector< ScoreType3D > * temp_

Detailed Description

Definition at line 775 of file MatchAligner.h.


Constructor & Destructor Documentation

ColumnFiller3D::ColumnFiller3D ( const char **  p1Trans,
int  p1Size,
int  p1FinalFrame,
const char **  p2Trans,
int  p2Size,
int  p2FinalFrame,
int  bandExtension,
const ScoreTable scoreTable 
)

Definition at line 1241 of file MatchAligner.cpp.

References ColumnFillerBasic::p1_, and ColumnFillerBasic::p2_.

01244                                  :
01245   bandExtension_( (bandExtension<(p1Size/2))
01246                   ? bandExtension
01247                   : max( (p1Size/2)-1, 0 ) ), 
01248   //  bandExtension_(bandExtension), 
01249   bandWidth_(p2Size-p1Size+1),
01250   bandLength_(p1Size+1),
01251   colSize_(p2Size-p1Size+1+(2*bandExtension_)),
01252   fillCell_(),
01253   finalFrame1_(p1FinalFrame),
01254   finalFrame2_(p2FinalFrame),
01255   numFrames1_((p1Trans[1]==NULL)?1:gNumReadingFrames),
01256   numFrames2_((p2Trans[1]==NULL)?1:gNumReadingFrames),
01257   v1_(colSize_, veryBadScore3D ), 
01258   v2_(colSize_, veryBadScore3D ),
01259   pLast_(&v1_),
01260   pCurrent_(&v2_),
01261   getScore_(scoreTable)
01262 {
01263   
01264   p1_[0] = p1Trans[0];
01265   p1_[1] = p1Trans[1];
01266   p1_[2] = p1Trans[2];
01267   p2_[0] = p2Trans[0];
01268   p2_[1] = p2Trans[1];
01269   p2_[2] = p2Trans[2];
01270 
01271   //    cout << "C3D::C3D " << bandExtension_ << " " << bandWidth_ << " "
01272   //   << bandLength_ << " " << colSize_ << " " 
01273   //    << numFrames1_ << " "
01274   //   << numFrames2_ << " "
01275   //   << finalFrame1_ << " "
01276   //   << finalFrame2_ << endl;
01277 
01278 } // ~ColumnFiller3D::ColumnFiller3D


Member Function Documentation

ScoreType ColumnFiller3D::operator() ( PathMatrix< PathType3D > &  matrix  ) 

Definition at line 1286 of file MatchAligner.cpp.

References bandExtension_, bandLength_, colSize_, finalFrame1_, finalFrame2_, pCurrent_, pLast_, temp_, v1_, and v2_.

01287 {
01288 
01289   //  ScoreType lastScore, prevFrameScore1, prevFrameScore2;
01290   int i,j,k,l;
01291 
01292   matrix.resize(bandLength_, vector<PathType3D>(colSize_) );
01293 
01294   //  matrix[0].resize(colSize_);
01295   
01296   pLast_    = &v2_;
01297   pCurrent_ = &v1_;
01298 
01299   // Fill in first column
01300   //  matrix[0][bandExtension_][0][0]=fromFinished;
01301   //  (*pCurrent_)[bandExtension_][0][0]=0;
01302   //  cout << "doing first cell" << endl;
01303   fillCell3D<false, false, false, false>( matrix, 0, bandExtension_);
01304   
01305 
01306 
01307   //    cout << "doing first column" << endl;
01308   for (j = (bandExtension_+1); j< colSize_ ; j++)
01309   {
01310     fillCell3D<false, false, true, false>( matrix, 0, j);
01311   } // ~for i
01312 
01313   temp_ = pCurrent_; pCurrent_ = pLast_; pLast_ = temp_;
01314 
01315   // Fill in next bandExtension_ columns
01316 
01317   for ( i=1 ; i <= bandExtension_ ; i++  ) // NB <= not <
01318   {
01319     //    cout << "doing leftmost columns" << i << endl;
01320 
01321     fillCell3D<false, true, false, false>( matrix, i, bandExtension_-i );
01322 
01323 
01324     for ( j=bandExtension_-i+1; j < colSize_-1 ; j++)
01325     {
01326       //      cout << "doing main chunk ";
01327       fillCell3D<true, true, true, true>( matrix, i, j);
01328 
01329     } // ~for j
01330 
01331     // Next if statement is unnecessary, as this scope is only executed
01332     // if band extension >= 1, since colSize > 2 * bandExtension
01333     //    if (colSize_>1)
01334     //   {
01335     //   cout << "doing last one ";
01336       fillCell3D<true, false, true, true>( matrix, i, j); // NB wot if loop never exec'd??
01337       //  }
01338 
01339 
01340     temp_ = pCurrent_; pCurrent_ = pLast_; pLast_ = temp_;
01341   } // ~for i
01342 
01343 
01344   // Fill in main set of columns
01345   if (colSize_==1)
01346   {
01347     for ( i=(bandExtension_+1) ; 
01348           i < bandLength_ -bandExtension_; 
01349           i++ ) 
01350     {
01351         fillCell3D<true, false, false, true>( matrix, i, 0);
01352         temp_ = pCurrent_; pCurrent_ = pLast_; pLast_ = temp_;
01353     } // ~for i
01354   } // ~if
01355   else
01356   {
01357     for ( i=(bandExtension_+1) ; 
01358           i < bandLength_ -bandExtension_; 
01359           i++ ) 
01360       {
01361         //      cout << "doing centre columns" << i << endl;
01362 
01363         //      cout << "doing first one ";
01364         fillCell3D<true, true, false, true>( matrix, i, 0);
01365 
01366         for ( j=1; j < colSize_-1 ; j++)
01367         {
01368           //      cout << "doing main chunk ";
01369           fillCell3D<true, true, true, true>( matrix, i, j);
01370         } // ~for j
01371 
01372         //      cout << "doing last one ";
01373         fillCell3D< true, false, true, true>(matrix, i, j);
01374         temp_ = pCurrent_; pCurrent_ = pLast_; pLast_ = temp_;
01375       } // ~for i
01376   } // ~else
01377 
01378   // Fill in last bandExtension_ columns;
01379 
01380 
01381   for ( i=bandLength_-bandExtension_ ; i < bandLength_ ; i++ ) 
01382   {
01383     //    cout << "doing rightmost columns" << i << endl;
01384     
01385     fillCell3D<true, true, false, true>( matrix, i, 0);
01386 
01387     for ( j=1; j < colSize_-1-i-bandExtension_+bandLength_ ; j++)
01388     {
01389       //      cout << "doing main chunk ";
01390       fillCell3D< true, true, true, true>( matrix, i, j);
01391     } // ~for j
01392     //    print (*pCurrent_);
01393     temp_ = pCurrent_; pCurrent_ = pLast_; pLast_ = temp_;
01394 
01395   } // ~for i
01396 
01397   // Set position of the last cell filled in ready for
01398   // the traceback
01399   matrix.lastCell_.first
01400     = matrix.end()-1;
01401   matrix.lastCell_.second
01402     = matrix.lastCell_.first->begin()+ (colSize_-bandExtension_-1);
01403 
01404   return (*pLast_)[colSize_-bandExtension_-1][finalFrame1_][finalFrame2_];
01405 
01406 } // ~void ColumnFiller3D::operator()

ScoreType ColumnFiller3D::getScoreW< false > ( int  j,
int  k,
int  l 
) [inline]

Definition at line 794 of file MatchAligner.h.

References pLast_.

00795   {
00796     return (*pLast_)[j][k][l];
00797   } // ~template< bool canGoW> ScoreType getScoreW

ScoreType ColumnFiller3D::getScoreSW< false > ( int  j,
int  k,
int  l 
) [inline]

Definition at line 800 of file MatchAligner.h.

References pLast_.

00801   {
00802     return (*pLast_)[j+1][k][l];
00803   } // ~template< bool canGoSW> ScoreType getScoreSW

ScoreType ColumnFiller3D::getScoreN< false > ( int  j,
int  k,
int  l 
) [inline]

Definition at line 806 of file MatchAligner.h.

References pCurrent_.

00807   {
00808     return (*pCurrent_)[j-1][k][l];
00809   } // ~template< bool canGoN> ScoreType getScoreN

template<bool canGoSW>
ScoreType ColumnFiller3D::getScorePrevFrame1 ( int  j,
int  k,
int  l 
) [inline]

Definition at line 819 of file MatchAligner.h.

References numFrames1_, pCurrent_, and veryBadScoreIndeed.

00820   {
00821     return ((k!=0) 
00822             ? (*pCurrent_)[j][k-1][l] 
00823             : ( (numFrames1_==1)
00824                 ? veryBadScoreIndeed
00825                 : getScoreSW<canGoSW>( j, 2, l) ) );
00826   } // ~template< bool canGoSW > ScoreType getScorePrevFrame1

template<bool canGoN>
ScoreType ColumnFiller3D::getScorePrevFrame2 ( int  j,
int  k,
int  l 
) [inline]

Definition at line 835 of file MatchAligner.h.

References numFrames2_, pCurrent_, and veryBadScoreIndeed.

00836   {
00837     return ((l!=0) 
00838             ? (*pCurrent_)[j][k][l-1] 
00839             : ( (numFrames2_==1)
00840                 ? veryBadScoreIndeed
00841                 :getScoreN<canGoN>( j, k, 2) ) );
00842   } // ~template< bool canGoN > ScoreType getScorePrevFrame2

ScoreType ColumnFiller3D::getScoreChar< false > ( int  i,
int  j,
int  k,
int  l 
) [inline]

Definition at line 845 of file MatchAligner.h.

References bandExtension_, getScore_, p1_, and p2_.

00846   {
00847     assert(p1_[k]!=NULL);
00848     assert(p2_[l]!=NULL);
00849 
00850     //        cout << "getScoreChar "
00851     //  << p1_[k][i-1] << p2_[l][j-bandExtension_+i-1] << " "
00852     //  << i << " " 
00853     //  << j << " " 
00854     //  << k << " " 
00855     //  << l << endl;
00856     return (getScore_(p1_[k][i-1],p2_[l][j-bandExtension_+i-1]));
00857   } // ~template< bool canMatch> ScoreType getScoreChar

void ColumnFiller3D::fillCell3D< false, false, false, false > ( PathMatrix< PathType3D > &  matrix,
int  i,
int  j 
) [inline]

Definition at line 863 of file MatchAligner.h.

References fillCell_, frameShiftScoreBLOSUM, gapStartScoreBLOSUM, numFrames1_, numFrames2_, and pCurrent_.

00864   {
00865     //        cout << "filling cell " << i << " " << j << " : "
00866     //  << (canGoW?'T':'F')
00867     //  << (canGoSW?'T':'F')
00868     //  << (canGoN?'T':'F')
00869     //   << (canMatch?'T':'F')
00870     //  << endl;
00871 
00872     for ( int k(0); k < numFrames1_; k++ )
00873     {
00874       for ( int l(0); l < numFrames2_; l++ )
00875       {
00876         //              cout << k << " " << l << endl;
00877         (*pCurrent_)[j][k][l] 
00878           = fillCell_( matrix[i][j][k][l],
00879                        getScoreW<canGoW>( j, k, l)
00880                        + getScoreChar<canMatch>(i,j,k,l),
00881                        getScoreSW<canGoSW>( j, k, l)
00882                        + gapStartScoreBLOSUM,
00883                        getScoreN<canGoN>( j, k, l)
00884                        + gapStartScoreBLOSUM,
00885                        getScorePrevFrame1<canGoSW>( j, k, l)
00886                        + frameShiftScoreBLOSUM,
00887                        getScorePrevFrame2<canGoN>( j, k, l) 
00888                        + frameShiftScoreBLOSUM );
00889       } // ~for l
00890     } // ~for k
00891   } // ~fillCell3D


Member Data Documentation

const char* ColumnFiller3D::p1_[gNumReadingFrames] [private]

Definition at line 896 of file MatchAligner.h.

Referenced by getScoreChar().

const char* ColumnFiller3D::p2_[gNumReadingFrames] [private]

Definition at line 897 of file MatchAligner.h.

Referenced by getScoreChar().

vector< vector<char> > ColumnFiller3D::p1Translations_ [private]

Definition at line 898 of file MatchAligner.h.

vector< vector<char> > ColumnFiller3D::p2Translations_ [private]

Definition at line 899 of file MatchAligner.h.

int ColumnFiller3D::bandExtension_ [private]

Definition at line 901 of file MatchAligner.h.

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

int ColumnFiller3D::bandWidth_ [private]

Definition at line 902 of file MatchAligner.h.

int ColumnFiller3D::bandLength_ [private]

Definition at line 903 of file MatchAligner.h.

Referenced by operator()().

int ColumnFiller3D::colSize_ [private]

Definition at line 904 of file MatchAligner.h.

Referenced by operator()().

int ColumnFiller3D::finalFrame1_ [private]

Definition at line 905 of file MatchAligner.h.

Referenced by operator()().

int ColumnFiller3D::finalFrame2_ [private]

Definition at line 906 of file MatchAligner.h.

Referenced by operator()().

int ColumnFiller3D::numFrames1_ [private]

Definition at line 907 of file MatchAligner.h.

Referenced by fillCell3D(), and getScorePrevFrame1().

int ColumnFiller3D::numFrames2_ [private]

Definition at line 908 of file MatchAligner.h.

Referenced by fillCell3D(), and getScorePrevFrame2().

CellFiller3D ColumnFiller3D::fillCell_ [private]

Definition at line 910 of file MatchAligner.h.

Referenced by fillCell3D().

ScoreMaker ColumnFiller3D::getScore_ [private]

Definition at line 911 of file MatchAligner.h.

Referenced by getScoreChar().

vector<ScoreType3D> ColumnFiller3D::v1_ [private]

Definition at line 913 of file MatchAligner.h.

Referenced by operator()().

vector<ScoreType3D> ColumnFiller3D::v2_ [private]

Definition at line 914 of file MatchAligner.h.

Referenced by operator()().

vector<ScoreType3D>* ColumnFiller3D::pLast_ [private]

Definition at line 915 of file MatchAligner.h.

Referenced by getScoreSW(), getScoreW(), and operator()().

vector<ScoreType3D>* ColumnFiller3D::pCurrent_ [private]

Definition at line 916 of file MatchAligner.h.

Referenced by fillCell3D(), getScoreN(), getScorePrevFrame1(), getScorePrevFrame2(), and operator()().

vector<ScoreType3D>* ColumnFiller3D::temp_ [private]

Definition at line 917 of file MatchAligner.h.

Referenced by operator()().


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