]> git.donarmstrong.com Git - mothur.git/commitdiff
added blastlocation to chimera.slayer and fixed issue with clearcut getting current...
authorwestcott <westcott>
Tue, 19 Jul 2011 16:09:58 +0000 (16:09 +0000)
committerwestcott <westcott>
Tue, 19 Jul 2011 16:09:58 +0000 (16:09 +0000)
alignmentdb.cpp
blastdb.cpp
blastdb.hpp
chimeraslayer.cpp
chimeraslayer.h
chimeraslayercommand.cpp
chimeraslayercommand.h
classify.cpp
clearcutcommand.cpp

index 0fd2ac4dca4ff4fcfc770488ab96f40dc21c38d7..7c2916c54970c72f73942db5726fe3a0d8c85655 100644 (file)
@@ -157,7 +157,7 @@ AlignmentDB::AlignmentDB(string fastaFileName, string s, int kmerSize, float gap
                        #endif
                }
                else if(method == "suffix")             {       search = new SuffixDB(numSeqs);                                                         }
-               else if(method == "blast")              {       search = new BlastDB(fastaFileName.substr(0,fastaFileName.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch);   }
+               else if(method == "blast")              {       search = new BlastDB(fastaFileName.substr(0,fastaFileName.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "");       }
                else {
                        m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
                        m->mothurOutEndLine();
@@ -198,7 +198,7 @@ AlignmentDB::AlignmentDB(string s){
                method = s;
                
                if(method == "suffix")          {       search = new SuffixDB();        }
-               else if(method == "blast")      {       search = new BlastDB();         }
+               else if(method == "blast")      {       search = new BlastDB("");               }
                else                                            {       search = new KmerDB();          }
 
                                
index 96770dcd5334afc6ed3d067ea6c7230b7c3edc73..af157203630c68bc8e8cfd0e09a2bcf846e4d33c 100644 (file)
 
 /**************************************************************************************************/
 
-BlastDB::BlastDB(string tag, float gO, float gE, float mm, float mM) : Database(), 
+BlastDB::BlastDB(string tag, float gO, float gE, float mm, float mM, string b) : Database(), 
 gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
        try {
                count = 0;
+               path = b;
 
                int randNumber = rand();
                //int randNumber = 12345;
@@ -31,31 +32,38 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
                blastFileName = tag + pid + toString(randNumber) + ".blast";
                
                //make sure blast exists in the write place
-               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')));
+               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')));
+                       
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       path += "blast/bin/";   
+#else
+                       path += "blast\\bin\\";
+#endif                 
+               }
+               
                
                string formatdbCommand;
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-               formatdbCommand = path + "blast/bin/formatdb";  //      format the database, -o option gives us the ability
+               formatdbCommand = path + "formatdb";    //      format the database, -o option gives us the ability
 #else
-               formatdbCommand = path + "blast\\bin\\formatdb.exe";
-               //wrap entire string in ""
-               //formatdbCommand = "\"" + formatdbCommand + "\"";
+               formatdbCommand = path + "formatdb.exe";
 #endif
                
                //test to make sure formatdb exists
                ifstream in;
                formatdbCommand = m->getFullPathName(formatdbCommand);
                int ableToOpen = m->openInputFile(formatdbCommand, in, "no error"); in.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + formatdbCommand + " file does not exist. mothur requires formatdb.exe to be in the ./blast/bin folder relative to the mothur.exe location."); m->mothurOutEndLine(); m->control_pressed = true; }
+               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + formatdbCommand + " file does not exist. mothur requires formatdb.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
                
                string blastCommand;
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-               blastCommand = path + "blast/bin/blastall";     //      format the database, -o option gives us the ability
+               blastCommand = path + "blastall";       //      format the database, -o option gives us the ability
 #else
-               blastCommand = path + "blast\\bin\\blastall.exe";
+               blastCommand = path + "blastall.exe";
                //wrap entire string in ""
                //blastCommand = "\"" + blastCommand + "\"";
 #endif
@@ -64,23 +72,21 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
                ifstream in2;
                blastCommand = m->getFullPathName(blastCommand);
                ableToOpen = m->openInputFile(blastCommand, in2, "no error"); in2.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + blastCommand + " file does not exist. mothur requires blastall.exe to be in the ./blast/bin folder relative to the mothur.exe location."); m->mothurOutEndLine(); m->control_pressed = true; }
