X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=listotulabelscommand.cpp;fp=listotulabelscommand.cpp;h=e50196bec8bdb8e22004561df9537648d529514d;hb=1a5c2356c1b955c6ec024b2baf9f46377ee7c72e;hp=4a12197b9f21534173c92f6d99c389a3aabb907f;hpb=79a7d3273749b08d4f9f8dfe350c964ff0c4351e;p=mothur.git diff --git a/listotulabelscommand.cpp b/listotulabelscommand.cpp index 4a12197..e50196b 100644 --- a/listotulabelscommand.cpp +++ b/listotulabelscommand.cpp @@ -12,13 +12,13 @@ //********************************************************************************************************************** vector ListOtuLabelsCommand::setParameters(){ try { - CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(pshared); - CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(prelabund); - CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); - CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); + CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none","otulabels",false,false,true); parameters.push_back(pshared); + CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none","otulabels",false,false); parameters.push_back(prelabund); + CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups); + CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel); //every command must have inputdir and outputdir. This allows mothur users to redirect input and output files. - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + 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); } @@ -47,26 +47,20 @@ string ListOtuLabelsCommand::getHelpString(){ } } //********************************************************************************************************************** -string ListOtuLabelsCommand::getOutputFileNameTag(string type, string inputName=""){ - try { - string outputFileName = ""; - map >::iterator it; +string ListOtuLabelsCommand::getOutputPattern(string type) { + try { + string pattern = ""; - //is this a type this command creates - it = outputTypes.find(type); - if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); } - else { - if (type == "otulabels") { outputFileName = "otulabels"; } - else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } - } - return outputFileName; - } - catch(exception& e) { - m->errorOut(e, "ListOtuLabelsCommand", "getOutputFileNameTag"); - exit(1); - } + if (type == "otulabels") { pattern = "[filename],[distance],otulabels"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "ListOtuLabelsCommand", "getOutputPattern"); + exit(1); + } } - //********************************************************************************************************************** ListOtuLabelsCommand::ListOtuLabelsCommand(){ try { @@ -365,7 +359,10 @@ int ListOtuLabelsCommand::execute(){ int ListOtuLabelsCommand::createList(vector& lookup){ try { - string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("otulabels"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName)); + variables["[distance]"] = lookup[0]->getLabel(); + string outputFileName = getOutputFileName("otulabels",variables); outputNames.push_back(outputFileName); outputTypes["otulabels"].push_back(outputFileName); ofstream out; m->openOutputFile(outputFileName, out); @@ -386,8 +383,10 @@ int ListOtuLabelsCommand::createList(vector& lookup){ int ListOtuLabelsCommand::createList(vector& lookup){ try { - - string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("otulabels"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName)); + variables["[distance]"] = lookup[0]->getLabel(); + string outputFileName = getOutputFileName("otulabels",variables); outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName); ofstream out; m->openOutputFile(outputFileName, out);