X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=corraxescommand.cpp;h=72fa03b75edc196aafcaaa4b6ade6f95d1106d48;hp=c4454a5181c719302011e6e98410408826183735;hb=b206f634aae1b4ce13978d203247fb64757d5482;hpb=a9dbc22713bfc056a797361dd757b1a5c98e1c01 diff --git a/corraxescommand.cpp b/corraxescommand.cpp index c4454a5..72fa03b 100644 --- a/corraxescommand.cpp +++ b/corraxescommand.cpp @@ -14,16 +14,16 @@ //********************************************************************************************************************** vector CorrAxesCommand::setParameters(){ try { - CommandParameter paxes("axes", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paxes); - CommandParameter pshared("shared", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pshared); - CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(prelabund); - CommandParameter pmetadata("metadata", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pmetadata); - CommandParameter pnumaxes("numaxes", "Number", "", "3", "", "", "",false,false); parameters.push_back(pnumaxes); - CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); - CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); - CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "",false,false); parameters.push_back(pmethod); - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + CommandParameter paxes("axes", "InputTypes", "", "", "none", "none", "none","corraxes",false,true,true); parameters.push_back(paxes); + CommandParameter pshared("shared", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none","",false,false,true); parameters.push_back(pshared); + CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none","",false,false,true); parameters.push_back(prelabund); + CommandParameter pmetadata("metadata", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none","",false,false); parameters.push_back(pmetadata); + CommandParameter pnumaxes("numaxes", "Number", "", "3", "", "", "","",false,false); parameters.push_back(pnumaxes); + CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel); + CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups); + CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "","",false,false); parameters.push_back(pmethod); + CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir); + CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir); vector myArray; for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } @@ -56,25 +56,21 @@ string CorrAxesCommand::getHelpString(){ } } //********************************************************************************************************************** -string CorrAxesCommand::getOutputFileNameTag(string type, string inputName=""){ - try { - string outputFileName = ""; - map >::iterator it; +string CorrAxesCommand::getOutputPattern(string type) { + try { + string pattern = ""; - //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); - } + if (type == "corraxes") { pattern = "[filename],[tag],corr.axes"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "CorrAxesCommand", "getOutputPattern"); + exit(1); + } } + //********************************************************************************************************************** CorrAxesCommand::CorrAxesCommand(){ try { @@ -285,8 +281,10 @@ int CorrAxesCommand::execute(){ /*************************************************************************************/ // calc the r values // /************************************************************************************/ - - string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + method + "." + getOutputFileNameTag("corraxes"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName)); + variables["[tag]"] = method; + string outputFileName = getOutputFileName("corraxes", variables); outputNames.push_back(outputFileName); outputTypes["corraxes"].push_back(outputFileName); ofstream out; m->openOutputFile(outputFileName, out); @@ -341,7 +339,7 @@ int CorrAxesCommand::calcPearson(map >& axes, ofstream& ou //for each otu for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) { - if (metadatafile == "") { out << m->currentBinLabels[i]; } + if (metadatafile == "") { out << m->currentSharedBinLabels[i]; } else { out << metadataLabels[i]; } //find the averages this otu - Y @@ -476,7 +474,7 @@ int CorrAxesCommand::calcSpearman(map >& axes, ofstream& o //for each otu for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) { - if (metadatafile == "") { out << m->currentBinLabels[i]; } + if (metadatafile == "") { out << m->currentSharedBinLabels[i]; } else { out << metadataLabels[i]; } //find the ranks of this otu - Y @@ -629,7 +627,7 @@ int CorrAxesCommand::calcKendall(map >& axes, ofstream& ou //for each otu for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) { - if (metadatafile == "") { out << m->currentBinLabels[i]; } + if (metadatafile == "") { out << m->currentSharedBinLabels[i]; } else { out << metadataLabels[i]; } //find the ranks of this otu - Y @@ -836,7 +834,7 @@ int CorrAxesCommand::eliminateZeroOTUS(vector& thisloo for (int h = 0; h < diff; h++) { binLabel += "0"; } } binLabel += sbinNumber; - if (i < m->currentBinLabels.size()) { binLabel = m->currentBinLabels[i]; } + if (i < m->currentSharedBinLabels.size()) { binLabel = m->currentSharedBinLabels[i]; } newBinLabels.push_back(binLabel); } @@ -845,7 +843,7 @@ int CorrAxesCommand::eliminateZeroOTUS(vector& thisloo for (int j = 0; j < thislookup.size(); j++) { delete thislookup[j]; } thislookup = newLookup; - m->currentBinLabels = newBinLabels; + m->currentSharedBinLabels = newBinLabels; return 0;