]> git.donarmstrong.com Git - mothur.git/blobdiff - blastdb.cpp
changes while setting up test files
[mothur.git] / blastdb.cpp
index d8a04da762b65406af2d43062460de9324d41f61..6cfa3c685767457e6b9e9e10400ca1806929574c 100644 (file)
@@ -17,7 +17,6 @@
 BlastDB::BlastDB(float gO, float gE, float m, float mM) : Database(), 
 gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) {
        
-       globaldata = GlobalData::getInstance();
        count = 0;
 
        int randNumber = rand();
@@ -30,7 +29,6 @@ gapOpen(gO), gapExtend(gE), match(m), misMatch(mM) {
 
 BlastDB::BlastDB() : Database() {
        try {
-               globaldata = GlobalData::getInstance();
                count = 0;
 
                int randNumber = rand();
@@ -69,7 +67,7 @@ vector<int> BlastDB::findClosestSequences(Sequence* seq, int n) {
                vector<int> topMatches;
                
                ofstream queryFile;
-               openOutputFile((queryFileName+seq->getName()), queryFile);
+               m->openOutputFile((queryFileName+seq->getName()), queryFile);
                queryFile << '>' << seq->getName() << endl;
                queryFile << seq->getUnaligned() << endl;
                queryFile.close();
@@ -84,11 +82,11 @@ vector<int> BlastDB::findClosestSequences(Sequence* seq, int n) {
                system(blastCommand.c_str());
                
                ifstream m8FileHandle;
-               openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error");
+               m->openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error");
                
                string dummy;
                int templateAccession;
-               gobble(m8FileHandle);
+               m->gobble(m8FileHandle);
                
                while(!m8FileHandle.eof()){
                        m8FileHandle >> dummy >> templateAccession >> searchScore;
@@ -96,7 +94,7 @@ vector<int> BlastDB::findClosestSequences(Sequence* seq, int n) {
                        //get rest of junk in line
                        while (!m8FileHandle.eof())     {       char c = m8FileHandle.get(); if (c == 10 || c == 13){   break;  }       } 
                        
-                       gobble(m8FileHandle);
+                       m->gobble(m8FileHandle);
                        topMatches.push_back(templateAccession);
                }
                m8FileHandle.close();
@@ -118,7 +116,7 @@ vector<int> BlastDB::findClosestMegaBlast(Sequence* seq, int n) {
                vector<int> topMatches;
                
                ofstream queryFile;
-               openOutputFile((queryFileName+seq->getName()), queryFile);
+               m->openOutputFile((queryFileName+seq->getName()), queryFile);
                queryFile << '>' << seq->getName() << endl;
                queryFile << seq->getUnaligned() << endl;
                queryFile.close();
@@ -132,26 +130,27 @@ vector<int> BlastDB::findClosestMegaBlast(Sequence* seq, int n) {
                system(blastCommand.c_str());
 
                ifstream m8FileHandle;
-               openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error");
+               m->openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error");
        
                string dummy;
                int templateAccession;
-               gobble(m8FileHandle);
+               m->gobble(m8FileHandle);
                
                while(!m8FileHandle.eof()){
                        m8FileHandle >> dummy >> templateAccession >> searchScore;
+                       //cout << templateAccession << '\t' << searchScore << endl;
                        
                        //get rest of junk in line
                        while (!m8FileHandle.eof())     {       char c = m8FileHandle.get(); if (c == 10 || c == 13){   break;  }       } 
                        
-                       gobble(m8FileHandle);
+                       m->gobble(m8FileHandle);
                        topMatches.push_back(templateAccession);
 //cout << templateAccession << endl;
                }
                m8FileHandle.close();
                remove((queryFileName+seq->getName()).c_str());
                remove((blastFileName+seq->getName()).c_str());
-//cout << "\n\n" ;             
+//cout << "\n" ;               
                return topMatches;
        }
        catch(exception& e) {
@@ -164,7 +163,7 @@ void BlastDB::addSequence(Sequence seq) {
        try {
        
                ofstream unalignedFastaFile;
-               openOutputFileAppend(dbFileName, unalignedFastaFile);                           
+               m->openOutputFileAppend(dbFileName, unalignedFastaFile);                                
        
                //      generating a fasta file with unaligned template
                unalignedFastaFile << '>' << count << endl;                                     //      sequences, which will be input to formatdb
@@ -184,7 +183,7 @@ void BlastDB::generateDB() {
        
                //m->mothurOut("Generating the temporary BLAST database...\t"); cout.flush();
                
-               path = globaldata->argv;
+               path = m->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