X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=otuhierarchycommand.cpp;h=091bf9bb0659dd0895bf47a414fa4ea86692f026;hb=79a7d3273749b08d4f9f8dfe350c964ff0c4351e;hp=2f99aa6091452933f6796f21aa043449bfce1dd4;hpb=19fcbbdba99658f5eca244803280f9ee7f9f6607;p=mothur.git diff --git a/otuhierarchycommand.cpp b/otuhierarchycommand.cpp index 2f99aa6..091bf9b 100644 --- a/otuhierarchycommand.cpp +++ b/otuhierarchycommand.cpp @@ -46,7 +46,26 @@ string OtuHierarchyCommand::getHelpString(){ exit(1); } } - +//********************************************************************************************************************** +string OtuHierarchyCommand::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 == "otuheirarchy") { outputFileName = "otu.hierarchy"; } + 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, "OtuHierarchyCommand", "getOutputFileNameTag"); + exit(1); + } +} //********************************************************************************************************************** OtuHierarchyCommand::OtuHierarchyCommand(){ try { @@ -180,7 +199,7 @@ int OtuHierarchyCommand::execute(){ } ofstream out; - string outputFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + lists[0].getLabel() + "-" + lists[1].getLabel() + ".otu.hierarchy"; + string outputFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + lists[0].getLabel() + "-" + lists[1].getLabel() + "." + getOutputFileNameTag("otuheirarchy"); m->openOutputFile(outputFileName, out); //go through each bin in "big" otu and output the bins in "little" otu which created it @@ -222,7 +241,7 @@ int OtuHierarchyCommand::execute(){ if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0; } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["otuheirarchy"].push_back(outputFileName); m->mothurOutEndLine();