X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=getlistcountcommand.cpp;h=a4d7b83397f83bf6ae3dd21627566252035b328f;hp=57afd85943e956b6bf4364d0b7c0b8bf27657cc3;hb=615301e57c25e241356a9c2380648d117709458d;hpb=7bf9a81bba76538ecaf351ae208de3da4bf1b6dd diff --git a/getlistcountcommand.cpp b/getlistcountcommand.cpp index 57afd85..a4d7b83 100644 --- a/getlistcountcommand.cpp +++ b/getlistcountcommand.cpp @@ -12,11 +12,11 @@ //********************************************************************************************************************** vector 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 myArray; for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } @@ -49,6 +49,21 @@ string GetListCountCommand::getHelpString(){ } } //********************************************************************************************************************** +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; @@ -149,7 +164,7 @@ int GetListCountCommand::execute(){ set processedLabels; set 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))) { @@ -157,7 +172,7 @@ int GetListCountCommand::execute(){ 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()); @@ -171,7 +186,7 @@ int GetListCountCommand::execute(){ 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()); @@ -208,7 +223,7 @@ int GetListCountCommand::execute(){ 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; } @@ -234,7 +249,11 @@ void GetListCountCommand::process(ListVector* list) { try { string binnames; if (outputDir == "") { outputDir += m->hasPath(listfile); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu"; + map 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);