X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=needlemanoverlap.cpp;h=1239beb1a2a9f61d3f8c2cec178161fb36a7b865;hb=2c97dd48b8e27ee0a6a86c7a082f4c504c3357c6;hp=effe0d310d99958cd5e97a09b494353d902e548c;hpb=74c78f9abd9e733f0c2f812efec97a76632fcbf8;p=mothur.git diff --git a/needlemanoverlap.cpp b/needlemanoverlap.cpp index effe0d3..1239beb 100644 --- a/needlemanoverlap.cpp +++ b/needlemanoverlap.cpp @@ -24,20 +24,25 @@ /**************************************************************************************************/ -NeedlemanOverlap::NeedlemanOverlap(float gO, float m, float mm, int r) :// note that we don't have a gap extend -gap(gO), match(m), mismatch(mm), Alignment(r) { // the gap openning penalty is assessed for - // every gapped position - for(int i=1;ierrorOut(e, "NeedlemanOverlap", "NeedlemanOverlap"); + exit(1); } } - /**************************************************************************************************/ NeedlemanOverlap::~NeedlemanOverlap(){ /* do nothing */ } @@ -45,45 +50,58 @@ NeedlemanOverlap::~NeedlemanOverlap(){ /* do nothing */ } /**************************************************************************************************/ void NeedlemanOverlap::align(string A, string B){ + try { - seqA = ' ' + A; lA = seqA.length(); // algorithm requires a dummy space at the beginning of each string - seqB = ' ' + B; lB = seqB.length(); // algorithm requires a dummy space at the beginning of each string + seqA = ' ' + A; lA = seqA.length(); // algorithm requires a dummy space at the beginning of each string + seqB = ' ' + B; lB = seqB.length(); // algorithm requires a dummy space at the beginning of each string + + if (lA > nRows) { m->mothurOut("One of your candidate sequences is longer than you longest template sequence. Your longest template sequence is " + toString(nRows) + ". Your candidate is " + toString(lA) + "."); m->mothurOutEndLine(); } + + for(int i=1;i= up){ - if(diagonal >= left){ - alignment[i][j].cValue = diagonal; - alignment[i][j].prevCell = 'd'; + float up = alignment[i-1][j].cValue + gap; + float left = alignment[i][j-1].cValue + gap; + + if(diagonal >= up){ + if(diagonal >= left){ + alignment[i][j].cValue = diagonal; + alignment[i][j].prevCell = 'd'; + } + else{ + alignment[i][j].cValue = left; + alignment[i][j].prevCell = 'l'; + } } else{ - alignment[i][j].cValue = left; - alignment[i][j].prevCell = 'l'; - } - } - else{ - if(up >= left){ - alignment[i][j].cValue = up; - alignment[i][j].prevCell = 'u'; - } - else{ - alignment[i][j].cValue = left; - alignment[i][j].prevCell = 'l'; + if(up >= left){ + alignment[i][j].cValue = up; + alignment[i][j].prevCell = 'u'; + } + else{ + alignment[i][j].cValue = left; + alignment[i][j].prevCell = 'l'; + } } } } + + Overlap over; + over.setOverlap(alignment, lA, lB, 0); // Fix gaps at the beginning and end of the sequences + traceBack(); // Traceback the alignment to populate seqAaln and seqBaln + + } + catch(exception& e) { + m->errorOut(e, "NeedlemanOverlap", "align"); + exit(1); } - Overlap over; - over.setOverlap(alignment, lA, lB, 0); // Fix gaps at the beginning and end of the sequences - traceBack(); // Traceback the alignment to populate seqAaln and seqBaln + } /**************************************************************************************************/