+               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + blastCommand + " file does not exist. mothur requires blastall.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
                
                
                string megablastCommand;
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-               megablastCommand = path + "blast/bin/megablast";        //      format the database, -o option gives us the ability
+               megablastCommand = path + "megablast";  //      format the database, -o option gives us the ability
 #else
-               megablastCommand = path + "blast\\bin\\megablast.exe";
-               //wrap entire string in ""
-               //megablastCommand = "\"" + megablastCommand + "\"";
+               megablastCommand = path + "megablast.exe";
 #endif
                
                //test to make sure formatdb exists
                ifstream in3;
                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 to be in the ./blast/bin folder relative to the mothur.exe location."); m->mothurOutEndLine(); m->control_pressed = true; }
+               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " +  megablastCommand + " file does not exist. mothur requires megablast.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
                
        }
        catch(exception& e) {
@@ -90,10 +96,26 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
 }
 /**************************************************************************************************/
 
-BlastDB::BlastDB() : Database() {
+BlastDB::BlastDB(string b) : Database() {
        try {
                count = 0;
-
+               
+               path = b;
+               
+               //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')));
+                       
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       path += "blast/bin/";   
+#else
+                       path += "blast\\bin\\";
+#endif                 
+               }
+               
                int randNumber = rand();
                string pid = "";
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
@@ -104,17 +126,11 @@ BlastDB::BlastDB() : Database() {
                queryFileName = pid + toString(randNumber) + ".candidate.unaligned.fasta";
                blastFileName = pid + toString(randNumber) + ".blast";
                
-               //make sure blast exists in the write place
-               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 formatdbCommand;
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-               formatdbCommand = path + "blast/bin/formatdb";  //      format the database, -o option gives us the ability
+               formatdbCommand = path + "formatdb";    //      format the database, -o option gives us the ability
 #else
-               formatdbCommand = path + "blast\\bin\\formatdb.exe";
+               formatdbCommand = path + "formatdb.exe";
                //wrap entire string in ""
                //formatdbCommand = "\"" + formatdbCommand + "\"";
 #endif
@@ -123,13 +139,13 @@ BlastDB::BlastDB() : Database() {
                ifstream in;
                formatdbCommand = m->getFullPathName(formatdbCommand);
                int ableToOpen = m->openInputFile(formatdbCommand, in, "no error"); in.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " +  formatdbCommand + " file does not exist. mothur requires formatdb.exe to be in the ./blast/bin folder relative to the mothur.exe location."); m->mothurOutEndLine(); m->control_pressed = true; }
+               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " +  formatdbCommand + " file does not exist. mothur requires formatdb.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
                
                string blastCommand;
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-               blastCommand = path + "blast/bin/blastall";     //      format the database, -o option gives us the ability
+               blastCommand = path + "blastall";       //      format the database, -o option gives us the ability
 #else
-               blastCommand = path + "blast\\bin\\blastall.exe";
+               blastCommand = path + "blastall.exe";
                //wrap entire string in ""
                //blastCommand = "\"" + blastCommand + "\"";
 #endif
@@ -138,14 +154,14 @@ BlastDB::BlastDB() : Database() {
                ifstream in2;
                blastCommand = m->getFullPathName(blastCommand);
                ableToOpen = m->openInputFile(blastCommand, in2, "no error"); in2.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + blastCommand + " file does not exist. mothur requires blastall.exe to be in the ./blast/bin folder relative to the mothur.exe location."); m->mothurOutEndLine(); m->control_pressed = true; }
+               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + blastCommand + " file does not exist. mothur requires blastall.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
                
                
                string megablastCommand;
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-               megablastCommand = path + "blast/bin/megablast";        //      format the database, -o option gives us the ability
+               megablastCommand = path + "megablast";  //      format the database, -o option gives us the ability
 #else
-               megablastCommand = path + "blast\\bin\\megablast.exe";
+               megablastCommand = path + "megablast.exe";
                //wrap entire string in ""
                //megablastCommand = "\"" + megablastCommand + "\"";
 #endif
@@ -154,7 +170,7 @@ BlastDB::BlastDB() : Database() {
                ifstream in3;
                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 to be in the ./blast/bin folder relative to the mothur.exe location."); m->mothurOutEndLine(); m->control_pressed = true; }
+               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + megablastCommand + " file does not exist. mothur requires megablast.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
                
                
        }
@@ -208,10 +224,10 @@ vector<int> BlastDB::findClosestSequences(Sequence* seq, int n) {
                string blastCommand;
                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                
-                       blastCommand = path + "blast/bin/blastall -p blastn -d " + dbFileName + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n);
+                       blastCommand = path + "blastall -p blastn -d " + dbFileName + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n);
                        blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber));
                #else
