#include "getlistcountcommand.h"
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getValidParameters(){
+ try {
+ string Array[] = {"list","label","sort","outputdir","inputdir"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetListCountCommand", "getValidParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+GetListCountCommand::GetListCountCommand(){
+ try {
+ abort = true;
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["otu"] = tempOutNames;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetListCountCommand", "GetListCountCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getRequiredParameters(){
+ try {
+ string Array[] = {"list"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetListCountCommand", "getRequiredParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getRequiredFiles(){
+ try {
+ vector<string> myArray;
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetListCountCommand", "getRequiredFiles");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
GetListCountCommand::GetListCountCommand(string option) {
try {
if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
}
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["otu"] = tempOutNames;
+
string ranRead = globaldata->getListFile();
//if the user changes the input directory command factory will send this info to us in the output parameter
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
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; }
}
delete input;
delete list;
globaldata->gListVector = NULL;
- for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); }
+ for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear();
return 0;
}
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;
delete input;
delete list;
globaldata->gListVector = NULL;
- for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); }
+ for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear();
return 0;
}
delete input;
delete list;
globaldata->gListVector = NULL;
- for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); }
+ for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear();
return 0;
}
void GetListCountCommand::process(ListVector* list) {
try {
string binnames;
- if (outputDir == "") { outputDir += hasPath(listfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + list->getLabel() + ".otu";
- openOutputFile(outputFileName, out);
- outputNames.push_back(outputFileName);
+ if (outputDir == "") { outputDir += m->hasPath(listfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu";
+ m->openOutputFile(outputFileName, out);
+ outputNames.push_back(outputFileName); outputTypes["otu"].push_back(outputFileName);
m->mothurOut(list->getLabel()); m->mothurOutEndLine();
out << i+1 << '\t' << binnames << endl;
}else{ //sort = name
vector<string> names;
- splitAtComma(binnames, names);
+ m->splitAtComma(binnames, names);
for (int j = 0; j < names.size(); j++) {
out << names[j] << '\t' << i+1 << endl;