]> git.donarmstrong.com Git - mothur.git/blobdiff - bayesian.cpp
added sorted parameter to get.oturep, added error checking to chimera classes in...
[mothur.git] / bayesian.cpp
index 01e4139fc877946e8a491d6c5b1e5beafed577b8..5272b2d1761285f934e9e8e1a474fd27f1edc328 100644 (file)
@@ -11,8 +11,8 @@
 #include "kmer.hpp"
 
 /**************************************************************************************************/
-Bayesian::Bayesian(string tfile, string tempFile, string method, int ksize, int cutoff) : 
-Classify(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0), kmerSize(ksize), confidenceThreshold(cutoff)  {
+Bayesian::Bayesian(string tfile, string tempFile, string method, int ksize, int cutoff, bool p) : 
+Classify(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0), kmerSize(ksize), confidenceThreshold(cutoff), probs(p)  {
        try {
                                        
                numKmers = database->getMaxKmer() + 1;
@@ -99,7 +99,7 @@ Classify(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0), kmerSize(ksize), c
 /**************************************************************************************************/
 string Bayesian::getTaxonomy(Sequence* seq) {
        try {
-               string tax;
+               string tax = "";
                Kmer kmer(kmerSize);
                
                //get words contained in query
@@ -116,8 +116,17 @@ string Bayesian::getTaxonomy(Sequence* seq) {
                int index = getMostProbableTaxonomy(queryKmers);
                                        
                //bootstrap - to set confidenceScore
-               int numToSelect = queryKmers.size() / 8;
-               tax = bootstrapResults(queryKmers, index, numToSelect);
+               if (probs) {
+                       int numToSelect = queryKmers.size() / 8;
+                       tax = bootstrapResults(queryKmers, index, numToSelect);
+               }else{
+                       TaxNode seqTax = phyloTree->get(index);
+                       while (seqTax.level != 0) { //while you are not at the root
+                               tax = seqTax.name + ";" + tax;
+                               seqTax = phyloTree->get(seqTax.parent);
+                       }
+                       simpleTax = tax;
+               }
                                
                return tax;     
        }