X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=indicatorcommand.cpp;h=f98620b2ee0bd4cc70bc10d1db908d8de40de995;hb=078d7227da8dda9ae8620822fa32d51ec2706fc3;hp=97f480e749b7042a07a39d0f48890ff137d49dd0;hpb=d2390ede25cc211f95f99e377d5654bad7e6950e;p=mothur.git diff --git a/indicatorcommand.cpp b/indicatorcommand.cpp index 97f480e..f98620b 100644 --- a/indicatorcommand.cpp +++ b/indicatorcommand.cpp @@ -57,7 +57,27 @@ string IndicatorCommand::getHelpString(){ exit(1); } } - +//********************************************************************************************************************** +string IndicatorCommand::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 == "tree") { outputFileName = "indicator.tre"; } + else if (type == "summary") { outputFileName = "indicator.summary"; } + 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, "IndicatorCommand", "getOutputFileNameTag"); + exit(1); + } +} //********************************************************************************************************************** IndicatorCommand::IndicatorCommand(){ try { @@ -240,7 +260,6 @@ int IndicatorCommand::execute(){ util.setGroups(Groups, nameGroups); designMap->setNamesOfGroups(nameGroups); - //loop through the Groups and fill Globaldata's Groups with the design file info vector namesSeqs = designMap->getNamesSeqs(Groups); m->setGroups(namesSeqs); } @@ -386,7 +405,7 @@ int IndicatorCommand::GetIndicatorSpecies(){ try { string thisOutputDir = outputDir; if (outputDir == "") { thisOutputDir += m->hasPath(inputFileName); } - string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + "indicator.summary"; + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("summary"); outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName); ofstream out; @@ -501,7 +520,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ string thisOutputDir = outputDir; if (outputDir == "") { thisOutputDir += m->hasPath(inputFileName); } - string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + "indicator.summary"; + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("summary"); outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName); ofstream out; @@ -521,7 +540,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ string treeOutputDir = outputDir; if (outputDir == "") { treeOutputDir += m->hasPath(treefile); } - string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + "indicator.tre"; + string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("tree"); //create a map from tree node index to names of descendants, save time later to know which sharedRabund you need