Permalink
Browse files

Merge pull request #266 from mothur/Blast_223

Blast 223
  • Loading branch information...
2 parents 6f2cf2e + 2ee0071 commit bfc09feb1887ce07d4c489ee7e6b4c2d40eb6bf1 @mothur-westcott mothur-westcott committed on GitHub Aug 15, 2016
@@ -200,8 +200,8 @@ int CatchAllCommand::execute() {
if (abort == true) { if (calledHelp) { return 0; } return 2; }
//get location of catchall
- path = m->argv;
- path = path.substr(0, (path.find_last_of("othur")-5));
+ path = m->mothurProgramPath;
+ //path = path.substr(0, (path.find_last_of("othur")-5));
path = m->getFullPathName(path);
if (m->debug) { m->mothurOut("[DEBUG]: mothur's path = " + path + "\n"); }
@@ -556,10 +556,10 @@ ChimeraUchimeCommand::ChimeraUchimeCommand(string option) {
if (hasGroup && (templatefile != "self")) { m->mothurOut("You have provided a group file and the reference parameter is not set to self. I am not sure what reference you are trying to use, aborting."); m->mothurOutEndLine(); abort=true; }
//look for uchime exe
- 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')));
+ path = m->mothurProgramPath;
+ //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;
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
@@ -510,10 +510,10 @@ ChimeraVsearchCommand::ChimeraVsearchCommand(string option) {
if (hasGroup && (templatefile != "self")) { m->mothurOut("You have provided a group file and the reference parameter is not set to self. I am not sure what reference you are trying to use, aborting."); m->mothurOutEndLine(); abort=true; }
//look for uchime exe
- 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')));
+ path = m->mothurProgramPath;
+ //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 vsearchCommand;
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
@@ -371,11 +371,11 @@ int ClusterCommand::execute(){
int ClusterCommand::runVsearchCluster(){
try {
- //look for uchime exe
- 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')));
+ //look for vsearch exe
+ string path = m->mothurProgramPath;
+ //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 vsearchCommand;
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
@@ -1686,10 +1686,10 @@ bool ClusterSplitCommand::findVsearch(){
if (cutoffNotSet) { m->mothurOut("\nYou did not set a cutoff, using 0.03.\n"); cutoff = 0.03; }
//look for uchime exe
- 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 path = m->mothurProgramPath;
+ //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 vsearchCommand;
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
@@ -84,7 +84,7 @@ int GetCommandInfoCommand::execute(){
int numNonHidden = 0;
- out << "mothurLocation=" << m->getFullPathName(m->argv) << endl;
+ out << "mothurLocation=" << m->getFullPathName(m->mothurProgramPath) << endl;
out << "mothurVersion=" << m->getVersion() << endl;
map<string, string> commands = commandFactory->getListCommands();
@@ -2981,10 +2981,10 @@ vector< vector<string> > MakeContigsCommand::readFileNames(string filename){
}
//look for mothur exe
- string mpath = m->argv;
- string tempPath = mpath;
- for (int i = 0; i < mpath.length(); i++) { tempPath[i] = tolower(mpath[i]); }
- mpath = mpath.substr(0, (tempPath.find_last_of('m')));
+ string mpath = m->mothurProgramPath;
+ //string tempPath = mpath;
+ //for (int i = 0; i < mpath.length(); i++) { tempPath[i] = tolower(mpath[i]); }
+ //mpath = mpath.substr(0, (tempPath.find_last_of('m')));
//check to make sure both are able to be opened
ifstream in2;
@@ -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;
@@ -293,10 +293,10 @@ SffMultipleCommand::SffMultipleCommand(string option) {
temp = validParameter.validFile(parameters, "lookup", true);
if (temp == "not found") {
- 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 path = m->mothurProgramPath;
+ //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')));
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
path += "lookupFiles/";
@@ -311,10 +311,10 @@ SffMultipleCommand::SffMultipleCommand(string option) {
lookupFileName = validParameter.validFile(parameters, "lookup", false);
//if you can't open it its not inputDir, try mothur excutable location
- string exepath = m->argv;
- 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')));
+ string exepath = m->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')));
string tryPath = m->getFullPathName(exepath) + m->getSimpleName(lookupFileName);
m->mothurOut("Unable to open " + lookupFileName + ". Trying mothur's executable location " + tryPath); m->mothurOutEndLine();
@@ -231,10 +231,10 @@ ShhherCommand::ShhherCommand(string option) {
//if you can't open it its not in current working directory or inputDir, try mothur excutable location
if (ableToOpen == 1) {
- string exepath = m->argv;
- 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')));
+ string exepath = m->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')));
string tryPath = m->getFullPathName(exepath) + m->getSimpleName(fName);
m->mothurOut("Unable to open " + fName + ". Trying mothur's executable location " + tryPath); m->mothurOutEndLine();
@@ -261,10 +261,10 @@ ShhherCommand::ShhherCommand(string option) {
string temp;
temp = validParameter.validFile(parameters, "lookup", true);
if (temp == "not found") {
- 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 path = m->mothurProgramPath;
+ //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')));
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
path += "lookupFiles/";
@@ -304,10 +304,10 @@ ShhherCommand::ShhherCommand(string option) {
//if you can't open it its not in current working directory or inputDir, try mothur excutable location
if (ableToOpen == 1) {
- string exepath = m->argv;
- 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')));
+ string exepath = m->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')));
string tryPath = m->getFullPathName(exepath) + m->getSimpleName(lookupFileName);
m->mothurOut("Unable to open " + lookupFileName + ". Trying mothur's executable location " + tryPath); m->mothurOutEndLine();
@@ -324,10 +324,10 @@ ShhherCommand::ShhherCommand(string option) {
lookupFileName = validParameter.validFile(parameters, "lookup", false);
//if you can't open it its not inputDir, try mothur excutable location
- string exepath = m->argv;
- 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')));
+ string exepath = m->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')));
string tryPath = m->getFullPathName(exepath) + m->getSimpleName(lookupFileName);
m->mothurOut("Unable to open " + lookupFileName + ". Trying mothur's executable location " + tryPath); m->mothurOutEndLine();
@@ -22,8 +22,7 @@ BlastAlignment::BlastAlignment(float go, float ge, float ma, float mm) :
match(ma), // This is the score to award for two nucleotides matching (match >= 0)
mismatch(mm) // This is the penalty to assess for a mismatch (mismatch <= 0)
{
- path = m->argv;
- path = path.substr(0, (path.find_last_of('m')));
+ path = m->getBlastPath();
gapOpen = abs(go); // This is the penalty to assess for opening a gap (gapOpen >= 0)
gapExtend = abs(ge); // This is the penalty to assess for extending a gap (gapExtend >= 0)
@@ -33,10 +33,10 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
//make sure blast exists in the write place
if (path == "") {
- 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')));
+ path = m->getBlastPath();
+ //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')));
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
path += "blast/bin/";
@@ -87,7 +87,7 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
megablastCommand = m->getFullPathName(megablastCommand);
ableToOpen = m->openInputFile(megablastCommand, in3, "no error"); in3.close();
if(ableToOpen == 1) { m->mothurOut("[ERROR]: " + megablastCommand + " file does not exist. mothur requires megablast.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
-
+
}
catch(exception& e) {
m->errorOut(e, "BlastDB", "BlastDB");
@@ -105,10 +105,10 @@ BlastDB::BlastDB(string b, int tid) : Database() {
//make sure blast exists in the write place
if (path == "") {
- 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')));
+ path = m->getBlastPath();
+ //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')));
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
path += "blast/bin/";
Oops, something went wrong.

0 comments on commit bfc09fe

Please sign in to comment.