X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=parselistscommand.cpp;h=61cb2454b52ee9e05cf1027995906371b5463762;hb=55bbd10379db27def51cec72a8819d775f73e45b;hp=4e61a58d9e5cb4bc640c544797c87a363580575e;hpb=f687723a8357916e86a05116978e6869b039ce36;p=mothur.git diff --git a/parselistscommand.cpp b/parselistscommand.cpp index 4e61a58..61cb245 100644 --- a/parselistscommand.cpp +++ b/parselistscommand.cpp @@ -12,11 +12,11 @@ //********************************************************************************************************************** vector ParseListCommand::setParameters(){ try { - CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist); - CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup); - CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); - 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","list",false,true,true); parameters.push_back(plist); + CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pgroup); + CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel); + 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); } @@ -46,26 +46,20 @@ string ParseListCommand::getHelpString(){ } } //********************************************************************************************************************** -string ParseListCommand::getOutputFileNameTag(string type, string inputName=""){ - try { - string outputFileName = ""; - map >::iterator it; +string ParseListCommand::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 == "list") { outputFileName = "list"; } - 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, "ParseListCommand", "getOutputFileNameTag"); - exit(1); - } + if (type == "list") { pattern = "[filename],[group],list"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "ParseListCommand", "getOutputPattern"); + exit(1); + } } - //********************************************************************************************************************** ParseListCommand::ParseListCommand(){ try { @@ -191,7 +185,8 @@ int ParseListCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } //set fileroot - string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile)); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile)); //fill filehandles with neccessary ofstreams int i; @@ -201,7 +196,8 @@ int ParseListCommand::execute(){ temp = new ofstream; filehandles[gGroups[i]] = temp; - string filename = fileroot + gGroups[i] + "." + getOutputFileNameTag("list"); + variables["[group]"] = gGroups[i]; + string filename = getOutputFileName("list",variables); outputNames.push_back(filename); outputTypes["list"].push_back(filename); m->openOutputFile(filename, *temp); }