X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=otuassociationcommand.cpp;fp=otuassociationcommand.cpp;h=06f83a4f1a390536a9952d10d413ec22613b89cd;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=93f46ba1e716f80e321245832eb11eabb2bda733;hpb=ee8403d4eb5760187d62b42a9cf4272de8fc0ec4;p=mothur.git diff --git a/otuassociationcommand.cpp b/otuassociationcommand.cpp index 93f46ba..06f83a4 100644 --- a/otuassociationcommand.cpp +++ b/otuassociationcommand.cpp @@ -53,12 +53,32 @@ string OTUAssociationCommand::getHelpString(){ } } //********************************************************************************************************************** +string OTUAssociationCommand::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 == "otucorr") { outputFileName = "otu.corr"; } + 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, "OTUAssociationCommand", "getOutputFileNameTag"); + exit(1); + } +} +//********************************************************************************************************************** OTUAssociationCommand::OTUAssociationCommand(){ try { abort = true; calledHelp = true; setParameters(); vector tempOutNames; - outputTypes["otu.corr"] = tempOutNames; + outputTypes["otucorr"] = tempOutNames; } catch(exception& e) { m->errorOut(e, "OTUAssociationCommand", "OTUAssociationCommand"); @@ -90,7 +110,7 @@ OTUAssociationCommand::OTUAssociationCommand(string option) { } vector tempOutNames; - outputTypes["otu.corr"] = tempOutNames; + outputTypes["otucorr"] = tempOutNames; //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); @@ -306,8 +326,8 @@ int OTUAssociationCommand::processShared(){ int OTUAssociationCommand::process(vector& lookup){ try { - string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + ".otu.corr"; - outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName); + string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + "." + getOutputFileNameTag("otucorr"); + outputNames.push_back(outputFileName); outputTypes["otucorr"].push_back(outputFileName); ofstream out; m->openOutputFile(outputFileName, out); @@ -466,8 +486,8 @@ int OTUAssociationCommand::processRelabund(){ int OTUAssociationCommand::process(vector& lookup){ try { - string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + ".otu.corr"; - outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName); + string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + "." + getOutputFileNameTag("otucorr"); + outputNames.push_back(outputFileName); outputTypes["otucorr"].push_back(outputFileName); ofstream out; m->openOutputFile(outputFileName, out);