X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=clustercommand.cpp;h=528f71c11c24f7a47133bef2d60a6906249abe92;hb=2bb9267aa4b4ecdf8488b06605cc9f3f36fa4332;hp=fd1f841dacab7ea017f15400766f384f10789cf3;hpb=220dc345e493cddc569521111ce32ac4d965ab7f;p=mothur.git diff --git a/clustercommand.cpp b/clustercommand.cpp index fd1f841..528f71c 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -11,6 +11,7 @@ #include "readphylip.h" #include "readcolumn.h" #include "readmatrix.hpp" +#include "clusterdoturcommand.h" //********************************************************************************************************************** vector ClusterCommand::setParameters(){ @@ -182,7 +183,7 @@ ClusterCommand::ClusterCommand(string option) { if (temp == "not found") { temp = "100"; } //saves precision legnth for formatting below length = temp.length(); - convert(temp, precision); + m->mothurConvert(temp, precision); temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "T"; } hard = m->isTrue(temp); @@ -192,7 +193,7 @@ ClusterCommand::ClusterCommand(string option) { temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "10"; } - convert(temp, cutoff); + m->mothurConvert(temp, cutoff); cutoff += (5 / (precision * 10.0)); method = validParameter.validFile(parameters, "method", false); @@ -207,7 +208,7 @@ ClusterCommand::ClusterCommand(string option) { timing = validParameter.validFile(parameters, "timing", false); if (timing == "not found") { timing = "F"; } - } + } } catch(exception& e) { m->errorOut(e, "ClusterCommand", "ClusterCommand"); @@ -223,6 +224,34 @@ int ClusterCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } + //phylip file given and cutoff not given - use cluster.classic because it uses less memory and is faster + if ((format == "phylip") && (cutoff > 10.0)) { + m->mothurOutEndLine(); m->mothurOut("You are using a phylip file and no cutoff. I will run cluster.classic to save memory and time."); m->mothurOutEndLine(); + + //run unique.seqs for deconvolute results + string inputString = "phylip=" + distfile; + if (namefile != "") { inputString += ", name=" + namefile; } + inputString += ", precision=" + toString(precision); + inputString += ", method=" + method; + if (hard) { inputString += ", hard=T"; } + else { inputString += ", hard=F"; } + if (sim) { inputString += ", sim=T"; } + else { inputString += ", sim=F"; } + + + m->mothurOutEndLine(); + m->mothurOut("/------------------------------------------------------------/"); m->mothurOutEndLine(); + m->mothurOut("Running command: cluster.classic(" + inputString + ")"); m->mothurOutEndLine(); + + Command* clusterClassicCommand = new ClusterDoturCommand(inputString); + clusterClassicCommand->execute(); + delete clusterClassicCommand; + + m->mothurOut("/------------------------------------------------------------/"); m->mothurOutEndLine(); + + return 0; + } + ReadMatrix* read; if (format == "column") { read = new ReadColumnMatrix(columnfile, sim); } //sim indicates whether its a similarity matrix else if (format == "phylip") { read = new ReadPhylipMatrix(phylipfile, sim); } @@ -244,7 +273,7 @@ int ClusterCommand::execute(){ if (m->control_pressed) { //clean up delete list; delete matrix; delete rabund; sabundFile.close();rabundFile.close();listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -283,7 +312,7 @@ int ClusterCommand::execute(){ if (m->control_pressed) { //clean up delete list; delete matrix; delete rabund; delete cluster; sabundFile.close();rabundFile.close();listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -326,7 +355,7 @@ int ClusterCommand::execute(){ cout.flush(); print_start = false; } - + if(previousDist <= 0.0000){ printData("unique"); }