X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=catchallcommand.cpp;h=1cfd4154686cd4884e275f4c3ea8c8ca3d5624d3;hb=f06b339c5fc4b6d1b9d2a08fe16bf7670bf7aeb4;hp=cc99e6d992cb182f7495e412b674298a643981f6;hpb=4f3d46bdb42c23468a534486fd105180b030fc65;p=mothur.git diff --git a/catchallcommand.cpp b/catchallcommand.cpp index cc99e6d..1cfd415 100644 --- a/catchallcommand.cpp +++ b/catchallcommand.cpp @@ -49,6 +49,27 @@ string CatchAllCommand::getHelpString(){ } } //********************************************************************************************************************** +string CatchAllCommand::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 == "csv") { outputFileName = "csv"; } + else if (type == "summary") { outputFileName = "catchall.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, "CatchAllCommand", "getOutputFileNameTag"); + exit(1); + } +} +//********************************************************************************************************************** CatchAllCommand::CatchAllCommand(){ try { abort = true; calledHelp = true; @@ -175,16 +196,14 @@ int CatchAllCommand::execute() { path = m->getFullPathName(path); if (m->debug) { m->mothurOut("[DEBUG]: mothur's path = " + path + "\n"); } - + savedOutputDir = outputDir; string catchAllCommandExe = ""; string catchAllTest = ""; #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) - catchAllCommandExe += "mono " + path + "CatchAllcmdL.exe "; if (outputDir == "") { outputDir = "./"; } //force full pathname to be created for catchall, this is necessary because if catchall is in the path it will look for input file whereever the exe is and not the cwd. catchAllTest = path + "CatchAllcmdL.exe"; #else - catchAllCommandExe += "\"" + path + "CatchAllcmdW.exe\"" + " "; if (outputDir == "") { outputDir = ".\\"; } //force full pathname to be created for catchall, this is necessary because if catchall is in the path it will look for input file whereever the exe is and not the cwd. catchAllTest = path + "CatchAllcmdW.exe"; #endif @@ -193,12 +212,34 @@ int CatchAllCommand::execute() { ifstream in; catchAllTest = m->getFullPathName(catchAllTest); int ableToOpen = m->openInputFile(catchAllTest, in, "no error"); in.close(); - if(ableToOpen == 1) { m->mothurOut("[ERROR]: " + catchAllTest + " file does not exist. mothur requires the catchall executable to run the catchall command."); m->mothurOutEndLine(); m->control_pressed = true; return 0; } + if(ableToOpen == 1) { + m->mothurOut(catchAllTest + " file does not exist. Checking path... \n"); + //check to see if uchime is in the path?? + + string programName = "CatchAllcmdW.exe"; +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) + programName = "CatchAllcmdL.exe"; +#endif + string cLocation = m->findProgramPath(programName); + + ifstream in2; + ableToOpen = m->openInputFile(cLocation, in2, "no error"); in2.close(); + + if(ableToOpen == 1) { m->mothurOut("[ERROR]: " + cLocation + " file does not exist. mothur requires the catchall executable."); m->mothurOutEndLine(); return 0; } + else { m->mothurOut("Found catchall in your path, using " + cLocation + "\n"); catchAllTest = cLocation; } + } + catchAllTest = m->getFullPathName(catchAllTest); + +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) + catchAllCommandExe += "mono " + catchAllTest + " "; +#else + catchAllCommandExe += "\"" + catchAllTest + "\" "; +#endif //prepare full output directory outputDir = m->getFullPathName(outputDir); - if (m->debug) { m->mothurOut("[DEBUG]: catchall location = " + catchAllCommandExe + ".\n [DEBUG]: outputDir = " + outputDir + ".\n"); } + if (m->debug) { m->mothurOut("[DEBUG]: catchall location = " + catchAllCommandExe + "\n[DEBUG]: outputDir = " + outputDir + "\n"); } vector inputFileNames; if (sharedfile != "") { inputFileNames = parseSharedFile(sharedfile); } @@ -216,10 +257,10 @@ int CatchAllCommand::execute() { set processedLabels; set userLabels = labels; - string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "catchall.summary"; + string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + getOutputFileNameTag("summary"); summaryfilename = m->getFullPathName(summaryfilename); - if (m->debug) { m->mothurOut("[DEBUG]: Input File = " + inputFileNames[p] + ".\n [DEBUG]: inputdata address = " + toString(&input) + ".\n [DEBUG]: sabund address = " + toString(&sabund) + ".\n"); } + if (m->debug) { m->mothurOut("[DEBUG]: Input File = " + inputFileNames[p] + ".\n[DEBUG]: inputdata address = " + toString(&input) + ".\n[DEBUG]: sabund address = " + toString(&sabund) + ".\n"); } ofstream out; m->openOutputFile(summaryfilename, out); @@ -263,10 +304,10 @@ int CatchAllCommand::execute() { filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra . if (savedOutputDir == "") { filename = m->getSimpleName(filename); } - 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 + "_Analysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_Analysis." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); } @@ -316,10 +357,10 @@ int CatchAllCommand::execute() { filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra . if (savedOutputDir == "") { filename = m->getSimpleName(filename); } - 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 + "_Analysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_Analysis." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); } @@ -390,11 +431,10 @@ int CatchAllCommand::execute() { filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra . if (savedOutputDir == "") { filename = m->getSimpleName(filename); } - 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"); - if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); } + outputNames.push_back(filename + "_Analysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_Analysis." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); + outputNames.push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); } createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out); @@ -471,7 +511,7 @@ string CatchAllCommand::combineSummmary(vector& outputNames) { try { ofstream out; - string combineFileName = savedOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "catchall.summary"; + string combineFileName = savedOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary"); //open combined file m->openOutputFile(combineFileName, out);