]> git.donarmstrong.com Git - mothur.git/blobdiff - bayesian.cpp
changes while testing
[mothur.git] / bayesian.cpp
index 49be4af57ff66f46ac04912535d7918518cc75d2..8278afb32e1d2c028a83ffdece17ed9910a78e20 100644 (file)
@@ -145,6 +145,8 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) {
 
                                //for each word
                                for (int i = 0; i < numKmers; i++) {
+                    //m->mothurOut("[DEBUG]: kmer = " + toString(i) + "\n");
+                    
                                        if (m->control_pressed) {  break; }
                                        
                                        #ifdef USE_MPI
@@ -239,7 +241,9 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) {
                        }
                }
                
+        if (m->debug) { m->mothurOut("[DEBUG]: about to generateWordPairDiffArr\n"); }
                generateWordPairDiffArr();
+        if (m->debug) { m->mothurOut("[DEBUG]: done generateWordPairDiffArr\n"); }
                
                //save probabilities
                if (rdb->save) { rdb->wordGenusProb = wordGenusProb; rdb->WordPairDiffArr = WordPairDiffArr; }
@@ -255,9 +259,8 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) {
 /**************************************************************************************************/
 Bayesian::~Bayesian() {
        try {
-               
-                delete phyloTree; 
-                if (database != NULL) {  delete database; }
+        if (phyloTree != NULL) { delete phyloTree; }
+        if (database != NULL) {  delete database; }
        }
        catch(exception& e) {
                m->errorOut(e, "Bayesian", "~Bayesian");
@@ -299,7 +302,7 @@ string Bayesian::getTaxonomy(Sequence* seq) {
                        }  
                }
                
-               if (queryKmers.size() == 0) {  m->mothurOut(seq->getName() + "is bad."); m->mothurOutEndLine(); simpleTax = "unknown;";  return "unknown;"; }
+               if (queryKmers.size() == 0) {  m->mothurOut(seq->getName() + " is bad. It has no kmers of length " + toString(kmerSize) + "."); m->mothurOutEndLine(); simpleTax = "unknown;";  return "unknown;"; }
                
                
                int index = getMostProbableTaxonomy(queryKmers);
@@ -309,7 +312,11 @@ string Bayesian::getTaxonomy(Sequence* seq) {
                //bootstrap - to set confidenceScore
                int numToSelect = queryKmers.size() / 8;
        
+        if (m->debug) {  m->mothurOut(seq->getName() + "\t"); }
+        
                tax = bootstrapResults(queryKmers, index, numToSelect);
+        
+        if (m->debug) {  m->mothurOut("\n"); }
                
                return tax;     
        }
@@ -375,6 +382,7 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
                int seqTaxIndex = tax;
                TaxNode seqTax = phyloTree->get(tax);
                
+        
                while (seqTax.level != 0) { //while you are not at the root
                                        
                                itBoot2 = confidenceScores.find(seqTaxIndex); //is this a classification we already have a count on
@@ -384,11 +392,13 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
                                        confidence = itBoot2->second;
                                }
                                
+                if (m->debug) { m->mothurOut(seqTax.name + "(" + toString(((confidence/(float)iters) * 100)) + ");"); }
+            
                                if (((confidence/(float)iters) * 100) >= confidenceThreshold) {
                                        confidenceTax = seqTax.name + "(" + toString(((confidence/(float)iters) * 100)) + ");" + confidenceTax;
                                        simpleTax = seqTax.name + ";" + simpleTax;
                                }
-                               
+            
                                seqTaxIndex = seqTax.parent;
                                seqTax = phyloTree->get(seqTax.parent);
                }