errorOut(e, "Nast", "Nast");
exit(1);
}
-
}
/**************************************************************************************************/
void Nast::pairwiseAlignSeqs(){ // Here we call one of the pairwise alignment methods to align our unaligned candidate
// and template sequences
try {
-
+
alignment->align(candidateSeq->getUnaligned(), templateSeq->getUnaligned());
string candAln = alignment->getSeqAAln();
string tempAln = alignment->getSeqBAln();
-
+
if(candAln == ""){
candidateSeq->setPairwise("");
candidateSeq->setPairwise(candAln); // set the pairwise sequences in the Sequence objects for
templateSeq->setPairwise(tempAln); // the candidate and template sequences
-
}
catch(exception& e) {
errorOut(e, "Nast", "pairwiseAlignSeqs");
try {
int longAlignmentLength = newTemplateAlign.length();
-
+
for(int i=0; i<longAlignmentLength; i++){ // use the long alignment as the standard
int rightIndex, rightRoom, leftIndex, leftRoom;
int insertLength = 0; // figure out how long the anomaly is
while(!isalpha(newTemplateAlign[i + insertLength])) { insertLength++; }
if(insertLength > maxInsertLength){ maxInsertLength = insertLength; }
-
+
if((leftRoom + rightRoom) >= insertLength){
// Parts D & E from Fig. 2 of DeSantis et al.
}
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);
}
}
else{
- // there could be a case where there isn't enough room in
+ // there could be a case where there isn't enough room in
string leftTemplateString = newTemplateAlign.substr(0,i); // either direction to move stuff
string rightTemplateString = newTemplateAlign.substr(i+leftRoom+rightRoom);
newTemplateAlign = leftTemplateString + rightTemplateString;
string insertString = candAln.substr(leftIndex+1,rightIndex-leftIndex-1);
string rightCandidateString = candAln.substr(rightIndex+rightRoom);
candAln = leftCandidateString + insertString + rightCandidateString;
-
+
}
-
+
i -= insertLength;
}
}
candidateSeq->setAligned(candAln);
return;
}
-
+
int fullAlignIndex = 0;
int pairwiseAlignIndex = 0;
string newTemplateAlign = ""; // this is going to be messy so we want a temporary template
newTemplateAlign += tempAln[i];//
}
- int start, end;
+ int start = 0;
+ int end = candAln.length()-1;
+
for(int i=0;i<candAln.length();i++){
if(candAln[i] == 'Z' || !isalnum(candAln[i])) { candAln[i] = '.'; } // if we padded the alignemnt from
else{ start = i; break; } // blast with Z's, change them to
candAln[i] = toupper(candAln[i]); // everything is upper case
}
-
+
if(candAln.length() != tempAln.length()){ // if the regapped candidate sequence is longer than the official
removeExtraGaps(candAln, tempAln, newTemplateAlign);// template alignment then we need to do steps C-F in Fig.
} // 2 of Desantis et al.
-
-
+
candidateSeq->setAligned(candAln);
}
catch(exception& e) {