]> git.donarmstrong.com Git - mothur.git/blobdiff - bayesian.cpp
modified mpi code to save ram by writing out every 10 seqs.
[mothur.git] / bayesian.cpp
index e59545a89a04031999885beb932dac5003ab6b8c..af1fa27f2202de76086e562c775229f4f241e387 100644 (file)
@@ -43,10 +43,10 @@ Classify(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0), kmerSize(ksize), c
                int start = time(NULL);
                
                if(probFileTest && probFileTest2){      
-                       mothurOut("Reading template probabilities...     "); cout.flush();
+                       m->mothurOut("Reading template probabilities...     "); cout.flush();
                        readProbFile(probFileTest, probFileTest2);      
                }else{
-                       mothurOut("Calculating template probabilities...     "); cout.flush();
+                       m->mothurOut("Calculating template probabilities...     "); cout.flush();
 
                        ofstream out;
                        openOutputFile(probFileName, out);
@@ -56,6 +56,7 @@ Classify(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0), kmerSize(ksize), c
                        
                        //for each word
                        for (int i = 0; i < numKmers; i++) {
+                               if (m->control_pressed) { break; }
                                
                                out << i << '\t';
                                
@@ -88,11 +89,11 @@ Classify(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0), kmerSize(ksize), c
                }
                
                
-               mothurOut("DONE."); mothurOutEndLine();
-               mothurOut("It took " + toString(time(NULL) - start) + " seconds get probabilities. "); mothurOutEndLine();
+               m->mothurOut("DONE."); m->mothurOutEndLine();
+               m->mothurOut("It took " + toString(time(NULL) - start) + " seconds get probabilities. "); m->mothurOutEndLine();
        }
        catch(exception& e) {
-               errorOut(e, "Bayesian", "getTaxonomy");
+               m->errorOut(e, "Bayesian", "Bayesian");
                exit(1);
        }
 }
@@ -114,6 +115,8 @@ string Bayesian::getTaxonomy(Sequence* seq) {
                }
        
                int index = getMostProbableTaxonomy(queryKmers);
+               
+               if (m->control_pressed) { return tax; }
                                        
                //bootstrap - to set confidenceScore
                int numToSelect = queryKmers.size() / 8;
@@ -122,7 +125,7 @@ string Bayesian::getTaxonomy(Sequence* seq) {
                return tax;     
        }
        catch(exception& e) {
-               errorOut(e, "Bayesian", "getTaxonomy");
+               m->errorOut(e, "Bayesian", "getTaxonomy");
                exit(1);
        }
 }
@@ -143,6 +146,8 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
                map<int, int>::iterator itConvert;
                
                for (int i = 0; i < iters; i++) {
+                       if (m->control_pressed) { return "control"; }
+                       
                        vector<int> temp;
                                                
                        for (int j = 0; j < numToSelect; j++) {
@@ -196,7 +201,7 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
                
        }
        catch(exception& e) {
-               errorOut(e, "Bayesian", "bootstrapResults");
+               m->errorOut(e, "Bayesian", "bootstrapResults");
                exit(1);
        }
 }
@@ -225,7 +230,7 @@ int Bayesian::getMostProbableTaxonomy(vector<int> queryKmer) {
                return indexofGenus;
        }
        catch(exception& e) {
-               errorOut(e, "Bayesian", "getMostProbableTaxonomy");
+               m->errorOut(e, "Bayesian", "getMostProbableTaxonomy");
                exit(1);
        }
 }
@@ -252,7 +257,7 @@ map<string, int> Bayesian::parseTaxMap(string newTax) {
                
        }
        catch(exception& e) {
-               errorOut(e, "Bayesian", "parseTax");
+               m->errorOut(e, "Bayesian", "parseTax");
                exit(1);
        }
 }
@@ -291,7 +296,7 @@ void Bayesian::readProbFile(ifstream& in, ifstream& inNum) {
                in.close();
        }
        catch(exception& e) {
-               errorOut(e, "Bayesian", "readProbFile");
+               m->errorOut(e, "Bayesian", "readProbFile");
                exit(1);
        }
 }