//if the user changes the output directory command factory will send this info to us in the output parameter
- outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
+ outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = hasPath(inputFile); }
string temp;
temp = validParameter.validFile(parameters, "version", false); if (temp == "not found"){ temp = "F"; }
string path = globaldata->argv;
path = path.substr(0, (path.find_last_of('m')));
- string clearcutCommand = "";
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- clearcutCommand = path + "clearcut/clearcut ";
- #else
- clearcutCommand = path + "clearcut\\clearcut ";
- #endif
-
+ string clearcutCommand = path + "clearcut ";
+
//you gave us a distance matrix
if (phylipfile != "") { clearcutCommand += "--distance "; }
InteractEngine::InteractEngine(string path){
globaldata = GlobalData::getInstance();
- globaldata->argv = path;
+ string temppath = path.substr(0, (path.find_last_of('m')));
+
+ //this will happen if you set the path variable to contain mothur's exe location
+ if (temppath == "") {
+
+ string envPath = getenv("PATH");
+
+ //delimiting path char
+ char delim;
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ delim = ':';
+ #else
+ delim = ';';
+ #endif
+
+ //break apart path variable by ':'
+ vector<string> dirs;
+ splitAtChar(envPath, dirs, delim);
+
+ //get path related to mothur
+ string mothurPath = "";
+ for (int i = 0; i < dirs.size(); i++) {
+ //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; }
+ }
+
+ //add mothur so it looks like what argv would look like
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ mothurPath += "/mothur";
+ #else
+ mothurPath += "\\mothur";
+ #endif
+
+ path = mothurPath;
+ }
+
+ globaldata->argv = path;
}
/***********************************************************************/
globaldata = GlobalData::getInstance();
openedBatch = openInputFile(batchFileName, inputBatchFile);
+
+ string temppath = path.substr(0, (path.find_last_of('m')));
+
+ //this will happen if you set the path variable to contain mothur's exe location
+ if (temppath == "") {
+
+ string envPath = getenv("PATH");
+
+ //delimiting path char
+ char delim;
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ delim = ':';
+ #else
+ delim = ';';
+ #endif
+
+ //break apart path variable by ':'
+ vector<string> dirs;
+ splitAtChar(envPath, dirs, delim);
+
+ //get path related to mothur
+ string mothurPath = "";
+ for (int i = 0; i < dirs.size(); i++) {
+ //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; }
+ }
+
+ //add mothur so it looks like what argv would look like
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ mothurPath += "/mothur";
+ #else
+ mothurPath += "\\mothur";
+ #endif
+
+ path = mothurPath;
+ }
+
globaldata->argv = path;
}
//remove quotes
listOfCommands = commandString.substr(1, (commandString.length()-1));
+
+ string temppath = path.substr(0, (path.find_last_of('m')));
+
+ //this will happen if you set the path variable to contain mothur's exe location
+ if (temppath == "") {
+
+ string envPath = getenv("PATH");
+
+ //delimiting path char
+ char delim;
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ delim = ':';
+ #else
+ delim = ';';
+ #endif
+
+ //break apart path variable by ':'
+ vector<string> dirs;
+ splitAtChar(envPath, dirs, delim);
+
+ //get path related to mothur
+ string mothurPath = "";
+ for (int i = 0; i < dirs.size(); i++) {
+ //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; }
+ }
+
+ //add mothur so it looks like what argv would look like
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ mothurPath += "/mothur";
+ #else
+ mothurPath += "\\mothur";
+ #endif
+
+ path = mothurPath;
+ }
globaldata->argv = path;
}
/***********************************************************************/
+//This function parses the estimator options and puts them in a vector
+inline void splitAtChar(string& estim, vector<string>& container, char symbol) {
+ try {
+ string individual;
+
+ while (estim.find_first_of(symbol) != -1) {
+ individual = estim.substr(0,estim.find_first_of(symbol));
+ if ((estim.find_first_of(symbol)+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+ estim = estim.substr(estim.find_first_of(symbol)+1, estim.length());
+ container.push_back(individual);
+ }
+ }
+ //get last one
+ container.push_back(estim);
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
//This function parses the estimator options and puts them in a vector
inline void splitAtDash(string& estim, vector<string>& container) {
try {
exit(1);
}
}
+
/**************************************************************************************************/
inline bool inUsersGroups(string groupname, vector<string> Groups) {
m->mothurOut("The set.dir command can also be used to override or set the default location mothur will look for files if it is unable to find them, the directory must exist.\n");
m->mothurOut("The set.dir command parameters are input, output and tempdefault and one is required.\n");
m->mothurOut("To return the output to the same directory as the input files you may enter: output=clear.\n");
- m->mothurOut("To return the input to the same directory as the mothur.exe you may enter: input=clear.\n");
+ m->mothurOut("To return the input to the current working directory you may enter: input=clear.\n");
+ m->mothurOut("To set the output to the directory where mothur.exe is located you may enter: output=default.\n");
+ m->mothurOut("To set the input to the directory where mothur.exe is located you may enter: input=default.\n");
m->mothurOut("To return the tempdefault to the default you provided at compile time you may enter: tempdefault=clear.\n");
+ m->mothurOut("To set the tempdefault to the directory where mothur.exe is located you may enter: tempdefault=default.\n");
m->mothurOut("The set.dir command should be in the following format: set.dir(output=yourOutputDirectory, input=yourInputDirectory, tempdefault=yourTempDefault).\n");
m->mothurOut("Example set.outdir(output=/Users/lab/desktop/outputs, input=/Users/lab/desktop/inputs).\n");
m->mothurOut("Note: No spaces between parameter labels (i.e. output), '=' and parameters (i.e.yourOutputDirectory).\n\n");
//redirect output
if ((output == "clear") || (output == "")) { output = ""; commandFactory->setOutputDirectory(output); }
- else {
+ else if (output == "default") {
+ GlobalData* globaldata = GlobalData::getInstance();
+ string exepath = globaldata->argv;
+ output = exepath.substr(0, (exepath.find_last_of('m')));
+
+ m->mothurOut("Changing output directory to " + output); m->mothurOutEndLine();
+ commandFactory->setOutputDirectory(output);
+ }else {
//add / to name if needed
string lastChar = output.substr(output.length()-1);
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
//redirect input
if ((input == "clear") || (input == "")) { input = ""; commandFactory->setInputDirectory(input); }
- else {
+ else if (input == "default") {
+ GlobalData* globaldata = GlobalData::getInstance();
+ string exepath = globaldata->argv;
+ input = exepath.substr(0, (exepath.find_last_of('m')));
+
+ m->mothurOut("Changing input directory to " + input); m->mothurOutEndLine();
+ commandFactory->setInputDirectory(input);
+ }else {
//add / to name if needed
string lastChar = input.substr(input.length()-1);
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
m->setDefaultPath(temp);
#endif
}else if (tempdefault == "") { //do nothing
+ }else if (tempdefault == "default") {
+ GlobalData* globaldata = GlobalData::getInstance();
+ string exepath = globaldata->argv;
+ tempdefault = exepath.substr(0, (exepath.find_last_of('m')));
+
+ m->mothurOut("Changing default directory to " + tempdefault); m->mothurOutEndLine();
+ m->setDefaultPath(tempdefault);
}else {
//add / to name if needed
string lastChar = tempdefault.substr(tempdefault.length()-1);
#include "command.hpp"
#include "commandfactory.hpp"
+#include "globaldata.hpp"
/**********************************************************/