X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=splitmatrix.cpp;h=2e8b9055eb117f02596864cd35289d92ea3a4a87;hb=70491a12902e89b85cfa6b44a7b7fbe066ee2ac1;hp=aea99ef2cccc3dbc070b251d4691209efacd2cbc;hpb=9b53f130ac9af5e95444ce2e817fce25ed19ff03;p=mothur.git diff --git a/splitmatrix.cpp b/splitmatrix.cpp index aea99ef..2e8b905 100644 --- a/splitmatrix.cpp +++ b/splitmatrix.cpp @@ -191,8 +191,12 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG else { options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(distCutoff); } if (outputDir != "") { options += ", outputdir=" + outputDir; } + m->mothurOut("/******************************************/"); m->mothurOutEndLine(); + Command* command = new DistanceCommand(options); + m->mothurOut("/******************************************/"); m->mothurOutEndLine(); + command->execute(); delete command; @@ -328,7 +332,7 @@ int SplitMatrix::splitDistanceLarge(){ int numGroups = 0; - ofstream outFile; + //ofstream outFile; ifstream dFile; m->openInputFile(distFile, dFile); @@ -404,6 +408,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(); @@ -430,7 +435,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); @@ -465,17 +470,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; @@ -490,7 +500,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); @@ -525,17 +535,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; @@ -555,6 +569,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();