-                       blastCommand =  "\"" + path + "blast\\bin\\blastall\" -p blastn -d " + "\"" + dbFileName + "\"" + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n);
+                       blastCommand =  "\"" + path + "blastall\" -p blastn -d " + "\"" + dbFileName + "\"" + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n);
                        blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber));
                        //wrap entire string in ""
                        blastCommand = "\"" + blastCommand + "\"";
@@ -273,13 +289,13 @@ vector<int> BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) {
 //7000004128189528left 0       100             66      0       0       1       66      61      126     1e-31    131    
                string blastCommand;
                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-                       blastCommand = path + "blast/bin/megablast -e 1e-10 -d " + dbFileName + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn
+                       blastCommand = path + "megablast -e 1e-10 -d " + dbFileName + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn
                        blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber));
                #else
                //blastCommand = path + "blast\\bin\\megablast -e 1e-10 -d " + dbFileName + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn
                //blastCommand += (" -i " + (queryFileName+toString(randNumber)) + " -o " + blastFileName+toString(randNumber));
 
-                       blastCommand =  "\"" + path + "blast\\bin\\megablast\" -e 1e-10 -d " + "\"" + dbFileName + "\"" + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn
+                       blastCommand =  "\"" + path + "megablast\" -e 1e-10 -d " + "\"" + dbFileName + "\"" + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn
                        blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber));
                        //wrap entire string in ""
                        blastCommand = "\"" + blastCommand + "\"";
