From 36a8526766106bce1412e530e99f9c699dd59105 Mon Sep 17 00:00:00 2001 From: westcott Date: Thu, 21 May 2009 13:18:32 +0000 Subject: [PATCH] fixed blast code path problem --- blastalign.cpp | 6 +++++- blastalign.hpp | 3 +++ blastdb.cpp | 11 ++++++++--- blastdb.hpp | 3 +++ engine.cpp | 8 +++++--- engine.hpp | 4 ++-- globaldata.hpp | 2 +- mothur.cpp | 4 ++-- 8 files changed, 29 insertions(+), 12 deletions(-) diff --git a/blastalign.cpp b/blastalign.cpp index 0a1350f..a477313 100644 --- a/blastalign.cpp +++ b/blastalign.cpp @@ -23,6 +23,10 @@ BlastAlignment::BlastAlignment(float go, float ge, float m, float mm) : match(m), // 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) { + globaldata = GlobalData::getInstance(); + path = globaldata->argv; + path = path.substr(0, (path.find_last_of('m'))); + 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) @@ -54,7 +58,7 @@ void BlastAlignment::align(string seqA, string seqB){ //Use blastn to align the // The blastCommand assumes that we have DNA sequences (blastn) and that they are fairly similar (-e 0.001) and // that we don't want to apply any kind of complexity filtering (-F F) - string blastCommand = "~/Pipeline/src/cpp/production/blast/bin/bl2seq -p blastn -i " + candidateFileName + " -j " + templateFileName + " -e 0.0001 -F F -o " + blastFileName + " -W 11"; + string blastCommand = path + "blast/bin/bl2seq -p blastn -i " + candidateFileName + " -j " + templateFileName + " -e 0.0001 -F F -o " + blastFileName + " -W 11"; blastCommand += " -r " + toString(match) + " -q " + toString(mismatch); blastCommand += " -G " + toString(gapOpen) + " -E " + toString(gapExtend); diff --git a/blastalign.hpp b/blastalign.hpp index 0f755d8..696c134 100644 --- a/blastalign.hpp +++ b/blastalign.hpp @@ -12,6 +12,7 @@ */ #include "mothur.h" +#include "globaldata.hpp" class BlastAlignment : public Alignment { @@ -24,11 +25,13 @@ private: string candidateFileName; string templateFileName; string blastFileName; + string path; void setPairwiseSeqs(); float match; float mismatch; float gapOpen; float gapExtend; + GlobalData* globaldata; }; diff --git a/blastdb.cpp b/blastdb.cpp index ef8f737..82b104e 100644 --- a/blastdb.cpp +++ b/blastdb.cpp @@ -18,7 +18,9 @@ using namespace std; BlastDB::BlastDB(string fastaFileName, float gO, float gE, float m, float mM) : Database(fastaFileName), gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) { - + + globaldata = GlobalData::getInstance(); + cout << "Generating the temporary BLAST database...\t"; cout.flush(); int randNumber = rand(); @@ -36,7 +38,10 @@ gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) { } unalignedFastaFile.close(); - string formatdbCommand = "~/Pipeline/src/cpp/production/blast/bin/formatdb -p F -o T -i " + dbFileName; // format the database, -o option gives us the ability + path = globaldata->argv; + path = path.substr(0, (path.find_last_of('m'))); + + string formatdbCommand = path + "blast/bin/formatdb -p F -o T -i " + dbFileName; // format the database, -o option gives us the ability system(formatdbCommand.c_str()); // to get the right sequence names, i think. -p F // option tells formatdb that seqs are DNA, not prot cout << "DONE." << endl << endl; cout.flush(); @@ -71,7 +76,7 @@ Sequence* BlastDB::findClosestSequence(Sequence* candidate){ // wordsize used in megablast. I'm sure we're sacrificing accuracy for speed, but anyother way would take way too // long. With this setting, it seems comparable in speed to the suffix tree approach. - string blastCommand = "~/Pipeline/src/cpp/production/blast/bin/blastall -p blastn -d " + dbFileName + " -b 1 -m 8 -W 28"; + string blastCommand = path + "blast/bin/blastall -p blastn -d " + dbFileName + " -b 1 -m 8 -W 28"; blastCommand += (" -i " + queryFileName + " -o " + blastFileName); system(blastCommand.c_str()); diff --git a/blastdb.hpp b/blastdb.hpp index a952897..dfb2a2c 100644 --- a/blastdb.hpp +++ b/blastdb.hpp @@ -12,6 +12,7 @@ */ #include "mothur.h" +#include "globaldata.hpp" class BlastDB : public Database { public: @@ -23,12 +24,14 @@ private: string dbFileName; string queryFileName; string blastFileName; + string path; float gapOpen; float gapExtend; float match; float misMatch; Sequence* emptySequence; + GlobalData* globaldata; }; #endif diff --git a/engine.cpp b/engine.cpp index b9360a4..23e3f6e 100644 --- a/engine.cpp +++ b/engine.cpp @@ -16,10 +16,11 @@ using namespace std; /***********************************************************************/ -InteractEngine::InteractEngine(){ +InteractEngine::InteractEngine(string path){ globaldata = GlobalData::getInstance(); - + globaldata->argv = path; + system("clear"); // char buffer = ' '; // ifstream header("introtext.txt"); @@ -92,10 +93,11 @@ bool InteractEngine::getInput(){ /***********************************************************************/ //This function opens the batchfile to be used by BatchEngine::getInput. -BatchEngine::BatchEngine(string batchFileName){ +BatchEngine::BatchEngine(string path, string batchFileName){ try { globaldata = GlobalData::getInstance(); openedBatch = openInputFile(batchFileName, inputBatchFile); + globaldata->argv = path; system("clear"); diff --git a/engine.hpp b/engine.hpp index a35b616..276d292 100644 --- a/engine.hpp +++ b/engine.hpp @@ -39,7 +39,7 @@ protected: class BatchEngine : public Engine { public: - BatchEngine(string); + BatchEngine(string, string); ~BatchEngine(); virtual bool getInput(); int openedBatch; @@ -53,7 +53,7 @@ private: class InteractEngine : public Engine { public: - InteractEngine(); + InteractEngine(string); ~InteractEngine(); virtual bool getInput(); private: diff --git a/globaldata.hpp b/globaldata.hpp index c4bfe05..0c25489 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -41,7 +41,7 @@ public: FullMatrix* gMatrix; TreeMap* gTreemap; SequenceDB* gSequenceDB; - string inputFileName, helpRequest, commandName, vertical; + string inputFileName, helpRequest, commandName, vertical, argv; bool allLines; vector Estimators, Groups; //holds estimators to be used set lines; //hold lines to be used diff --git a/mothur.cpp b/mothur.cpp index c60644d..add60fa 100644 --- a/mothur.cpp +++ b/mothur.cpp @@ -26,10 +26,10 @@ int main(int argc, char *argv[]){ bool bail = 0; if(argc>1){ - mothur = new BatchEngine(argv[1]); + mothur = new BatchEngine(argv[0], argv[1]); } else{ - mothur = new InteractEngine(); + mothur = new InteractEngine(argv[0]); } while(bail == 0) { bail = mothur->getInput(); } -- 2.39.2