X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=splitmatrix.cpp;h=59e49a79e9e702cfcf70c47ffee3a42da8a0b537;hb=ee8403d4eb5760187d62b42a9cf4272de8fc0ec4;hp=13b4bd46b6cb487f91344a678fa94bbc8552fbea;hpb=d4cd876bd09bfa1bcb137261700eae79f9e41fc0;p=mothur.git diff --git a/splitmatrix.cpp b/splitmatrix.cpp index 13b4bd4..59e49a7 100644 --- a/splitmatrix.cpp +++ b/splitmatrix.cpp @@ -10,6 +10,7 @@ #include "splitmatrix.h" #include "phylotree.h" #include "distancecommand.h" +#include "seqsummarycommand.h" /***********************************************************************/ @@ -24,7 +25,7 @@ SplitMatrix::SplitMatrix(string distfile, string name, string tax, float c, stri } /***********************************************************************/ -SplitMatrix::SplitMatrix(string ffile, string name, string tax, float c, float cu, string t, int p, string output){ +SplitMatrix::SplitMatrix(string ffile, string name, string tax, float c, float cu, string t, int p, bool cl, string output){ m = MothurOut::getInstance(); fastafile = ffile; namefile = name; @@ -33,6 +34,7 @@ SplitMatrix::SplitMatrix(string ffile, string name, string tax, float c, float c distCutoff = cu; //for fasta method if you are creating distance matrix you need a cutoff for that method = t; processors = p; + classic = cl; outputDir = output; } @@ -65,6 +67,8 @@ int SplitMatrix::splitDistance(){ if (large) { splitDistanceLarge(); } else { splitDistanceRAM(); } + + return 0; } catch(exception& e) { @@ -143,7 +147,7 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG set names; for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case - remove((fastafile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((fastafile + "." + toString(i) + ".temp")); } ifstream in; @@ -182,18 +186,22 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG //process each distance file for (int i = 0; i < numGroups; i++) { - string options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(distCutoff); + string options = ""; + if (classic) { options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", output=lt"; } + else { options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(distCutoff); } + if (outputDir != "") { options += ", outputdir=" + outputDir; } Command* command = new DistanceCommand(options); + command->execute(); delete command; - remove((fastafile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((fastafile + "." + toString(i) + ".temp")); //remove old names files just in case - remove((namefile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((namefile + "." + toString(i) + ".temp")); } - + singleton = namefile + ".extra.temp"; ofstream remainingNames; m->openOutputFile(singleton, remainingNames); @@ -224,7 +232,9 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG for(int i=0;ihasPath(fastafile); } - string tempDistFile = outputDir + m->getRootName(m->getSimpleName((fastafile + "." + toString(i) + ".temp"))) + "dist"; + string tempDistFile = ""; + if (classic) { tempDistFile = outputDir + m->getRootName(m->getSimpleName((fastafile + "." + toString(i) + ".temp"))) + "phylip.dist";} + else { tempDistFile = outputDir + m->getRootName(m->getSimpleName((fastafile + "." + toString(i) + ".temp"))) + "dist"; } //if there are valid distances ifstream fileHandle; @@ -245,7 +255,7 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG remainingNames << name << '\t' << nameList << endl; } in.close(); - remove(tempNameFile.c_str()); + m->mothurRemove(tempNameFile); } } fileHandle.close(); @@ -253,11 +263,11 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG remainingNames.close(); if (!wroteExtra) { - remove(singleton.c_str()); + m->mothurRemove(singleton); singleton = "none"; } - if (m->control_pressed) { for (int i = 0; i < dists.size(); i++) { remove((dists[i].begin()->first).c_str()); remove((dists[i].begin()->second).c_str()); } dists.clear(); } + if (m->control_pressed) { for (int i = 0; i < dists.size(); i++) { m->mothurRemove((dists[i].begin()->first)); m->mothurRemove((dists[i].begin()->second)); } dists.clear(); } return 0; } @@ -277,7 +287,7 @@ int SplitMatrix::splitDistanceFileByTax(map& seqGroup, int numGroup ofstream outFile; for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case - remove((distFile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((distFile + "." + toString(i) + ".temp")); } //for buffering the io to improve speed @@ -294,7 +304,7 @@ int SplitMatrix::splitDistanceFileByTax(map& seqGroup, int numGroup string seqA, seqB; float dist; - if (m->control_pressed) { dFile.close(); for (int i = 0; i < numGroups; i++) { remove((distFile + "." + toString(i) + ".temp").c_str()); } } + if (m->control_pressed) { dFile.close(); for (int i = 0; i < numGroups; i++) { m->mothurRemove((distFile + "." + toString(i) + ".temp")); } } dFile >> seqA >> seqB >> dist; m->gobble(dFile); @@ -321,7 +331,7 @@ int SplitMatrix::splitDistanceFileByTax(map& seqGroup, int numGroup dFile.close(); for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case - remove((namefile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((namefile + "." + toString(i) + ".temp")); //write out any remaining buffers if (numOutputs[i] > 0) { @@ -380,21 +390,21 @@ int SplitMatrix::splitDistanceFileByTax(map& seqGroup, int numGroup remainingNames << name << '\t' << nameList << endl; } in.close(); - remove(tempNameFile.c_str()); + m->mothurRemove(tempNameFile); } } remainingNames.close(); if (!wroteExtra) { - remove(singleton.c_str()); + m->mothurRemove(singleton); singleton = "none"; } if (m->control_pressed) { for (int i = 0; i < dists.size(); i++) { - remove((dists[i].begin()->first).c_str()); - remove((dists[i].begin()->second).c_str()); + m->mothurRemove((dists[i].begin()->first)); + m->mothurRemove((dists[i].begin()->second)); } dists.clear(); } @@ -429,7 +439,7 @@ int SplitMatrix::splitDistanceLarge(){ dFile >> seqA >> seqB >> dist; - if (m->control_pressed) { dFile.close(); for(int i=0;i 0){ remove((distFile + "." + toString(i) + ".temp").c_str()); } } return 0; } + if (m->control_pressed) { dFile.close(); for(int i=0;i 0){ m->mothurRemove((distFile + "." + toString(i) + ".temp")); } } return 0; } if(dist < cutoff){ //cout << "in cutoff: " << dist << endl; @@ -557,7 +567,7 @@ int SplitMatrix::splitDistanceLarge(){ delete memblock; fileB.close(); - remove(fileName2.c_str()); + m->mothurRemove(fileName2); //write out the merged memory if (numOutputs[groupID] > 60) { @@ -617,7 +627,7 @@ int SplitMatrix::splitDistanceLarge(){ delete memblock; fileB.close(); - remove(fileName2.c_str()); + m->mothurRemove(fileName2); //write out the merged memory if (numOutputs[groupID] > 60) { @@ -720,8 +730,8 @@ int SplitMatrix::splitNames(vector >& groups){ if (m->control_pressed) { for (int i = 0; i < dists.size(); i++) { - remove((dists[i].begin()->first).c_str()); - remove((dists[i].begin()->second).c_str()); + m->mothurRemove((dists[i].begin()->first)); + m->mothurRemove((dists[i].begin()->second)); } dists.clear(); } @@ -750,7 +760,7 @@ int SplitMatrix::splitDistanceRAM(){ dFile >> seqA >> seqB >> dist; - if (m->control_pressed) { dFile.close(); for(int i=0;i 0){ remove((distFile + "." + toString(i) + ".temp").c_str()); } } return 0; } + if (m->control_pressed) { dFile.close(); for(int i=0;i 0){ m->mothurRemove((distFile + "." + toString(i) + ".temp")); } } return 0; } if(dist < cutoff){ //cout << "in cutoff: " << dist << endl;