//moved this into driver to avoid deep copies in windows paralellized version
Alignment* alignment;
int longestBase = templateDB->getLongestBase();
+ if (m->debug) { m->mothurOut("[DEBUG]: template longest base = " + toString(templateDB->getLongestBase()) + " \n"); }
if(align == "gotoh") { alignment = new GotohOverlap(gapOpen, gapExtend, match, misMatch, longestBase); }
else if(align == "needleman") { alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase); }
else if(align == "blast") { alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch); }
int numBasesNeeded = origNumBases * threshold;
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
- if (candidateSeq->getUnaligned().length() > alignment->getnRows()) {
- alignment->resize(candidateSeq->getUnaligned().length()+1);
+ if (candidateSeq->getUnaligned().length()+1 > alignment->getnRows()) {
+ if (m->debug) { m->mothurOut("[DEBUG]: " + candidateSeq->getName() + " " + toString(candidateSeq->getUnaligned().length()) + " " + toString(alignment->getnRows()) + " \n"); }
+ alignment->resize(candidateSeq->getUnaligned().length()+2);
}
Sequence temp = templateDB->findClosestSequence(candidateSeq);
- Sequence* templateSeq = &temp;
+ Sequence* templateSeq = new Sequence(temp.getName(), temp.getAligned());
float searchScore = templateDB->getSearchScore();
//get reverse compliment
copy = new Sequence(candidateSeq->getName(), originalUnaligned);
copy->reverseComplement();
+
+ if (m->debug) { m->mothurOut("[DEBUG]: flipping " + candidateSeq->getName() + " \n"); }
//rerun alignment
Sequence temp2 = templateDB->findClosestSequence(copy);
- Sequence* templateSeq2 = &temp2;
+ Sequence* templateSeq2 = new Sequence(temp2.getName(), temp2.getAligned());
+
+ if (m->debug) { m->mothurOut("[DEBUG]: closest template " + temp2.getName() + " \n"); }
searchScore = templateDB->getSearchScore();
nast2 = new Nast(alignment, copy, templateSeq2);
+
+ if (m->debug) { m->mothurOut("[DEBUG]: completed Nast2 " + candidateSeq->getName() + " flipped numBases = " + toString(copy->getNumBases()) + " old numbases = " + toString(candidateSeq->getNumBases()) +" \n"); }
//check if any better
if (copy->getNumBases() > candidateSeq->getNumBases()) {
candidateSeq->setAligned(copy->getAligned()); //use reverse compliments alignment since its better
- templateSeq = templateSeq2;
+ delete templateSeq;
+ templateSeq = templateSeq2;
delete nast;
nast = nast2;
needToDeleteCopy = true;
}else{
wasBetter = "\treverse complement did NOT produce a better alignment so it was not used, please check sequence.";
delete nast2;
+ delete templateSeq2;
delete copy;
}
+ if (m->debug) { m->mothurOut("[DEBUG]: done.\n"); }
}
//create accnos file with names
report.print();
delete nast;
+ delete templateSeq;
if (needToDeleteCopy) { delete copy; }
count++;
#endif
//report progress
- if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); }
+ if((count) % 100 == 0){ m->mothurOutJustToScreen(toString(count) + "\n"); }
}
//report progress
- if((count) % 100 != 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); }
+ if((count) % 100 != 0){ m->mothurOutJustToScreen(toString(count) + "\n"); }
delete alignment;
alignmentFile.close();
}
Sequence temp = templateDB->findClosestSequence(candidateSeq);
- Sequence* templateSeq = &temp;
+ Sequence* templateSeq = new Sequence(temp.getName(), temp.getAligned());
float searchScore = templateDB->getSearchScore();
//rerun alignment
Sequence temp2 = templateDB->findClosestSequence(copy);
- Sequence* templateSeq2 = &temp2;
+ Sequence* templateSeq2 = new Sequence(temp2.getName(), temp2.getAligned());
searchScore = templateDB->getSearchScore();
//check if any better
if (copy->getNumBases() > candidateSeq->getNumBases()) {
candidateSeq->setAligned(copy->getAligned()); //use reverse compliments alignment since its better
- templateSeq = templateSeq2;
+ delete templateSeq;
+ templateSeq = templateSeq2;
delete nast;
nast = nast2;
needToDeleteCopy = true;
}else{
wasBetter = "\treverse complement did NOT produce a better alignment, please check sequence.";
delete nast2;
+ delete templateSeq2;
delete copy;
}
}
delete buf3;
delete nast;
+ delete templateSeq;
if (needToDeleteCopy) { delete copy; }
}
delete candidateSeq;
processIDS.push_back(pid); //create map from line number to pid so you can append files in correct order later
process++;
}else if (pid == 0){
- num = driver(lines[process], alignFileName + toString(getpid()) + ".temp", reportFileName + toString(getpid()) + ".temp", accnosFName + toString(getpid()) + ".temp", filename);
+ num = driver(lines[process], alignFileName + toString(m->mothurGetpid(process)) + ".temp", reportFileName + toString(m->mothurGetpid(process)) + ".temp", accnosFName + m->mothurGetpid(process) + ".temp", filename);
//pass numSeqs to parent
ofstream out;
- string tempFile = alignFileName + toString(getpid()) + ".num.temp";
+ string tempFile = alignFileName + toString(m->mothurGetpid(process)) + ".num.temp";
m->openOutputFile(tempFile, out);
out << num << endl;
out.close();