Nast::Nast(Alignment* method, Sequence* cand, Sequence* temp) : alignment(method), candidateSeq(cand), templateSeq(temp) {
try {
+ m = MothurOut::getInstance();
maxInsertLength = 0;
pairwiseAlignSeqs(); // This is part A in Fig. 2 of DeSantis et al.
regapSequences(); // This is parts B-F in Fig. 2 of DeSantis et al.
}
catch(exception& e) {
- errorOut(e, "Nast", "Nast");
+ m->errorOut(e, "Nast", "Nast");
exit(1);
}
}
templateSeq->setPairwise(tempAln); // the candidate and template sequences
}
catch(exception& e) {
- errorOut(e, "Nast", "pairwiseAlignSeqs");
+ m->errorOut(e, "Nast", "pairwiseAlignSeqs");
exit(1);
}
}
rightRoom = 0; leftRoom = 0;
// Part D of Fig. 2 from DeSantis et al. // template sequence and the official template sequence
- for(leftIndex=i-1;leftIndex>0;leftIndex--){ // then we've got problems...
+ for(leftIndex=i-1;leftIndex>0;leftIndex--){ // then we've got problems...
if(!isalpha(candAln[leftIndex])){
leftRoom = 1; //count how far it is to the nearest gap on the LEFT side of the anomaly
while(leftIndex-leftRoom>=0 && !isalpha(candAln[leftIndex-leftRoom])) { leftRoom++; }
break;
}
}
-
+
int insertLength = 0; // figure out how long the anomaly is
while(!isalpha(newTemplateAlign[i + insertLength])) { insertLength++; }
if(insertLength > maxInsertLength){ maxInsertLength = insertLength; }
if((i-leftIndex) <= (rightIndex-i)){ // the left gap is closer - > move stuff left there's
if(leftRoom >= insertLength){ // enough room to the left to move
-
string leftTemplateString = newTemplateAlign.substr(0,i);
string rightTemplateString = newTemplateAlign.substr(i+insertLength);
newTemplateAlign = leftTemplateString + rightTemplateString;
}
else{ // the right gap is closer - > move stuff right there's
if(rightRoom >= insertLength){ // enough room to the right to move
-
string leftTemplateString = newTemplateAlign.substr(0,i);
string rightTemplateString = newTemplateAlign.substr(i+insertLength);
newTemplateAlign = leftTemplateString + rightTemplateString;
candAln = leftCandidateString + rightCandidateString;
}
- else{ // not enough room to the right, have to steal some
-
+ else{ // not enough room to the right, have to steal some
// space to the left lets move left and then right...
string leftTemplateString = newTemplateAlign.substr(0,i);
string rightTemplateString = newTemplateAlign.substr(i+insertLength);
}
}
+ i -= insertLength;
+
}
else{
- // there could be a case where there isn't enough room in
- string leftTemplateString = newTemplateAlign.substr(0,i); // either direction to move stuff
+ // there could be a case where there isn't enough room in either direction to move stuff
+
+ string leftTemplateString = newTemplateAlign.substr(0,i);
string rightTemplateString = newTemplateAlign.substr(i+leftRoom+rightRoom);
newTemplateAlign = leftTemplateString + rightTemplateString;
longAlignmentLength = newTemplateAlign.length();
string insertString = candAln.substr(leftIndex+1,rightIndex-leftIndex-1);
string rightCandidateString = candAln.substr(rightIndex+rightRoom);
candAln = leftCandidateString + insertString + rightCandidateString;
-
+
+ i -= (leftRoom + rightRoom);
}
- i -= insertLength;
+// i -= insertLength;
}
}
}
catch(exception& e) {
- errorOut(e, "Nast", "removeExtraGaps");
+ m->errorOut(e, "Nast", "removeExtraGaps");
exit(1);
}
}
// would skip the gaps and not progress through full alignment sequence
// not tested yet
- mothurOut("We're into D " + toString(fullAlignIndex) + " " + toString(pairwiseAlignIndex)); mothurOutEndLine();
+ m->mothurOut("We're into D " + toString(fullAlignIndex) + " " + toString(pairwiseAlignIndex)); m->mothurOutEndLine();
pairwiseAlignIndex++;
}
else{
// everything has a gap - not possible
// not tested yet
- mothurOut("We're into F " + toString(fullAlignIndex) + " " + toString(pairwiseAlignIndex)); mothurOutEndLine();
+ m->mothurOut("We're into F " + toString(fullAlignIndex) + " " + toString(pairwiseAlignIndex)); m->mothurOutEndLine();
pairwiseAlignIndex++;
fullAlignIndex++;
}
candidateSeq->setAligned(candAln);
}
catch(exception& e) {
- errorOut(e, "Nast", "regapSequences");
+ m->errorOut(e, "Nast", "regapSequences");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Nast", "getSimilarityScore");
+ m->errorOut(e, "Nast", "getSimilarityScore");
exit(1);
}
}