]> git.donarmstrong.com Git - mothur.git/blobdiff - classify.cpp
some changes to trim.flows
[mothur.git] / classify.cpp
index 7f451261550a949b3a1cbb7ab72fd374122597bb..875628d85d8dbcb4caf6d712b41be517eefef733 100644 (file)
@@ -28,7 +28,7 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                m->mothurOut("Generating search database...    "); cout.flush();
 #ifdef USE_MPI 
                        int pid, processors;
-                       vector<long> positions;
+                       vector<unsigned long int> positions;
                        int tag = 2001;
                
                        MPI_Status status; 
@@ -46,7 +46,7 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                        //delete inFileName;
 
                        if (pid == 0) { //only one process needs to scan file
-                               positions = setFilePosFasta(tempFile, numSeqs); //fills MPIPos, returns numSeqs
+                               positions = m->setFilePosFasta(tempFile, numSeqs); //fills MPIPos, returns numSeqs
 
                                //send file positions to all processes
                                for(int i = 1; i < processors; i++) { 
@@ -96,8 +96,8 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                //need to know number of template seqs for suffixdb
                if (method == "suffix") {
                        ifstream inFASTA;
-                       openInputFile(tempFile, inFASTA);
-                       numSeqs = count(istreambuf_iterator<char>(inFASTA),istreambuf_iterator<char>(), '>');
+                       m->openInputFile(tempFile, inFASTA);
+                       m->getNumSeqs(inFASTA, numSeqs);
                        inFASTA.close();
                }
 
@@ -108,7 +108,10 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                        
                        kmerDBName = tempFile.substr(0,tempFile.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
                        ifstream kmerFileTest(kmerDBName.c_str());
-                       if(kmerFileTest){       needToGenerate = false;         }
+                       if(kmerFileTest){       
+                               bool GoodFile = m->checkReleaseVersion(kmerFileTest, m->getVersion());
+                               if (GoodFile) {  needToGenerate = false;        }
+                       }
                }
                else if(method == "suffix")             {       database = new SuffixDB(numSeqs);                                                               }
                else if(method == "blast")              {       database = new BlastDB(gapOpen, gapExtend, match, misMatch);    }
@@ -121,11 +124,11 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                
                if (needToGenerate) {
                        ifstream fastaFile;
-                       openInputFile(tempFile, fastaFile);
+                       m->openInputFile(tempFile, fastaFile);
                        
                        while (!fastaFile.eof()) {
                                Sequence temp(fastaFile);
-                               gobble(fastaFile);
+                               m->gobble(fastaFile);
                        
                                names.push_back(temp.getName());
                                                        
@@ -138,19 +141,20 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                }else if ((method == "kmer") && (!needToGenerate)) {    
                        ifstream kmerFileTest(kmerDBName.c_str());
                        database->readKmerDB(kmerFileTest);     
-                       
+               
                        ifstream fastaFile;
-                       openInputFile(tempFile, fastaFile);
+                       m->openInputFile(tempFile, fastaFile);
                        
                        while (!fastaFile.eof()) {
                                Sequence temp(fastaFile);
-                               gobble(fastaFile);
+                               m->gobble(fastaFile);
 
                                names.push_back(temp.getName());
                        }
                        fastaFile.close();
                }
-#endif         
+#endif 
+       
                database->setNumSeqs(names.size());
                
                //sanity check
@@ -182,7 +186,7 @@ int Classify::readTaxonomy(string file) {
 
 #ifdef USE_MPI 
                int pid, num, processors;
-               vector<long> positions;
+               vector<unsigned long int> positions;
                int tag = 2001;
                
                MPI_Status status; 
@@ -200,7 +204,7 @@ int Classify::readTaxonomy(string file) {
                //delete inFileName;
 
                if (pid == 0) {
-                       positions = setFilePosEachLine(file, num);
+                       positions = m->setFilePosEachLine(file, num);
                        
                        //send file positions to all processes
                        for(int i = 1; i < processors; i++) { 
@@ -235,7 +239,7 @@ int Classify::readTaxonomy(string file) {
                MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
 #else                          
                ifstream inTax;
-               openInputFile(file, inTax);
+               m->openInputFile(file, inTax);
        
                //read template seqs and save
                while (!inTax.eof()) {
@@ -245,7 +249,7 @@ int Classify::readTaxonomy(string file) {
                        
                        phyloTree->addSeqToTree(name, taxInfo);
                
-                       gobble(inTax);
+                       m->gobble(inTax);
                }
                inTax.close();
 #endif 
@@ -253,7 +257,7 @@ int Classify::readTaxonomy(string file) {
                phyloTree->assignHeirarchyIDs(0);
                
                phyloTree->setUp(file);
-               
+       
                m->mothurOut("DONE.");
                m->mothurOutEndLine();  cout.flush();