]> git.donarmstrong.com Git - mothur.git/blobdiff - bayesian.cpp
latest version
[mothur.git] / bayesian.cpp
index 63f8716dc0ee4fd243a21c06dd41c30f648228c9..b46f7703a971b8b5141d42faf14e26d45037cba0 100644 (file)
@@ -17,9 +17,11 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i)  {
        try {
                                        
                /************calculate the probablity that each word will be in a specific taxonomy*************/
-               string phyloTreeName = tfile.substr(0,tfile.find_last_of(".")+1) + "tree.train";
-               string probFileName = tfile.substr(0,tfile.find_last_of(".")+1) + tempFile.substr(0,tempFile.find_last_of(".")+1) + char('0'+ kmerSize) + "mer.prob";
-               string probFileName2 = tfile.substr(0,tfile.find_last_of(".")+1) + tempFile.substr(0,tempFile.find_last_of(".")+1) + char('0'+ kmerSize) + "mer.numNonZero";
+               string tfileroot = tfile.substr(0,tfile.find_last_of(".")+1);
+               string tempfileroot = getRootName(getSimpleName(tempFile));
+               string phyloTreeName = tfileroot + "tree.train";
+               string probFileName = tfileroot + tempfileroot + char('0'+ kmerSize) + "mer.prob";
+               string probFileName2 = tfileroot + tempfileroot + char('0'+ kmerSize) + "mer.numNonZero";
                
                ofstream out;
                ofstream out2;
@@ -213,7 +215,7 @@ string Bayesian::getTaxonomy(Sequence* seq) {
                int index = getMostProbableTaxonomy(queryKmers);
                
                if (m->control_pressed) { return tax; }
-                                       
+//cout << seq->getName() << '\t' << index << endl;                                     
                //bootstrap - to set confidenceScore
                int numToSelect = queryKmers.size() / 8;
                tax = bootstrapResults(queryKmers, index, numToSelect);
@@ -249,10 +251,10 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
                        
                        //get taxonomy
                        int newTax = getMostProbableTaxonomy(temp);
-                       TaxNode taxonomy = phyloTree->get(newTax);
-                       
+                       TaxNode taxonomyTemp = phyloTree->get(newTax);
+       
                        //add to confidence results
-                       while (taxonomy.level != 0) { //while you are not at the root
+                       while (taxonomyTemp.level != 0) { //while you are not at the root
                                
                                itBoot2 = confidenceScores.find(newTax); //is this a classification we already have a count on
                                
@@ -262,8 +264,8 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
                                        confidenceScores[newTax]++;
                                }
                                
-                               newTax = taxonomy.parent;
-                               taxonomy = phyloTree->get(taxonomy.parent);
+                               newTax = taxonomyTemp.parent;
+                               taxonomyTemp = phyloTree->get(newTax);
                        }
        
                }