#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, 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;
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);
//for each word
for (int i = 0; i < numKmers; i++) {
+ if (m->control_pressed) { break; }
out << i << '\t';
}
- 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);
}
}
/**************************************************************************************************/
string Bayesian::getTaxonomy(Sequence* seq) {
try {
- string tax;
+ string tax = "";
Kmer kmer(kmerSize);
//get words contained in query
}
int index = getMostProbableTaxonomy(queryKmers);
+
+ if (m->control_pressed) { return tax; }
//bootstrap - to set confidenceScore
int numToSelect = queryKmers.size() / 8;
tax = bootstrapResults(queryKmers, index, numToSelect);
-
+
return tax;
}
catch(exception& e) {
- errorOut(e, "Bayesian", "getTaxonomy");
+ m->errorOut(e, "Bayesian", "getTaxonomy");
exit(1);
}
}
map<string, int>::iterator itBoot2;
map<int, int>::iterator itConvert;
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < iters; i++) {
+ if (m->control_pressed) { return "control"; }
+
vector<int> temp;
for (int j = 0; j < numToSelect; j++) {
}
if (confidence >= confidenceThreshold) {
- confidenceTax = seqTax.name + "(" + toString(confidence) + ");" + confidenceTax;
+ confidenceTax = seqTax.name + "(" + toString(((confidence/(float)iters) * 100)) + ");" + confidenceTax;
simpleTax = seqTax.name + ";" + simpleTax;
}
}
catch(exception& e) {
- errorOut(e, "Bayesian", "bootstrapResults");
+ m->errorOut(e, "Bayesian", "bootstrapResults");
exit(1);
}
}
return indexofGenus;
}
catch(exception& e) {
- errorOut(e, "Bayesian", "getMostProbableTaxonomy");
+ m->errorOut(e, "Bayesian", "getMostProbableTaxonomy");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "Bayesian", "parseTax");
+ m->errorOut(e, "Bayesian", "parseTax");
exit(1);
}
}
in.close();
}
catch(exception& e) {
- errorOut(e, "Bayesian", "readProbFile");
+ m->errorOut(e, "Bayesian", "readProbFile");
exit(1);
}
}