X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=splitmatrix.cpp;h=f6b5c4d81cf5446adc5e5253808380be7ebbf28d;hp=a5ae3cbda79fd52a9358464eab1941c96a69bd63;hb=d1c97b8c04bb75faca1e76ffad60b37a4d789d3d;hpb=deba0af0ccdcb6005ed5b2b82649b137c63fbdf7 diff --git a/splitmatrix.cpp b/splitmatrix.cpp index a5ae3cb..f6b5c4d 100644 --- a/splitmatrix.cpp +++ b/splitmatrix.cpp @@ -182,7 +182,7 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG } copyGroups.clear(); - + //process each distance file for (int i = 0; i < numGroups; i++) { @@ -207,6 +207,9 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG else { m->mothurRemove((countfile + "." + toString(i) + ".temp")); } } + //restore old fasta file name since dist.seqs overwrites it with the temp files + m->setFastaFile(fastafile); + vector tempDistFiles; for(int i=0;ihasPath(fastafile); } @@ -332,7 +335,7 @@ int SplitMatrix::splitDistanceLarge(){ int numGroups = 0; - ofstream outFile; + //ofstream outFile; ifstream dFile; m->openInputFile(distFile, dFile); @@ -408,6 +411,7 @@ int SplitMatrix::splitDistanceLarge(){ //have we reached the max buffer size if (numOutputs[groupID] > 60) { //write out sequence + ofstream outFile; outFile.open(fileName.c_str(), ios::app); outFile << outputs[groupID] << seqA << '\t' << seqB << '\t' << dist << endl; outFile.close(); @@ -434,7 +438,7 @@ int SplitMatrix::splitDistanceLarge(){ //if groupB is written to file it is above buffer size so read and write to new merged file if (wroteOutPut[groupIDB]) { string fileName2 = distFile + "." + toString(groupIDB) + ".temp"; - ifstream fileB(fileName2.c_str(), ios::ate); + /*ifstream fileB(fileName2.c_str(), ios::ate); outFile.open(fileName.c_str(), ios::app); @@ -469,17 +473,22 @@ int SplitMatrix::splitDistanceLarge(){ outFile << temp.substr(0, lastRead); delete memblock; - fileB.close(); + fileB.close();*/ + m->appendFiles(fileName2, fileName); m->mothurRemove(fileName2); + //write out the merged memory if (numOutputs[groupID] > 60) { - outFile << outputs[groupID]; + ofstream tempOut; + m->openOutputFile(fileName, tempOut); + tempOut << outputs[groupID]; outputs[groupID] = ""; numOutputs[groupID] = 0; + tempOut.close(); } - outFile.close(); + //outFile.close(); wroteOutPut[groupID] = true; wroteOutPut[groupIDB] = false; @@ -494,7 +503,7 @@ int SplitMatrix::splitDistanceLarge(){ if (wroteOutPut[groupIDA]) { string fileName2 = distFile + "." + toString(groupIDA) + ".temp"; - ifstream fileB(fileName2.c_str(), ios::ate); + /*ifstream fileB(fileName2.c_str(), ios::ate); outFile.open(fileName.c_str(), ios::app); @@ -529,17 +538,21 @@ int SplitMatrix::splitDistanceLarge(){ delete memblock; - fileB.close(); + fileB.close();*/ + m->appendFiles(fileName2, fileName); m->mothurRemove(fileName2); //write out the merged memory if (numOutputs[groupID] > 60) { - outFile << outputs[groupID]; + ofstream tempOut; + m->openOutputFile(fileName, tempOut); + tempOut << outputs[groupID]; outputs[groupID] = ""; numOutputs[groupID] = 0; + tempOut.close(); } - outFile.close(); + //outFile.close(); wroteOutPut[groupID] = true; wroteOutPut[groupIDA] = false; @@ -559,6 +572,7 @@ int SplitMatrix::splitDistanceLarge(){ //remove old names files just in case if (numOutputs[i] > 0) { + ofstream outFile; outFile.open(fileName.c_str(), ios::app); outFile << outputs[i]; outFile.close();