//**********************************************************************************************************************
vector<string> GetRAbundCommand::setParameters(){
try {
- CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
- CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
- CommandParameter psorted("sorted", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(psorted);
- CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
- CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
- CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+ CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","rabund",false,false, true); parameters.push_back(plist);
+ CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none","rabund",false,false, true); parameters.push_back(psabund);
+ CommandParameter psorted("sorted", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(psorted);
+ CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+ CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+ CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
helpString += "Example get.rabund(sorted=F).\n";
helpString += "The default value for label is all labels in your inputfile.\n";
helpString += "The get.rabund command outputs a .rabund file containing the lines you selected.\n";
- helpString += "Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabels).\n\n";
+ helpString += "Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabels).\n";
return helpString;
}
catch(exception& e) {
exit(1);
}
}
+//**********************************************************************************************************************
+string GetRAbundCommand::getOutputPattern(string type) {
+ try {
+ string pattern = "";
+
+ if (type == "rabund") { pattern = "[filename],rabund"; }
+ else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
+
+ return pattern;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetRAbundCommand", "getOutputPattern");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
GetRAbundCommand::GetRAbundCommand(){
//allow user to run help
if(option == "help") { help(); abort = true; calledHelp = true; }
+ else if(option == "citation") { citation(); abort = true; calledHelp = true;}
else {
vector<string> myArray = setParameters();
listfile = validParameter.validFile(parameters, "list", true);
if (listfile == "not open") { listfile = ""; abort = true; }
else if (listfile == "not found") { listfile = ""; }
- else { format = "list"; inputfile = listfile; }
+ else { format = "list"; inputfile = listfile; m->setListFile(listfile); }
sabundfile = validParameter.validFile(parameters, "sabund", true);
if (sabundfile == "not open") { sabundfile = ""; abort = true; }
else if (sabundfile == "not found") { sabundfile = ""; }
- else { format = "sabund"; inputfile = sabundfile; }
+ else { format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); }
//check for optional parameter and set defaults
if (abort == true) { if (calledHelp) { return 0; } return 2; }
- filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "rabund";
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+ filename = getOutputFileName("rabund", variables);
m->openOutputFile(filename, out);
input = new InputData(inputfile, format);
set<string> processedLabels;
set<string> userLabels = labels;
- if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete rabund; delete input; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete rabund; delete input; return 0; }
while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if(allLines == 1 || labels.count(rabund->getLabel()) == 1){
m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
- if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete input; delete rabund; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete input; delete rabund; return 0; }
if(sorted) { rabund->print(out); }
else { rabund->nonSortedPrint(out); }
-
- delete rabund;
processedLabels.insert(rabund->getLabel());
userLabels.erase(rabund->getLabel());
m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
- if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete input; delete rabund; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete input; delete rabund; return 0; }
if(sorted) { rabund->print(out); }
else { rabund->nonSortedPrint(out); }
- delete rabund;
-
processedLabels.insert(rabund->getLabel());
userLabels.erase(rabund->getLabel());
m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
- if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete input; delete rabund; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete input; delete rabund; return 0; }
if(sorted) { rabund->print(out); }
else { rabund->nonSortedPrint(out); }
}
m->mothurOutEndLine();
- m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
m->mothurOut(filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["rabund"].push_back(filename);
m->mothurOutEndLine();