X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=heatmapsimcommand.cpp;h=28b0221ba8458cb1a760fade14426ea6a7123568;hb=4169642e8a8d45f71a4a7241ee02f1b1aae29520;hp=7e77980659681cd6aa4bbafbc6d502e4e0064bc7;hpb=a76d81690125ca57d7f602ac93abad75cf9796c2;p=mothur.git diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp index 7e77980..28b0221 100644 --- a/heatmapsimcommand.cpp +++ b/heatmapsimcommand.cpp @@ -19,20 +19,65 @@ #include "sharedmorisitahorn.h" #include "sharedbraycurtis.h" - +//********************************************************************************************************************** +vector HeatMapSimCommand::getValidParameters(){ + try { + string Array[] = {"groups","label", "calc","phylip","column","name","outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +HeatMapSimCommand::HeatMapSimCommand(){ + try { + abort = true; calledHelp = true; + vector tempOutNames; + outputTypes["svg"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector HeatMapSimCommand::getRequiredParameters(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector HeatMapSimCommand::getRequiredFiles(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "getRequiredFiles"); + exit(1); + } +} //********************************************************************************************************************** HeatMapSimCommand::HeatMapSimCommand(string option) { try { globaldata = GlobalData::getInstance(); - abort = false; + abort = false; calledHelp = false; allLines = 1; labels.clear(); Groups.clear(); Estimators.clear(); //allow user to run help - if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; } + if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; calledHelp = true; } else { //valid paramters for this command @@ -50,6 +95,10 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } + //initialize outputTypes + vector tempOutNames; + outputTypes["svg"] = tempOutNames; + format = ""; //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 = ""; } @@ -223,7 +272,7 @@ HeatMapSimCommand::~HeatMapSimCommand(){} int HeatMapSimCommand::execute(){ try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } heatmap = new HeatMapSim(outputDir); @@ -240,7 +289,7 @@ int HeatMapSimCommand::execute(){ delete heatmap; delete validCalculator; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -286,7 +335,7 @@ int HeatMapSimCommand::runCommandShared() { m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); vector outfilenames = heatmap->getPic(lookup, heatCalculators); - for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); } + for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]); } processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); @@ -300,7 +349,7 @@ int HeatMapSimCommand::runCommandShared() { m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); vector outfilenames = heatmap->getPic(lookup, heatCalculators); - for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); } + for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]); } processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); @@ -344,7 +393,7 @@ int HeatMapSimCommand::runCommandShared() { m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); vector outfilenames = heatmap->getPic(lookup, heatCalculators); - for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); } + for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]); } for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } @@ -482,8 +531,10 @@ int HeatMapSimCommand::runCommandDist() { delete nameMap; } - - outputNames.push_back(heatmap->getPic(matrix, names)); //vector>, vector + + string outputFileName = heatmap->getPic(matrix, names); + outputNames.push_back(outputFileName); //vector>, vector + outputTypes["svg"].push_back(outputFileName); return 0; }