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
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<string> inputFileNames;
if (sharedfile != "") { inputFileNames = parseSharedFile(sharedfile); }
string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "catchall.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);
ifstream in;
uchimeCommand = m->getFullPathName(uchimeCommand);
int ableToOpen = m->openInputFile(uchimeCommand, in, "no error"); in.close();
- if(ableToOpen == 1) { m->mothurOut("[ERROR]: " + uchimeCommand + " file does not exist. mothur requires the uchime executable."); m->mothurOutEndLine(); abort = true; }
- }
+ if(ableToOpen == 1) {
+ m->mothurOut(uchimeCommand + " file does not exist. Checking path... \n");
+ //check to see if uchime is in the path??
+
+ string uLocation = m->findProgramPath("uchime");
+
+
+ ifstream in2;
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ ableToOpen = m->openInputFile(uLocation, in2, "no error"); in2.close();
+#else
+ ableToOpen = m->openInputFile((uLocation + ".exe"), in2, "no error"); in2.close();
+#endif
+
+ if(ableToOpen == 1) { m->mothurOut("[ERROR]: " + uLocation + " file does not exist. mothur requires the uchime executable."); m->mothurOutEndLine(); abort = true; }
+ else { m->mothurOut("Found uchime in your path, using " + uLocation + "\n");uchimeLocation = uLocation; }
+ }else { uchimeLocation = uchimeCommand; }
+
+ uchimeLocation = m->getFullPathName(uchimeLocation);
+ }
}
catch(exception& e) {
m->errorOut(e, "ChimeraSlayerCommand", "ChimeraSlayerCommand");
vector<char*> cPara;
- string path = m->argv;
- string tempPath = path;
- for (int i = 0; i < path.length(); i++) { tempPath[i] = tolower(path[i]); }
- path = path.substr(0, (tempPath.find_last_of('m')));
-
- string uchimeCommand = path;
+ string uchimeCommand = uchimeLocation;
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
- uchimeCommand += "uchime ";
+ uchimeCommand += " ";
#else
- uchimeCommand += "uchime";
uchimeCommand = "\"" + uchimeCommand + "\"";
#endif
#else
commandString = "\"" + commandString + "\"";
#endif
+ if (m->debug) { m->mothurOut("[DEBUG]: uchime command = " + commandString + ".\n"); }
system(commandString.c_str());
//free memory
// Allocate memory for thread data.
string extension = toString(i) + ".temp";
- uchimeData* tempUchime = new uchimeData(outputFileName+extension, templatefile, files[i], "", "", "", accnos+extension, alns+extension, dummy, m, 0, 0, i);
+ uchimeData* tempUchime = new uchimeData(outputFileName+extension, uchimeLocation, templatefile, files[i], "", "", "", accnos+extension, alns+extension, dummy, m, 0, 0, i);
tempUchime->setBooleans(useAbskew, chimealns, useMinH, useMindiv, useXn, useDn, useXa, useChunks, useMinchunk, useIdsmoothwindow, useMinsmoothid, useMaxp, skipgaps, skipgaps2, useMinlen, useMaxlen, ucl, useQueryfract);
tempUchime->setVariables(abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract);
// Allocate memory for thread data.
string extension = toString(i) + ".temp";
- uchimeData* tempUchime = new uchimeData(outputFName+extension, templatefile, filename+extension, fastaFile, nameFile, groupFile, accnos+extension, alns+extension, groups, m, lines[i].start, lines[i].end, i);
+ uchimeData* tempUchime = new uchimeData(outputFName+extension, uchimeLocation, templatefile, filename+extension, fastaFile, nameFile, groupFile, accnos+extension, alns+extension, groups, m, lines[i].start, lines[i].end, i);
tempUchime->setBooleans(useAbskew, chimealns, useMinH, useMindiv, useXn, useDn, useXa, useChunks, useMinchunk, useIdsmoothwindow, useMinsmoothid, useMaxp, skipgaps, skipgaps2, useMinlen, useMaxlen, ucl, useQueryfract);
tempUchime->setVariables(abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract);
int createProcesses(string, string, string, string, int&);
bool abort, useAbskew, chimealns, useMinH, useMindiv, useXn, useDn, useXa, useChunks, useMinchunk, useIdsmoothwindow, useMinsmoothid, useMaxp, skipgaps, skipgaps2, useMinlen, useMaxlen, ucl, useQueryfract;
- string fastafile, groupfile, templatefile, outputDir, namefile, abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract;
+ string fastafile, groupfile, templatefile, outputDir, namefile, abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract, uchimeLocation;
int processors;
string namefile;
string groupfile;
string outputFName;
- string accnos, alns, filename, templatefile;
+ string accnos, alns, filename, templatefile, uchimeLocation;
MothurOut* m;
int start;
int end;
string abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract;
uchimeData(){}
- uchimeData(string o, string t, string file, string f, string n, string g, string ac, string al, vector<string> gr, MothurOut* mout, int st, int en, int tid) {
+ uchimeData(string o, string uloc, string t, string file, string f, string n, string g, string ac, string al, vector<string> gr, MothurOut* mout, int st, int en, int tid) {
fastafile = f;
namefile = n;
groupfile = g;
groups = gr;
count = 0;
numChimeras = 0;
+ uchimeLocation = uloc;
}
void setBooleans(bool Abskew, bool calns, bool MinH, bool Mindiv, bool Xn, bool Dn, bool Xa, bool Chunks, bool Minchunk, bool Idsmoothwindow, bool Minsmoothid, bool Maxp, bool skipgap, bool skipgap2, bool Minlen, bool Maxlen, bool uc, bool Queryfract) {
useAbskew = Abskew;
vector<char*> cPara;
- string path = pDataArray->m->argv;
- string tempPath = path;
- for (int j = 0; j < path.length(); j++) { tempPath[j] = tolower(path[j]); }
- path = path.substr(0, (tempPath.find_last_of('m')));
-
- string uchimeCommand = path;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
- uchimeCommand += "uchime ";
-#else
- uchimeCommand += "uchime";
- uchimeCommand = "\"" + uchimeCommand + "\"";
-#endif
+ string uchimeCommand = pDataArray->uchimeLocation;
+ uchimeCommand = "\"" + uchimeCommand + "\"";
char* tempUchime;
tempUchime= new char[uchimeCommand.length()+1];
//uchime_main(numArgs, uchimeParameters);
//cout << "commandString = " << commandString << endl;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
commandString = "\"" + commandString + "\"";
-#endif
+
+ if (pDataArray->m->debug) { pDataArray->m->mothurOut("[DEBUG]: uchime command = " + commandString + ".\n"); }
+
system(commandString.c_str());
//free memory
vector<char*> cPara;
- char* tempUchime;
- tempUchime= new char[8];
- *tempUchime = '\0';
- strncat(tempUchime, "uchime ", 7);
- cPara.push_back(tempUchime);
+ string uchimeCommand = pDataArray->uchimeLocation;
+ uchimeCommand = "\"" + uchimeCommand + "\"";
+
+ char* tempUchime;
+ tempUchime= new char[uchimeCommand.length()+1];
+ *tempUchime = '\0';
+ strncat(tempUchime, uchimeCommand.c_str(), uchimeCommand.length());
+ cPara.push_back(tempUchime);
char* tempIn = new char[8];
*tempIn = '\0'; strncat(tempIn, "--input", 7);
//uchime_main(numArgs, uchimeParameters);
//cout << "commandString = " << commandString << endl;
+ if (pDataArray->m->debug) { pDataArray->m->mothurOut("[DEBUG]: uchime command = " + commandString + ".\n"); }
system(commandString.c_str());
//free memory
}
}
/***********************************************************************/
-string Engine::findMothursPath(){
- try {
-
- string envPath = getenv("PATH");
- string mothurPath = "";
-
- //delimiting path char
- char delim;
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
- delim = ':';
- #else
- delim = ';';
- #endif
-
- //break apart path variable by ':'
- vector<string> dirs;
- mout->splitAtChar(envPath, dirs, delim);
-
- if (mout->debug) { mout->mothurOut("[DEBUG]: dir's in path: \n"); }
-
- //get path related to mothur
- for (int i = 0; i < dirs.size(); i++) {
-
- if (mout->debug) { mout->mothurOut("[DEBUG]: " + dirs[i] + "\n"); }
-
- //to lower so we can find it
- string tempLower = "";
- for (int j = 0; j < dirs[i].length(); j++) { tempLower += tolower(dirs[i][j]); }
-
- //is this mothurs path?
- if (tempLower.find("mothur") != -1) { mothurPath = dirs[i]; break; }
- }
-
- if (mout->debug) { mout->mothurOut("[DEBUG]: mothurPath = " + mothurPath + "\n"); }
-
- if (mothurPath != "") {
- //add mothur so it looks like what argv would look like
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
- mothurPath += "/mothur";
- #else
- mothurPath += "\\mothur";
- #endif
- }else {
- //okay mothur is not in the path, so the folder mothur is in must be in the path
- //lets find out which one
-
- //get path related to mothur
- for (int i = 0; i < dirs.size(); i++) {
-
- //is this mothurs path?
- ifstream in;
- string tempIn = dirs[i];
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
- tempIn += "/mothur";
- #else
- tempIn += "\\mothur";
- #endif
- mout->openInputFile(tempIn, in, "");
-
- //if this file exists
- if (in) { in.close(); mothurPath = tempIn; break; if (mout->debug) { mout->mothurOut("[DEBUG]: found it, mothurPath = " + mothurPath + "\n"); } }
- }
- }
-
- return mothurPath;
-
- }
- catch(exception& e) {
- mout->errorOut(e, "Engine", "findMothursPath");
- exit(1);
- }
-}
+
/***********************************************************************/
InteractEngine::InteractEngine(string path){
string temppath = path.substr(0, (path.find_last_of("othur")-5));
//this will happen if you set the path variable to contain mothur's exe location
- if (temppath == "") { path = findMothursPath(); }
+ if (temppath == "") { path = mout->findProgramPath("mothur"); }
mout->argv = path;
}
string temppath = path.substr(0, (path.find_last_of("othur")-5));
//this will happen if you set the path variable to contain mothur's exe location
- if (temppath == "") { path = findMothursPath(); }
+ if (temppath == "") { path = mout->findProgramPath("mothur"); }
mout->argv = path;
string temppath = path.substr(0, (path.find_last_of("othur")-5));
//this will happen if you set the path variable to contain mothur's exe location
- if (temppath == "") { path = findMothursPath(); }
+ if (temppath == "") { path = mout->findProgramPath("mothur"); }
mout->argv = path;
vector<string> options;
CommandFactory* cFactory;
MothurOut* mout;
- string findMothursPath();
};
exit(1);
}
}
+/***********************************************************************/
+string MothurOut::findProgramPath(string programName){
+ try {
+
+ string envPath = getenv("PATH");
+ string pPath = "";
+
+ //delimiting path char
+ char delim;
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ delim = ':';
+#else
+ delim = ';';
+#endif
+
+ //break apart path variable by ':'
+ vector<string> dirs;
+ splitAtChar(envPath, dirs, delim);
+
+ if (debug) { mothurOut("[DEBUG]: dir's in path: \n"); }
+
+ //get path related to mothur
+ for (int i = 0; i < dirs.size(); i++) {
+
+ if (debug) { mothurOut("[DEBUG]: " + dirs[i] + "\n"); }
+
+ //to lower so we can find it
+ string tempLower = "";
+ for (int j = 0; j < dirs[i].length(); j++) { tempLower += tolower(dirs[i][j]); }
+
+ //is this mothurs path?
+ if (tempLower.find(programName) != -1) { pPath = dirs[i]; break; }
+ }
+
+ if (debug) { mothurOut("[DEBUG]: programPath = " + pPath + "\n"); }
+
+ if (pPath != "") {
+ //add programName so it looks like what argv would look like
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ pPath += "/" + programName;
+#else
+ pPath += "\\" + programName;
+#endif
+ }else {
+ //okay programName is not in the path, so the folder programName is in must be in the path
+ //lets find out which one
+
+ //get path related to the program
+ for (int i = 0; i < dirs.size(); i++) {
+
+ if (debug) { mothurOut("[DEBUG]: looking in " + dirs[i] + " for " + programName + " \n"); }
+
+ //is this the programs path?
+ ifstream in;
+ string tempIn = dirs[i];
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ tempIn += "/" + programName;
+#else
+ tempIn += "\\" + programName;
+#endif
+ openInputFile(tempIn, in, "");
+
+ //if this file exists
+ if (in) { in.close(); pPath = tempIn; if (debug) { mothurOut("[DEBUG]: found it, programPath = " + pPath + "\n"); } break; }
+ }
+ }
+
+ return pPath;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "findProgramPath");
+ exit(1);
+ }
+}
/*********************************************************************************************/
void MothurOut::setFileName(string filename) {
try {
int appendFiles(string, string);
int renameFile(string, string); //oldname, newname
string getFullPathName(string);
+ string findProgramPath(string programName);
string hasPath(string);
string getExtension(string);
string getPathName(string);