X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=listotulabelscommand.cpp;h=e50196bec8bdb8e22004561df9537648d529514d;hb=4542a79d20176ff0ee830b0f9d4f4c92637439d9;hp=becfae3ff949f0a3f8bba42604459f8e4267dc65;hpb=bdd77df6a7df8a5775b57d0a7ec8b55de45e7b5b;p=mothur.git diff --git a/listotulabelscommand.cpp b/listotulabelscommand.cpp index becfae3..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); } @@ -33,11 +33,11 @@ vector ListOtuLabelsCommand::setParameters(){ string ListOtuLabelsCommand::getHelpString(){ try { string helpString = ""; - helpString += "The list.labels lists otu labels from shared or relabund file. The results can be used by the get.labels to select specific otus with the output from classify.otu, otu.association, or corr.axes.\n"; - helpString += "The list.labels parameters are: shared, relabund, label and groups.\n"; + helpString += "The list.otulabels lists otu labels from shared or relabund file. The results can be used by the get.otulabels to select specific otus with the output from classify.otu, otu.association, or corr.axes.\n"; + helpString += "The list.otulabels parameters are: shared, relabund, label and groups.\n"; helpString += "The label parameter is used to analyze specific labels in your input.\n"; helpString += "The groups parameter allows you to specify which of the groups you would like analyzed.\n"; - helpString += "The list.labels commmand should be in the following format: \n"; + helpString += "The list.otulabels commmand should be in the following format: \n"; helpString += "list.otulabels(shared=yourSharedFile, groups=yourGroup1-yourGroup2)\n"; return helpString; } @@ -47,6 +47,21 @@ string ListOtuLabelsCommand::getHelpString(){ } } //********************************************************************************************************************** +string ListOtuLabelsCommand::getOutputPattern(string type) { + try { + string pattern = ""; + + 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 { abort = true; calledHelp = true; @@ -344,7 +359,10 @@ int ListOtuLabelsCommand::execute(){ int ListOtuLabelsCommand::createList(vector& lookup){ try { - string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + ".otu.labels"; + 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); @@ -365,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() + ".otu.labels"; + 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);