X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getrabundcommand.cpp;h=3b03f3694967d6d480ba0dc00153454c7e8b074f;hb=348de0f8b17d84ede77081dcf67bd6ef43496677;hp=b7dd7153609ada80c297d5d51cab70d3cae5ebc4;hpb=260ae19c36cb11a53ddc5a75b5e507f8dd8b31d6;p=mothur.git diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp index b7dd715..3b03f36 100644 --- a/getrabundcommand.cpp +++ b/getrabundcommand.cpp @@ -10,16 +10,63 @@ #include "getrabundcommand.h" //********************************************************************************************************************** - +vector GetRAbundCommand::getValidParameters(){ + try { + string Array[] = {"label","sorted","outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetRAbundCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +GetRAbundCommand::GetRAbundCommand(){ + try { + abort = true; calledHelp = true; + vector tempOutNames; + outputTypes["rabund"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "GetRAbundCommand", "GetRAbundCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector GetRAbundCommand::getRequiredParameters(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetRAbundCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector GetRAbundCommand::getRequiredFiles(){ + try { + string Array[] = {"list"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetRAbundCommand", "getRequiredFiles"); + exit(1); + } +} +//********************************************************************************************************************** GetRAbundCommand::GetRAbundCommand(string option) { try { globaldata = GlobalData::getInstance(); - abort = false; + abort = false; calledHelp = false; allLines = 1; labels.clear(); //allow user to run help - if(option == "help") { help(); abort = true; } + if(option == "help") { help(); abort = true; calledHelp = true; } else { //valid paramters for this command @@ -42,6 +89,10 @@ GetRAbundCommand::GetRAbundCommand(string option) { outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it } + //initialize outputTypes + vector tempOutNames; + outputTypes["rabund"] = tempOutNames; + //make sure the user has already run the read.otu command if (globaldata->getListFile() == "") { m->mothurOut("You must read a listfile before you can use the get.rabund command."); m->mothurOutEndLine(); abort = true; } @@ -106,7 +157,7 @@ GetRAbundCommand::~GetRAbundCommand(){} int GetRAbundCommand::execute(){ try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } //read first line read = new ReadOTUFile(globaldata->inputFileName); @@ -120,7 +171,7 @@ int GetRAbundCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { out.close(); remove(filename.c_str()); delete list; globaldata->gListVector = NULL; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete list; globaldata->gListVector = NULL; return 0; } while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { @@ -129,7 +180,7 @@ int GetRAbundCommand::execute(){ rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - if (m->control_pressed) { out.close(); remove(filename.c_str()); delete list; delete rabund; globaldata->gListVector = NULL; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete list; delete rabund; globaldata->gListVector = NULL; return 0; } if(sorted) { rabund->print(out); } @@ -151,7 +202,7 @@ int GetRAbundCommand::execute(){ rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - if (m->control_pressed) { out.close(); remove(filename.c_str()); delete list; delete rabund; globaldata->gListVector = NULL; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete list; delete rabund; globaldata->gListVector = NULL; return 0; } if(sorted) { rabund->print(out); } else { rabund->nonSortedPrint(out); } @@ -193,7 +244,7 @@ int GetRAbundCommand::execute(){ rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - if (m->control_pressed) { out.close(); remove(filename.c_str()); delete list; delete rabund; globaldata->gListVector = NULL; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete list; delete rabund; globaldata->gListVector = NULL; return 0; } if(sorted) { rabund->print(out); } else { rabund->nonSortedPrint(out); } @@ -204,13 +255,20 @@ int GetRAbundCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); - m->mothurOut(filename); m->mothurOutEndLine(); + m->mothurOut(filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["rabund"].push_back(filename); m->mothurOutEndLine(); out.close(); globaldata->gListVector = NULL; + //set rabund file as new current rabundfile + string current = ""; + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + return 0; }