for(int i=0; i<longAlignmentLength; i++){ // use the long alignment as the standard
int rightIndex, rightRoom, leftIndex, leftRoom;
for(int i=0; i<longAlignmentLength; i++){ // use the long alignment as the standard
int rightIndex, rightRoom, leftIndex, leftRoom;
// Part C of Fig. 2 from DeSantis et al.
if((isalpha(newTemplateAlign[i]) != isalpha(tempAln[i]))){ //if there is a discrepancy between the regapped
// Part C of Fig. 2 from DeSantis et al.
if((isalpha(newTemplateAlign[i]) != isalpha(tempAln[i]))){ //if there is a discrepancy between the regapped
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
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;
longAlignmentLength = newTemplateAlign.length();
string leftTemplateString = newTemplateAlign.substr(0,i);
string rightTemplateString = newTemplateAlign.substr((i+insertLength));
newTemplateAlign = leftTemplateString + rightTemplateString;
longAlignmentLength = newTemplateAlign.length();
string leftCandidateString = candAln.substr(0,(leftIndex-insertLength+1));
string rightCandidateString = candAln.substr((leftIndex+1));
candAln = leftCandidateString + rightCandidateString;
string leftCandidateString = candAln.substr(0,(leftIndex-insertLength+1));
string rightCandidateString = candAln.substr((leftIndex+1));
candAln = leftCandidateString + rightCandidateString;
string leftTemplateString = newTemplateAlign.substr(0,i); // the right
string rightTemplateString = newTemplateAlign.substr((i+insertLength));
newTemplateAlign = leftTemplateString + rightTemplateString;
longAlignmentLength = newTemplateAlign.length();
string leftTemplateString = newTemplateAlign.substr(0,i); // the right
string rightTemplateString = newTemplateAlign.substr((i+insertLength));
newTemplateAlign = leftTemplateString + rightTemplateString;
longAlignmentLength = newTemplateAlign.length();
string leftCandidateString = candAln.substr(0,(leftIndex-leftRoom+1));
string insertString = candAln.substr((leftIndex+1),(rightIndex-leftIndex-1));
string rightCandidateString = candAln.substr((rightIndex+(insertLength-leftRoom)));
string leftCandidateString = candAln.substr(0,(leftIndex-leftRoom+1));
string insertString = candAln.substr((leftIndex+1),(rightIndex-leftIndex-1));
string rightCandidateString = candAln.substr((rightIndex+(insertLength-leftRoom)));
if(isalpha(tempPair[pairwiseAlignIndex]) && isalpha(tempAln[fullAlignIndex])
&& isalpha(candPair[pairwiseAlignIndex])){
// the template and candidate pairwise and template aligned have characters
if(isalpha(tempPair[pairwiseAlignIndex]) && isalpha(tempAln[fullAlignIndex])
&& isalpha(candPair[pairwiseAlignIndex])){
// the template and candidate pairwise and template aligned have characters