@@ -343,20 +359,15 @@ void BlastDB::generateDB() {
        try {
        
                //m->mothurOut("Generating the temporary BLAST database...\t"); cout.flush();
-               
-               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 formatdbCommand;
                
                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-                       formatdbCommand = path + "blast/bin/formatdb -p F -o T -i " + dbFileName;       //      format the database, -o option gives us the ability
+                       formatdbCommand = path + "formatdb -p F -o T -i " + dbFileName; //      format the database, -o option gives us the ability
                #else
                        //formatdbCommand = path + "blast\\bin\\formatdb -p F -o T -i " + dbFileName;   //      format the database, -o option gives us the ability
 
-                       formatdbCommand = "\"" + path + "blast\\bin\\formatdb\" -p F -o T -i " + "\"" +  dbFileName + "\"";
+                       formatdbCommand = "\"" + path + "formatdb\" -p F -o T -i " + "\"" +  dbFileName + "\"";
                        //wrap entire string in ""
                        formatdbCommand = "\"" + formatdbCommand + "\"";
                #endif
index 5daedf53d9a4fc6385d44c90383fca16d14d47c8..99a99879f427efd0ea068f125bbf8b1cd003e95e 100644 (file)
@@ -16,8 +16,8 @@
 class BlastDB : public Database {
 
 public:
-       BlastDB(string, float, float, float, float);
-       BlastDB();
+       BlastDB(string, float, float, float, float, string);
+       BlastDB(string);
        ~BlastDB();
        
        void generateDB();
index 57528b4026e538f4b9ad85b706182e162bca2567..9da0d3c522526a7fb76720aef8a38c83fab11814 100644 (file)
@@ -14,7 +14,7 @@
 
 //***************************************************************************************************************
 ChimeraSlayer::ChimeraSlayer(string file, string temp, bool trim, string mode, int k, int ms, int mms, int win, float div, 
-int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r) : Chimera()  {      
+int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas) : Chimera()  {         
        try {
                fastafile = file;
                templateFileName = temp; templateSeqs = readSeqs(temp);
@@ -35,6 +35,7 @@ int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int num
                realign = r; 
                trimChimera = trim;
                numNoParents = 0;
+               blastlocation = blas;
        
                doPrep();
        }
@@ -46,7 +47,7 @@ int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int num
 //***************************************************************************************************************
 //template=self
 ChimeraSlayer::ChimeraSlayer(string file, string temp, bool trim, map<string, int>& prior, string mode, int k, int ms, int mms, int win, float div, 
-                                                        int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r) : Chimera()  {      
+                                                        int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas) : Chimera()  {         
        try {
                fastafile = file; templateSeqs = readSeqs(fastafile);
                templateFileName = temp; 
@@ -68,6 +69,7 @@ ChimeraSlayer::ChimeraSlayer(string file, string temp, bool trim, map<string, in
                trimChimera = trim;
                priority = prior;
                numNoParents = 0;
+               blastlocation = blas;
                
                createFilter(templateSeqs, 0.0); //just removed columns where all seqs have a gap
                
@@ -216,7 +218,7 @@ int ChimeraSlayer::doPrep() {
                }else if (searchMethod == "blast") {
                
                        //generate blastdb
-                       databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(fastafile)), -1.0, -1.0, 1, -3);
+                       databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(fastafile)), -1.0, -1.0, 1, -3, blastlocation);
                        
                        if (m->control_pressed) { return 0; }
 
@@ -330,7 +332,7 @@ vector<Sequence*> ChimeraSlayer::getTemplate(Sequence q, vector<Sequence*>& user
                }else if (searchMethod == "blast") {
                        
                        //generate blastdb
-                       databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(templateFileName)), -1.0, -1.0, 1, -3);
+                       databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(templateFileName)), -1.0, -1.0, 1, -3, blastlocation);
                        
                        if (m->control_pressed) { return userTemplate; }
 
index 8c3cbb22994cb4956f5752806a76bf5b9b1361df..ef7b3c3c4fb46efa313aa9b03b7fcbc84489c497 100644 (file)
@@ -24,8 +24,8 @@
 class ChimeraSlayer : public Chimera {
        
        public:
-               ChimeraSlayer(string, string, bool, string, int, int, int, int, float, int, int, int, int, int, int, int, int, bool);
-               ChimeraSlayer(string, string, bool, map<string, int>&, string,  int, int, int, int, float, int, int, int, int, int, int, int, int, bool);
+               ChimeraSlayer(string, string, bool, string, int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string);
+               ChimeraSlayer(string, string, bool, map<string, int>&, string,  int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string);
 
                ~ChimeraSlayer();
                
@@ -54,7 +54,7 @@ class ChimeraSlayer : public Chimera {
        
                vector<data_struct>  chimeraResults;
                data_results printResults;
-               string chimeraFlags, searchMethod, fastafile;
+               string chimeraFlags, searchMethod, fastafile, blastlocation;
                bool realign, trimChimera;
                int window, numWanted, kmerSize, match, misMatch, minSim, minCov, minBS, minSNP, parents, iters, increment;
                float divR;
index 4c37a854fe317a29c90be7dc45e31144fe68a6c5..7c35453a8993363512c9121aed83cd664ebcb799 100644 (file)
@@ -36,6 +36,7 @@ vector<string> ChimeraSlayerCommand::setParameters(){
                CommandParameter pdivergence("divergence", "Number", "", "1.007", "", "", "",false,false); parameters.push_back(pdivergence);
                CommandParameter pparents("parents", "Number", "", "3", "", "", "",false,false); parameters.push_back(pparents);
                CommandParameter pincrement("increment", "Number", "", "5", "", "", "",false,false); parameters.push_back(pincrement);
+               CommandParameter pblastlocation("blastlocation", "String", "", "", "", "", "",false,false); parameters.push_back(pblastlocation);
                CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
                CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
                CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
@@ -55,7 +56,7 @@ string ChimeraSlayerCommand::getHelpString(){
                string helpString = "";
                helpString += "The chimera.slayer command reads a fastafile and referencefile and outputs potentially chimeric sequences.\n";
                helpString += "This command was modeled after the chimeraSlayer written by the Broad Institute.\n";
-               helpString += "The chimera.slayer command parameters are fasta, name, template, processors, trim, ksize, window, match, mismatch, divergence. minsim, mincov, minbs, minsnp, parents, search, iters, increment, numwanted, and realign.\n";
+               helpString += "The chimera.slayer command parameters are fasta, name, template, processors, trim, ksize, window, match, mismatch, divergence. minsim, mincov, minbs, minsnp, parents, search, iters, increment, numwanted, blastlocation and realign.\n";
                helpString += "The fasta parameter allows you to enter the fasta file containing your potentially chimeric sequences, and is required, unless you have a valid current fasta file. \n";
                helpString += "The name parameter allows you to provide a name file, if you are using reference=self. \n";
                helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amazon.fasta \n";
@@ -81,6 +82,7 @@ string ChimeraSlayerCommand::getHelpString(){
                helpString += "The minsnp parameter allows you to specify percent of SNPs to sample on each side of breakpoint for computing bootstrap support (default: 10) \n";
                helpString += "The search parameter allows you to specify search method for finding the closest parent. Choices are blast, and kmer, default blast. \n";
                helpString += "The realign parameter allows you to realign the query to the potential parents. Choices are true or false, default true.  \n";
+               helpString += "The blastlocation parameter allows you to specify the location of your blast executable. By default mothur will look in ./blast/bin relative to mothur's executable.  \n";
                helpString += "If the save parameter is set to true the reference sequences will be saved in memory, to clear them later you can use the clear.memory command. Default=f.";
                helpString += "The chimera.slayer command should be in the following format: \n";
                helpString += "chimera.slayer(fasta=yourFastaFile, reference=yourTemplate, search=yourSearch) \n";
@@ -408,6 +410,43 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option)  {
                        
                        temp = validParameter.validFile(parameters, "numwanted", false);                if (temp == "not found") { temp = "15"; }               
                        convert(temp, numwanted);
+                       
+                       blastlocation = validParameter.validFile(parameters, "blastlocation", false);   
+                       if (blastlocation == "not found") { blastlocation = ""; }
+                       else {
+                               //add / to name if needed
+                               string lastChar = blastlocation.substr(blastlocation.length()-1);
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                               if (lastChar != "/") { blastlocation += "/"; }
+#else
+                               if (lastChar != "\\") { blastlocation += "\\"; }        
+#endif
+                               blastlocation = m->getFullPathName(blastlocation);
+                               string formatdbCommand = "";
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                               formatdbCommand = blastlocation + "formatdb";   
+#else
+                               formatdbCommand = blastlocation + "formatdb.exe";
+#endif
+                               
+                               //test to make sure formatdb exists
+                               ifstream in;
+                               formatdbCommand = m->getFullPathName(formatdbCommand);
+                               int ableToOpen = m->openInputFile(formatdbCommand, in, "no error"); in.close();
+                               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + formatdbCommand + " file does not exist. mothur requires formatdb.exe to run chimera.slayer."); m->mothurOutEndLine(); abort = true; }
+                               
+                               string blastCommand = "";
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                               blastCommand = blastlocation + "megablast";     
+#else
+                               blastCommand = blastlocation + "megablast.exe";
+#endif
+                               //test to make sure formatdb exists
+                               ifstream in2;
+                               blastCommand = m->getFullPathName(blastCommand);
+                               ableToOpen = m->openInputFile(blastCommand, in2, "no error"); in2.close();
+                               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + blastCommand + " file does not exist. mothur requires blastall.exe to run chimera.slayer."); m->mothurOutEndLine(); abort = true; }
+                       }
 
                        if ((search != "blast") && (search != "kmer")) { m->mothurOut(search + " is not a valid search."); m->mothurOutEndLine(); abort = true;  }
                        
@@ -432,7 +471,7 @@ int ChimeraSlayerCommand::execute(){
                        int start = time(NULL); 
                        
                        if (templatefile != "self") { //you want to run slayer with a refernce template
-                               chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign);     
+                               chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation);      
                        }else {
                                if (processors != 1) { m->mothurOut("When using template=self, mothur can only use 1 processor, continuing."); m->mothurOutEndLine(); processors = 1; }
                                string nameFile = "";
@@ -466,7 +505,7 @@ int ChimeraSlayerCommand::execute(){
                                
                                if (m->control_pressed) {  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        }  return 0;    }
 
-                               chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign);   
+                               chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation);    
                        }
                                
                        if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it                               
