X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=hclustercommand.cpp;h=cf35cd9d6fa4c2a8fe1349b63399eb60007a4217;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=47136938a19e6c5d4b8dd2b8110849249ac50b06;hpb=0ca63a8165baa0afa459e644ebe140ba496d5ba0;p=mothur.git diff --git a/hclustercommand.cpp b/hclustercommand.cpp index 4713693..cf35cd9 100644 --- a/hclustercommand.cpp +++ b/hclustercommand.cpp @@ -52,6 +52,28 @@ string HClusterCommand::getHelpString(){ } } //********************************************************************************************************************** +string HClusterCommand::getOutputFileNameTag(string type, string inputName=""){ + try { + string outputFileName = ""; + map >::iterator it; + + //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 if (type == "rabund") { outputFileName = "rabund"; } + else if (type == "sabund") { outputFileName = "sabund"; } + 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, "HClusterCommand", "getOutputFileNameTag"); + exit(1); + } +} +//********************************************************************************************************************** HClusterCommand::HClusterCommand(){ try { abort = true; calledHelp = true; @@ -219,13 +241,17 @@ HClusterCommand::HClusterCommand(string option) { else if (method == "weighted") { tag = "wn"; } else { tag = "an"; } - m->openOutputFile(fileroot+ tag + ".sabund", sabundFile); - m->openOutputFile(fileroot+ tag + ".rabund", rabundFile); - m->openOutputFile(fileroot+ tag + ".list", listFile); - - outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund"); - outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund"); - outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list"); + string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund"); + string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund"); + string listFileName = fileroot+ tag + "." + getOutputFileNameTag("list"); + + m->openOutputFile(sabundFileName, sabundFile); + m->openOutputFile(rabundFileName, rabundFile); + m->openOutputFile(listFileName, listFile); + + outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName); + outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName); + outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName); } } }