#include "getrabundcommand.h"
//**********************************************************************************************************************
-
+vector<string> GetRAbundCommand::getValidParameters(){
+ try {
+ string Array[] = {"label","sorted","outputdir","inputdir"};
+ vector<string> 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<string> tempOutNames;
+ outputTypes["rabund"] = tempOutNames;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetRAbundCommand", "GetRAbundCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> GetRAbundCommand::getRequiredParameters(){
+ try {
+ vector<string> myArray;
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetRAbundCommand", "getRequiredParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> GetRAbundCommand::getRequiredFiles(){
+ try {
+ string Array[] = {"list"};
+ vector<string> 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();
//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<string> 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; }
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; }
}
}
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);
}
}
set<string> processedLabels;
set<string> 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))) {
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); }
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;
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); }
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); }
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;
}