X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=corraxescommand.cpp;h=f8083cc01c10a23b4626c6ea2ccd285a15f59c87;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=a1c3a3d6cd9e6849fb5f86be42a1d46bcd9bc138;hpb=5d77fd07180d1fb8561ff1962e6d7429caf8555e;p=mothur.git diff --git a/corraxescommand.cpp b/corraxescommand.cpp index a1c3a3d..f8083cc 100644 --- a/corraxescommand.cpp +++ b/corraxescommand.cpp @@ -56,12 +56,32 @@ string CorrAxesCommand::getHelpString(){ } } //********************************************************************************************************************** +string CorrAxesCommand::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 == "corraxes") { outputFileName = "corr.axes"; } + 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, "CorrAxesCommand", "getOutputFileNameTag"); + exit(1); + } +} +//********************************************************************************************************************** CorrAxesCommand::CorrAxesCommand(){ try { abort = true; calledHelp = true; setParameters(); vector tempOutNames; - outputTypes["corr.axes"] = tempOutNames; + outputTypes["corraxes"] = tempOutNames; } catch(exception& e) { m->errorOut(e, "CorrAxesCommand", "CorrAxesCommand"); @@ -92,7 +112,7 @@ CorrAxesCommand::CorrAxesCommand(string option) { } vector tempOutNames; - outputTypes["corr.axes"] = tempOutNames; + outputTypes["corraxes"] = 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); @@ -266,8 +286,8 @@ int CorrAxesCommand::execute(){ // calc the r values // /************************************************************************************/ - string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + method + ".corr.axes"; - outputNames.push_back(outputFileName); outputTypes["corr.axes"].push_back(outputFileName); + string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + method + "." + getOutputFileNameTag("corraxes"); + outputNames.push_back(outputFileName); outputTypes["corraxes"].push_back(outputFileName); ofstream out; m->openOutputFile(outputFileName, out); out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint); @@ -321,7 +341,7 @@ int CorrAxesCommand::calcPearson(map >& axes, ofstream& ou //for each otu for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) { - if (metadatafile == "") { out << i+1; } + if (metadatafile == "") { out << m->currentBinLabels[i]; } else { out << metadataLabels[i]; } //find the averages this otu - Y @@ -456,7 +476,7 @@ int CorrAxesCommand::calcSpearman(map >& axes, ofstream& o //for each otu for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) { - if (metadatafile == "") { out << i+1; } + if (metadatafile == "") { out << m->currentBinLabels[i]; } else { out << metadataLabels[i]; } //find the ranks of this otu - Y @@ -609,7 +629,7 @@ int CorrAxesCommand::calcKendall(map >& axes, ofstream& ou //for each otu for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) { - if (metadatafile == "") { out << i+1; } + if (metadatafile == "") { out << m->currentBinLabels[i]; } else { out << metadataLabels[i]; } //find the ranks of this otu - Y