X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=catchallcommand.cpp;h=efe99b007d6cd37e823ccca91937f4c38cd26c1b;hb=1916dd65829d6bb5b8bef74eddc61ea38fccf63a;hp=8f2841358dd4bbb91b69c2a530b6332b8fc2d131;hpb=c53ef46b40b97c00e32bfd8c3924ce8c51b5cd7b;p=mothur.git diff --git a/catchallcommand.cpp b/catchallcommand.cpp index 8f28413..efe99b0 100644 --- a/catchallcommand.cpp +++ b/catchallcommand.cpp @@ -28,6 +28,7 @@ CatchAllCommand::CatchAllCommand(){ //initialize outputTypes vector tempOutNames; outputTypes["csv"] = tempOutNames; + outputTypes["summary"] = tempOutNames; } catch(exception& e) { m->errorOut(e, "CatchAllCommand", "CatchAllCommand"); @@ -86,6 +87,7 @@ CatchAllCommand::CatchAllCommand(string option) { //initialize outputTypes vector tempOutNames; outputTypes["csv"] = tempOutNames; + outputTypes["summary"] = 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); @@ -203,6 +205,7 @@ int CatchAllCommand::execute() { outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv"); outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv"); + createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel()); if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str()); } delete read; delete input; globaldata->ginput = NULL; delete sabund; return 0; } @@ -238,6 +241,8 @@ int CatchAllCommand::execute() { outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv"); outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv"); + createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel()); + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str()); } delete read; delete input; globaldata->ginput = NULL; delete sabund; return 0; } processedLabels.insert(sabund->getLabel()); @@ -291,7 +296,9 @@ int CatchAllCommand::execute() { outputNames.push_back(filename + "_Analysis.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv"); outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv"); outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv"); - outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv"); + outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv"); + + createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel()); delete sabund; } @@ -340,6 +347,55 @@ string CatchAllCommand::process(SAbundVector* sabund) { exit(1); } } +//********************************************************************************************************************** +string CatchAllCommand::createSummaryFile(string file1, string label) { + try { + string filename = outputDir + m->getRootName(m->getSimpleName(sabundfile)) + label + ".catchall.summary"; + filename = m->getFullPathName(filename); + outputNames.push_back(filename); outputTypes["summary"].push_back(filename); + + ofstream out; + m->openOutputFile(filename, out); + + out << "group\tmodel\testimate\tlci\tuci" << endl; + + ifstream in; + m->openInputFile(file1, in); + + if (!in.eof()) { + + string header = m->getline(in); m->gobble(in); + + int pos = header.find("Total Number of Observed Species ="); + cout << pos << '\t' << header.length() << endl; exit(1); + if (pos == string::npos) { m->mothurOut("[ERROR]: cannot parse " + file1); m->mothurOutEndLine(); } + else { + //pos will be the position of the T in total, so we want to count to the position of = + pos += 34; + char c=header[pos]; + string numString = ""; + while (c != ','){ + if (c != ' ') { + numString += c; + } + } + + int numOtus; convert(numString, numOtus); + cout << numOtus << endl; + } + } + + in.close(); + out.close(); + + return filename; + + } + catch(exception& e) { + m->errorOut(e, "CatchAllCommand", "createSummaryFile"); + exit(1); + } +} /**************************************************************************************/