index cfa934abf6655e9605d104300b90e0d590ce179f..1b173911c3d79218413e76533da53b7a3ffa3649 100644 (file)
@@ -53,7 +53,7 @@ private:
        #endif
 
        bool abort, realign, trim, trimera, save;
-       string fastafile, templatefile, outputDir, search, namefile;
+       string fastafile, templatefile, outputDir, search, namefile, blastlocation;
        int processors, window, iters, increment, numwanted, ksize, match, mismatch, parents, minSimilarity, minCoverage, minBS, minSNP, numSeqs, templateSeqsLength;
        float divR;
        Chimera* chimera;
index 7770999e779917996a916e87836a03c3a2a8f26b..1642f0bb037f609971797812575aa109e35aed28 100644 (file)
@@ -47,7 +47,7 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                                }
                        }
                        else if(method == "suffix")             {       database = new SuffixDB(numSeqs);                                                               }
-                       else if(method == "blast")              {       database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch);   }
+                       else if(method == "blast")              {       database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "");       }
                        else if(method == "distance")   {       database = new DistanceDB();    }
                        else {
                                m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
@@ -176,7 +176,7 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                                }
                        }
                        else if(method == "suffix")             {       database = new SuffixDB(numSeqs);                                                               }
-                       else if(method == "blast")              {       database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch);   }
+                       else if(method == "blast")              {       database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "");       }
                        else if(method == "distance")   {       database = new DistanceDB();    }
                        else {
                                m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
index 29a5d725ff121b47b5c8f3132f54776f3e8a34ff..d3c7fa48128246f8f4cb28ad53727329b3de856c 100644 (file)
@@ -166,10 +166,10 @@ ClearcutCommand::ClearcutCommand(string option)  {
                                //is there are current file available for either of these?
                                //give priority to phylip, then fasta
                                phylipfile = m->getPhylipFile(); 
-                               if (phylipfile != "") {  m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
+                               if (phylipfile != "") {  inputFile = phylipfile; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
                                else { 
                                        fastafile = m->getFastaFile(); 
-                                       if (fastafile != "") {  m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
+                                       if (fastafile != "") { inputFile = fastafile;  m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
                                        else { 
                                                m->mothurOut("No valid current files. You must provide a phylip or fasta file before you can use the clearcut command."); m->mothurOutEndLine(); 
                                                abort = true;