X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=mergegroupscommand.cpp;h=bfd1b8484eee963c897000a20024aae831c531f5;hp=e30558cbe69d3069135e0432f2eda7f9623095b5;hb=050a3ff02473a3d4c0980964e1a9ebe52e55d6b8;hpb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc diff --git a/mergegroupscommand.cpp b/mergegroupscommand.cpp index e30558c..bfd1b84 100644 --- a/mergegroupscommand.cpp +++ b/mergegroupscommand.cpp @@ -13,13 +13,13 @@ //********************************************************************************************************************** vector MergeGroupsCommand::setParameters(){ try { - CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared); - CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pgroup); - CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign); - CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); - CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none","shared",false,false,true); parameters.push_back(pshared); + CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "none","group",false,false,true); parameters.push_back(pgroup); + CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pdesign); + CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel); + CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups); + 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); } @@ -52,6 +52,23 @@ string MergeGroupsCommand::getHelpString(){ exit(1); } } + +//********************************************************************************************************************** +string MergeGroupsCommand::getOutputPattern(string type) { + try { + string pattern = ""; + + if (type == "shared") { pattern = "[filename],merge,[extension]"; } + else if (type == "group") { pattern = "[filename],merge,[extension]"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "MergeGroupsCommand", "getOutputPattern"); + exit(1); + } +} //********************************************************************************************************************** MergeGroupsCommand::MergeGroupsCommand(){ try { @@ -284,8 +301,11 @@ int MergeGroupsCommand::processSharedFile(GroupMap*& designMap){ string thisOutputDir = outputDir; if (outputDir == "") { thisOutputDir += m->hasPath(sharedfile); } - string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "merge" + m->getExtension(sharedfile); - outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName); + map variables; + variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)); + variables["[extension]"] = m->getExtension(sharedfile); + string outputFileName = getOutputFileName("shared", variables); + outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName); ofstream out; m->openOutputFile(outputFileName, out); @@ -387,7 +407,10 @@ int MergeGroupsCommand::processGroupFile(GroupMap*& designMap){ string thisOutputDir = outputDir; if (outputDir == "") { thisOutputDir += m->hasPath(groupfile); } - string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "merge" + m->getExtension(groupfile); + map variables; + variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)); + variables["[extension]"] = m->getExtension(groupfile); + string outputFileName = getOutputFileName("group", variables); outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName); ofstream out;