//**********************************************************************************************************************
vector<string> GetListCountCommand::setParameters(){
try {
- CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
- CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
- CommandParameter parasort("sort", "Multiple", "name-otu", "otu", "", "", "",false,false); parameters.push_back(parasort);
- CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
- CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+ CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","otu",false,true, true); parameters.push_back(plist);
+ CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+ CommandParameter parasort("sort", "Multiple", "name-otu", "otu", "", "", "","",false,false); parameters.push_back(parasort);
+ 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.otulist(list=amazon.fn.list, label=0.10).\n";
helpString += "The default value for label is all lines in your inputfile.\n";
helpString += "The get.otulist command outputs a .otu file for each distance you specify listing the bin number and the names of the sequences in that bin.\n";
- helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n\n";
+ helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n";
return helpString;
}
catch(exception& e) {
}
}
//**********************************************************************************************************************
+string GetListCountCommand::getOutputPattern(string type) {
+ try {
+ string pattern = "";
+
+ if (type == "otu") { pattern = "[filename],[tag],otu"; }
+ else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
+
+ return pattern;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetListCountCommand", "getOutputPattern");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
GetListCountCommand::GetListCountCommand(){
try {
abort = true; calledHelp = true;
//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();
else { m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
}
else if (listfile == "not open") { abort = true; }
+ else { m->setListFile(listfile); }
//check for optional parameter and set defaults
set<string> processedLabels;
set<string> userLabels = labels;
- if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+ if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
process(list);
- if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+ if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
processedLabels.insert(list->getLabel());
userLabels.erase(list->getLabel());
process(list);
- if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+ if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
processedLabels.insert(list->getLabel());
process(list);
- if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+ if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
delete list;
}
try {
string binnames;
if (outputDir == "") { outputDir += m->hasPath(listfile); }
- string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu";
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+ variables["[tag]"] = list->getLabel();
+ string outputFileName = getOutputFileName("otu", variables);
+
m->openOutputFile(outputFileName, out);
outputNames.push_back(outputFileName); outputTypes["otu"].push_back(outputFileName);
m->mothurOut(list->getLabel()); m->mothurOutEndLine();
//for each bin in the list vector
+ vector<string> binLabels = list->getLabels();
for (int i = 0; i < list->getNumBins(); i++) {
if (m->control_pressed) { break; }
binnames = list->get(i);
if (sort == "otu") {
- out << i+1 << '\t' << binnames << endl;
+ out << binLabels[i] << '\t' << binnames << endl;
}else{ //sort = name
vector<string> names;
m->splitAtComma(binnames, names);
for (int j = 0; j < names.size(); j++) {
- out << names[j] << '\t' << i+1 << endl;
+ out << names[j] << '\t' << binLabels[i] << endl;
}
}
}