]> git.donarmstrong.com Git - mothur.git/blobdiff - bayesian.cpp
added warning about merging with something above cutoff to cluster. working on chimeras
[mothur.git] / bayesian.cpp
index 3a2d3e0156468f1114dd0ebb2d47fe87fe577789..a83f1edd04c3f8ddfad13887c1dbb78c9341d4f1 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), kmerSize(ksize), confidenceThreshold(cutoff)  {
+Bayesian::Bayesian(string tfile, string tempFile, string method, int ksize, int cutoff, int i) : 
+Classify(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0), kmerSize(ksize), confidenceThreshold(cutoff), iters(i)  {
        try {
                                        
                numKmers = database->getMaxKmer() + 1;
@@ -92,14 +92,14 @@ Classify(tfile, tempFile, method, ksize, 0, 0, 0, 0), kmerSize(ksize), confidenc
                mothurOut("It took " + toString(time(NULL) - start) + " seconds get probabilities. "); mothurOutEndLine();
        }
        catch(exception& e) {
-               errorOut(e, "Bayesian", "getTaxonomy");
+               errorOut(e, "Bayesian", "Bayesian");
                exit(1);
        }
 }
 /**************************************************************************************************/
 string Bayesian::getTaxonomy(Sequence* seq) {
        try {
-               string tax;
+               string tax = "";
                Kmer kmer(kmerSize);
                
                //get words contained in query
@@ -118,7 +118,7 @@ string Bayesian::getTaxonomy(Sequence* seq) {
                //bootstrap - to set confidenceScore
                int numToSelect = queryKmers.size() / 8;
                tax = bootstrapResults(queryKmers, index, numToSelect);
-                               
+                                               
                return tax;     
        }
        catch(exception& e) {
@@ -142,7 +142,7 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
                map<string, int>::iterator itBoot2;
                map<int, int>::iterator itConvert;
                
-               for (int i = 0; i < 100; i++) {
+               for (int i = 0; i < iters; i++) {
                        vector<int> temp;
                                                
                        for (int j = 0; j < numToSelect; j++) {
@@ -185,7 +185,7 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
                                }
                                
                                if (confidence >= confidenceThreshold) {
-                                       confidenceTax = seqTax.name + "(" + toString(confidence) + ");" + confidenceTax;
+                                       confidenceTax = seqTax.name + "(" + toString(((confidence/(float)iters) * 100)) + ");" + confidenceTax;
                                        simpleTax = seqTax.name + ";" + simpleTax;
                                }