]> git.donarmstrong.com Git - mothur.git/blobdiff - classify.cpp
added count file to cluster.classic and cluster.split. modified splitting classes...
[mothur.git] / classify.cpp
index c92d9fdc6526788df19d9e6f487ffb641bbaca44..212e563f94c4ae7af3ba0916d1040afd9b0e11fa 100644 (file)
@@ -61,7 +61,7 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                                        names.push_back(temp.getName());
                                        database->addSequence(temp);    
                                }
-//                             database->generateDB();
+                               database->generateDB();
                        }else if ((method == "kmer") && (!needToGenerate)) {    
                                ifstream kmerFileTest(kmerDBName.c_str());
                                database->readKmerDB(kmerFileTest);     
@@ -150,7 +150,7 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                                        }
                                }
                                
-//                             database->generateDB();
+                               database->generateDB();
                                MPI_File_close(&inMPI);
                                MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
                #else
@@ -200,7 +200,7 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                                }
                                fastaFile.close();
 
-//                             database->generateDB();
+                               database->generateDB();
                                
                        }else if ((method == "kmer") && (!needToGenerate)) {    
                                ifstream kmerFileTest(kmerDBName.c_str());
@@ -223,9 +223,9 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
                        database->setNumSeqs(names.size());
                        
                        //sanity check
-                       //bool okay = phyloTree->ErrorCheck(names);
+                       bool okay = phyloTree->ErrorCheck(names);
                        
-                       //if (!okay) { m->control_pressed = true; }
+                       if (!okay) { m->control_pressed = true; }
                        
                        m->mothurOut("DONE."); m->mothurOutEndLine();
                        m->mothurOut("It took " + toString(time(NULL) - start) + " seconds generate search database. "); m->mothurOutEndLine();
@@ -238,7 +238,7 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
        }
 }
 /**************************************************************************************************/
-Classify::Classify() {         m = MothurOut::getInstance();   database = NULL;        }
+Classify::Classify() {         m = MothurOut::getInstance();   database = NULL;        flipped=false; }
 /**************************************************************************************************/
 
 int Classify::readTaxonomy(string file) {
@@ -249,7 +249,8 @@ int Classify::readTaxonomy(string file) {
                
                m->mothurOutEndLine();
                m->mothurOut("Reading in the " + file + " taxonomy...\t");      cout.flush();
-
+        if (m->debug) { m->mothurOut("[DEBUG]: Taxonomies read in...\n"); }
+        
 #ifdef USE_MPI 
                int pid, num, processors;
                vector<unsigned long long> positions;
@@ -296,30 +297,21 @@ int Classify::readTaxonomy(string file) {
                        delete buf4;
 
                        istringstream iss (tempBuf,istringstream::in);
-                       iss >> name >> taxInfo;
+                       iss >> name; m->gobble(iss);
+            iss >> taxInfo;
+            if (m->debug) { m->mothurOut("[DEBUG]: name = " + name + " tax = " + taxInfo + "\n"); }
                        taxonomy[name] = taxInfo;
                        phyloTree->addSeqToTree(name, taxInfo);
                }
                
                MPI_File_close(&inMPI);
                MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-#else                          
-               ifstream inTax;
-               m->openInputFile(file, inTax);
-       
-               //read template seqs and save
-               while (!inTax.eof()) {
-                       inTax >> name >> taxInfo;
-                       
-                       taxonomy[name] = taxInfo;
-                       
-                       phyloTree->addSeqToTree(name, taxInfo);
-               
-                       m->gobble(inTax);
-               }
-               inTax.close();
+#else  
+        
+        taxonomy.clear(); 
+        m->readTax(file, taxonomy);
+        for (map<string, string>::iterator itTax = taxonomy.begin(); itTax != taxonomy.end(); itTax++) {  phyloTree->addSeqToTree(itTax->first, itTax->second);  }
 #endif 
-       
                phyloTree->assignHeirarchyIDs(0);
                
                phyloTree->setUp(file);