X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=overlap.cpp;fp=overlap.cpp;h=9645e7a748ce72417f8c8bcbd272ac38dde1aca4;hb=526a868606faa50caf86e7399f7554c0335b39e5;hp=0000000000000000000000000000000000000000;hpb=c35f02a218ce8f430a75850b4d9fabb96b3a022b;p=mothur.git diff --git a/overlap.cpp b/overlap.cpp new file mode 100644 index 0000000..9645e7a --- /dev/null +++ b/overlap.cpp @@ -0,0 +1,83 @@ +/* + * overlap.cpp + * + * + * Created by Pat Schloss on 12/15/08. + * Copyright 2008 Patrick D. Schloss. All rights reserved. + * + * This class cleans up the alignment at the 3' end of the alignments. Because the Gotoh and Needleman-Wunsch + * algorithms start the traceback from the lower-right corner of the dynamic programming matrix, there may be a lot of + * scattered bases in the alignment near the 3' end of the alignment. Here we basically look for the largest score + * in the last column and row to determine whether there should be exta gaps in sequence A or sequence B. The gap + * issues at the 5' end of the alignment seem to take care of themselves in the traceback. + * + */ +using namespace std; + +#include "alignmentcell.hpp" +#include "overlap.hpp" + + +/**************************************************************************************************/ + +int Overlap::maxRow(vector >& alignment, const int band){ + + float max = -100; + int end = lA - 1; + int index = end; + + for(int i=band;i= max){ // score. + index = i; + max = alignment[i][end].cValue; + } + } + return index; +} + +/**************************************************************************************************/ + +int Overlap::maxColumn(vector >& alignment, const int band){ + + float max = -100; + int end = lB - 1; + int index = end; + + for(int i=band;i= max){ // alignment score. + index = i; + max = alignment[end][i].cValue; + } + } + return index; +} + +/**************************************************************************************************/ + +void Overlap::setOverlap(vector >& alignment, const int nA, const int nB, const int band=0){ + + lA = nA; + lB = nB; + + int rowIndex = maxRow(alignment, band); // get the index for the row with the highest right hand side score + int colIndex = maxColumn(alignment, band); // get the index for the column with the highest bottom row score + + int row = lB-1; + int column = lA-1; + + if(colIndex == column && rowIndex == row){} // if the max values are the lower right corner, then we're good + else if(alignment[row][colIndex].cValue < alignment[rowIndex][column].cValue){ + for(int i=rowIndex+1;i