Permalink
Browse files

Adds blastdir parameter to set.dir

  • Loading branch information...
1 parent 6f2cf2e commit 3c6e19ebed386d33570fd45882e1f22086a2c886 @mothur-westcott mothur-westcott committed Aug 15, 2016
Showing with 60 additions and 16 deletions.
  1. +30 −9 source/commands/setdircommand.cpp
  2. +1 −1 source/commands/setdircommand.h
  3. +23 −2 source/mothurout.cpp
  4. +6 −4 source/mothurout.h
@@ -13,6 +13,7 @@
vector<string> SetDirectoryCommand::setParameters(){
try {
CommandParameter ptempdefault("tempdefault", "String", "", "", "", "", "","",false,false); parameters.push_back(ptempdefault);
+ CommandParameter pblast("blastdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pblast);
CommandParameter pdebug("debug", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pdebug);
CommandParameter pseed("seed", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pseed);
CommandParameter pmodnames("modifynames", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pmodnames);
@@ -37,6 +38,7 @@ string SetDirectoryCommand::getHelpString(){
helpString += "The set.dir command can be used to direct the output files generated by mothur to a specific place, the directory must exist.\n";
helpString += "The set.dir command can also be used to specify the directory where your input files are located, the directory must exist.\n";
helpString += "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";
+ helpString += "The set.dir command can also be used to set the location of the blast directory if other than mothur's executable location, the directory must exist.\n";
helpString += "The set.dir command can also be used to run mothur in debug mode.\n";
helpString += "The set.dir command can also be used to seed random.\n";
helpString += "The set.dir command can also be used to set the modifynames parameter. Default=t, meaning if your sequence names contain ':' change them to '_' to avoid issues while making trees. modifynames=F will leave sequence names as they are.\n";
@@ -45,6 +47,7 @@ string SetDirectoryCommand::getHelpString(){
helpString += "To seed random set seed=yourRandomValue. By default mothur seeds random with the start time.\n";
helpString += "To return the output to the same directory as the input files you may enter: output=clear.\n";
helpString += "To return the input to the current working directory you may enter: input=clear.\n";
+ helpString += "To set the blast location to the directory where the blast executables are located you may enter: blastdir=yourBlastLocation.\n";
helpString += "To set the output to the directory where mothur.exe is located you may enter: output=default.\n";
helpString += "To set the input to the directory where mothur.exe is located you may enter: input=default.\n";
helpString += "To return the tempdefault to the default you provided at compile time you may enter: tempdefault=clear.\n";
@@ -90,6 +93,9 @@ SetDirectoryCommand::SetDirectoryCommand(string option) {
tempdefault = validParameter.validFile(parameters, "tempdefault", false);
if (tempdefault == "not found") { tempdefault = ""; }
+ blastLocation = validParameter.validFile(parameters, "blastdir", false);
+ if (blastLocation == "not found") { blastLocation = ""; }
+
bool debug = false;
bool nodebug = false;
debugorSeedOnly = false;
@@ -118,9 +124,9 @@ SetDirectoryCommand::SetDirectoryCommand(string option) {
m->mothurOut("Setting random seed to " + toString(random) + ".\n\n");
}
- if ((input == "") && (output == "") && (tempdefault == "") && nodebug && nomod && !seed) {
- m->mothurOut("[ERROR]: You must provide either an input, output, tempdefault, debug or modifynames for the set.dir command."); m->mothurOutEndLine(); abort = true;
- }else if((input == "") && (output == "") && (tempdefault == "")) { debugorSeedOnly = true; }
+ if ((input == "") && (output == "") && (tempdefault == "") && (blastLocation == "") && nodebug && nomod && !seed) {
+ m->mothurOut("[ERROR]: You must provide either an input, output, tempdefault, blastdir, debug or modifynames for the set.dir command."); m->mothurOutEndLine(); abort = true;
+ }else if((input == "") && (output == "") && (tempdefault == "") && (blastLocation == "")) { debugorSeedOnly = true; }
}
}
catch(exception& e) {
@@ -143,8 +149,8 @@ int SetDirectoryCommand::execute(){
//redirect output
if ((output == "clear") || (output == "")) { output = ""; commandFactory->setOutputDirectory(output); }
else if (output == "default") {
- string exepath = m->argv;
- output = exepath.substr(0, (exepath.find_last_of('m')));
+ string output = m->mothurProgramPath;
+ //output = exepath.substr(0, (exepath.find_last_of('m')));
m->mothurOut("outputDir=" + output); m->mothurOutEndLine();
commandFactory->setOutputDirectory(output);
@@ -158,8 +164,8 @@ int SetDirectoryCommand::execute(){
//redirect input
if ((input == "clear") || (input == "")) { input = ""; commandFactory->setInputDirectory(input); }
else if (input == "default") {
- string exepath = m->argv;
- input = exepath.substr(0, (exepath.find_last_of('m')));
+ string input = m->mothurProgramPath;
+ //input = exepath.substr(0, (exepath.find_last_of('m')));
m->mothurOut("inputDir=" + input); m->mothurOutEndLine();
commandFactory->setInputDirectory(input);
@@ -183,8 +189,8 @@ int SetDirectoryCommand::execute(){
#endif
}else if (tempdefault == "") { //do nothing
}else if (tempdefault == "default") {
- string exepath = m->argv;
- tempdefault = exepath.substr(0, (exepath.find_last_of('m')));
+ string tempdefault = m->mothurProgramPath;
+ //tempdefault = exepath.substr(0, (exepath.find_last_of('m')));
m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();
m->setDefaultPath(tempdefault);
@@ -194,6 +200,21 @@ int SetDirectoryCommand::execute(){
m->setDefaultPath(tempdefault);
}
}
+
+ //set default
+ if (blastLocation == "") { //do nothing }
+ }else if ((blastLocation == "default") || (blastLocation == "clear")){
+ string blastLocation = m->mothurProgramPath;
+
+ m->mothurOut("Blast Location=" + blastLocation); m->mothurOutEndLine();
+ m->setBlastPath(blastLocation);
+ }else {
+ if (m->dirCheck(blastLocation)) {
+ m->mothurOut("Blast Location=" + blastLocation); m->mothurOutEndLine();
+ m->setBlastPath(blastLocation);
+ }
+ }
+
}
return 0;
}
@@ -36,7 +36,7 @@ class SetDirectoryCommand : public Command {
private:
CommandFactory* commandFactory;
- string output, input, tempdefault;
+ string output, input, tempdefault, blastLocation;
bool abort, debugorSeedOnly, modifyNames;
int random;
vector<string> outputNames;
View
@@ -313,7 +313,7 @@ void MothurOut::setDefaultPath(string pathname) {
if (lastChar != "\\") { pathname += "\\"; }
#endif
- defaultPath = pathname;
+ defaultPath = getFullPathName(pathname);
}
catch(exception& e) {
@@ -322,6 +322,27 @@ void MothurOut::setDefaultPath(string pathname) {
}
}
/*********************************************************************************************/
+void MothurOut::setBlastPath(string pathname) {
+ try {
+
+ //add / to name if needed
+ string lastChar = pathname.substr(pathname.length()-1);
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ if (lastChar != "/") { pathname += "/"; }
+#else
+ if (lastChar != "\\") { pathname += "\\"; }
+#endif
+
+ blastPath = getFullPathName(pathname);
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "setDefaultPath");
+ exit(1);
+ }
+}
+
+/*********************************************************************************************/
void MothurOut::setOutputDir(string pathname) {
try {
outputDir = pathname;
@@ -3884,7 +3905,7 @@ bool MothurOut::checkLocations(string& filename, string inputDir){
//if you can't open it its not in current working directory or inputDir, try mothur excutable location
if (ableToOpen == 1) {
- string exepath = argv;
+ string exepath = mothurProgramPath;
string tempPath = exepath;
for (int i = 0; i < exepath.length(); i++) { tempPath[i] = tolower(exepath[i]); }
exepath = exepath.substr(0, (tempPath.find_last_of('m')));
View
@@ -46,6 +46,8 @@ class MothurOut {
void closeLog();
string getDefaultPath() { return defaultPath; }
void setDefaultPath(string);
+ string getBlastPath() { return blastPath; }
+ void setBlastPath(string);
string getOutputDir() { return outputDir; }
void setOutputDir(string);
@@ -69,7 +71,7 @@ class MothurOut {
vector<string> sharedBinLabelsInFile;
vector<string> currentSharedBinLabels;
vector<string> listBinLabelsInFile;
- string saveNextLabel, argv, sharedHeaderMode, groupMode, testDirectory;
+ string saveNextLabel, mothurProgramPath, sharedHeaderMode, groupMode, testDirectory;
bool printedSharedHeaders, printedListHeaders, commandInputsConvertError, changedSeqNames, modifyNames;
//functions from mothur.h
@@ -193,7 +195,7 @@ class MothurOut {
string makeList(vector<string>&);
bool isSubset(vector<string>, vector<string>); //bigSet, subset
int checkName(string&);
- bool checkGroupName(string name);
+ bool checkGroupName(string name);
map<string, vector<string> > parseClasses(string);
string addUnclassifieds(string tax, int maxlevel, bool probs);
@@ -290,7 +292,7 @@ class MothurOut {
MothurOut( const MothurOut& ); // Disable copy constructor
void operator=( const MothurOut& ); // Disable assignment operator
MothurOut() {
- control_pressed = false; defaultPath="";
+ control_pressed = false; defaultPath=""; blastPath="";
filefile = "";
phylipfile = "";
columnfile = "";
@@ -333,7 +335,7 @@ class MothurOut {
~MothurOut();
string logFileName;
- string defaultPath, outputDir;
+ string defaultPath, outputDir, blastPath;
string releaseDate, version;
string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile, biomfile, filefile;

0 comments on commit 3c6e19e

Please sign in to comment.