X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getrabundcommand.cpp;h=60f4ece3eb13de6fc68f6141c3e28ca283da694b;hb=5d6d303e481489e226fdf8d6c5385b99b50718bc;hp=6b68c32cad7673b950eeb8acfe6423b160630130;hpb=aa9238c0a9e6e7aa0ed8b8b606b08ad4fd7dcfe3;p=mothur.git diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp index 6b68c32..60f4ece 100644 --- a/getrabundcommand.cpp +++ b/getrabundcommand.cpp @@ -10,7 +10,55 @@ #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; + //initialize outputTypes + 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(); @@ -39,9 +87,13 @@ GetRAbundCommand::GetRAbundCommand(string option) { //if the user changes the output directory command factory will send this info to us in the output parameter string outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; - outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it + 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; } @@ -50,12 +102,12 @@ GetRAbundCommand::GetRAbundCommand(string option) { string temp; temp = validParameter.validFile(parameters, "sorted", false); if (temp == "not found") { temp = "T"; } - sorted = isTrue(temp); + sorted = m->isTrue(temp); label = validParameter.validFile(parameters, "label", false); if (label == "not found") { label = ""; } else { - if(label != "all") { splitAtDash(label, labels); allLines = 0; } + if(label != "all") { m->splitAtDash(label, labels); allLines = 0; } else { allLines = 1; } } @@ -66,8 +118,8 @@ GetRAbundCommand::GetRAbundCommand(string option) { } if (abort == false) { - filename = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "rabund"; - openOutputFile(filename, out); + filename = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "rabund"; + m->openOutputFile(filename, out); } } @@ -120,7 +172,7 @@ int GetRAbundCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { out.close(); remove(filename.c_str()); delete read; delete input; 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 +181,7 @@ int GetRAbundCommand::execute(){ rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - if (m->control_pressed) { out.close(); remove(filename.c_str()); delete read; delete input; 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); } @@ -141,7 +193,7 @@ int GetRAbundCommand::execute(){ userLabels.erase(list->getLabel()); } - if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { + if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { string saveLabel = list->getLabel(); delete list; @@ -151,7 +203,7 @@ int GetRAbundCommand::execute(){ rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - if (m->control_pressed) { out.close(); remove(filename.c_str()); delete read; delete input; 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 +245,7 @@ int GetRAbundCommand::execute(){ rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - if (m->control_pressed) { out.close(); remove(filename.c_str()); delete read; delete input; 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 +256,12 @@ 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(); - delete read; delete input; - globaldata->gListVector = NULL; + + globaldata->gListVector = NULL; return 0; }