X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=clustercommand.cpp;h=6043d39be8d559010e156111f41a856b716cda40;hb=191ae1be0679d5cf4eda950b3b1bf26fb7dd503d;hp=2f9c36e0ff84c4b67af8f9e4d50e77edd62d414a;hpb=61798fe609675abfedf511e542cc48c56a531199;p=mothur.git diff --git a/clustercommand.cpp b/clustercommand.cpp index 2f9c36e..6043d39 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -9,6 +9,56 @@ #include "clustercommand.h" +//********************************************************************************************************************** +vector ClusterCommand::getValidParameters(){ + try { + string AlignArray[] = {"cutoff","precision","method","showabund","timing","hard","outputdir","inputdir"}; + vector myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "ClusterCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +ClusterCommand::ClusterCommand(){ + try { + abort = true; + //initialize outputTypes + vector tempOutNames; + outputTypes["list"] = tempOutNames; + outputTypes["rabund"] = tempOutNames; + outputTypes["sabund"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "ClusterCommand", "ClusterCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector ClusterCommand::getRequiredParameters(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "ClusterCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector ClusterCommand::getRequiredFiles(){ + try { + string Array[] = {"phylip","column","or"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "ClusterCommand", "getRequiredFiles"); + exit(1); + } +} //********************************************************************************************************************** //This function checks to make sure the cluster command has no errors and then clusters based on the method chosen. ClusterCommand::ClusterCommand(string option) { @@ -37,6 +87,12 @@ ClusterCommand::ClusterCommand(string option) { } } + //initialize outputTypes + vector tempOutNames; + outputTypes["list"] = tempOutNames; + outputTypes["rabund"] = tempOutNames; + outputTypes["sabund"] = tempOutNames; + //if the user changes the output directory command factory will send this info to us in the output parameter outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; } @@ -101,9 +157,9 @@ ClusterCommand::ClusterCommand(string option) { m->openOutputFile(fileroot+ tag + ".rabund", rabundFile); m->openOutputFile(fileroot+ tag + ".list", listFile); - outputNames.push_back(fileroot+ tag + ".sabund"); - outputNames.push_back(fileroot+ tag + ".rabund"); - outputNames.push_back(fileroot+ tag + ".list"); + outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund"); + outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund"); + outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list"); } } } @@ -158,14 +214,14 @@ int ClusterCommand::execute(){ double saveCutoff = cutoff; while (matrix->getSmallDist() < cutoff && matrix->getNNodes() > 0){ - cout << matrix->getSmallDist() << '\t' << cutoff << '\t' << matrix->getNNodes() << endl; + if (m->control_pressed) { //clean up delete globaldata->gSparseMatrix; globaldata->gSparseMatrix = NULL; delete globaldata->gListVector; globaldata->gListVector = NULL; if (globaldata->getFormat() == "phylip") { globaldata->setPhylipFile(""); } else if (globaldata->getFormat() == "column") { globaldata->setColumnFile(""); } sabundFile.close();rabundFile.close();listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0; }