#include "phylosummary.h"
#include "referencedb.h"
/**************************************************************************************************/
-Bayesian::Bayesian(string tfile, string tempFile, string method, int ksize, int cutoff, int i) :
+Bayesian::Bayesian(string tfile, string tempFile, string method, int ksize, int cutoff, int i, int tid) :
Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) {
try {
ReferenceDB* rdb = ReferenceDB::getInstance();
+ threadID = tid;
string baseName = tempFile;
+
if (baseName == "saved") { baseName = rdb->getSavedReference(); }
string baseTName = tfile;
}
//if you want to save, but you dont need to calculate then just read
- if (rdb->save && probFileTest && probFileTest2 && phyloTreeTest && probFileTest3 && FilesGood) {
+ if (rdb->save && probFileTest && probFileTest2 && phyloTreeTest && probFileTest3 && FilesGood && (tempFile != "saved")) {
ifstream saveIn;
m->openInputFile(tempFile, saveIn);
//cout << numKmers << '\t' << genusNodes.size() << endl;
for (int j = 0; j < wordGenusProb.size(); j++) { wordGenusProb[j].resize(genusNodes.size()); }
//cout << numKmers << '\t' << genusNodes.size() << endl;
- ofstream out;
- ofstream out2;
+ //ofstream out;
+ //ofstream out2;
#ifdef USE_MPI
int pid;
#endif
- m->openOutputFile(probFileName, out);
+ //m->openOutputFile(probFileName, out);
//output mothur version
- out << "#" << m->getVersion() << endl;
+ //out << "#" << m->getVersion() << endl;
- out << numKmers << endl;
+ //out << numKmers << endl;
- m->openOutputFile(probFileName2, out2);
+ //m->openOutputFile(probFileName2, out2);
//output mothur version
- out2 << "#" << m->getVersion() << endl;
+ //out2 << "#" << m->getVersion() << endl;
#ifdef USE_MPI
}
if (pid == 0) {
#endif
- out << i << '\t';
+ //out << i << '\t';
#ifdef USE_MPI
}
if (pid == 0) {
#endif
- out << k << '\t' << wordGenusProb[i][k] << '\t';
+ //out << k << '\t' << wordGenusProb[i][k] << '\t';
#ifdef USE_MPI
}
if (pid == 0) {
#endif
- out << endl;
- out2 << probabilityInTemplate << '\t' << numNotZero << endl;
+ //out << endl;
+ //out2 << probabilityInTemplate << '\t' << numNotZero << endl;
#ifdef USE_MPI
}
if (pid == 0) {
#endif
- out.close();
- out2.close();
+ //out.close();
+ //out2.close();
#ifdef USE_MPI
}
#ifdef USE_MPI
int pid, num, num2, processors;
- vector<unsigned long int> positions;
- vector<unsigned long int> positions2;
+ vector<unsigned long long> positions;
+ vector<unsigned long long> positions2;
MPI_Status status;
MPI_File inMPI;
string line = m->getline(in); m->gobble(in);
in >> numKmers; m->gobble(in);
-
+ //cout << threadID << '\t' << line << '\t' << numKmers << &in << '\t' << &inNum << '\t' << genusNodes.size() << endl;
//initialze probabilities
wordGenusProb.resize(numKmers);
//read version
string line2 = m->getline(inNum); m->gobble(inNum);
-
+ //cout << threadID << '\t' << line2 << '\t' << this << endl;
while (inNum) {
inNum >> zeroCountProb[count] >> num[count];
count++;
m->gobble(inNum);
+ //cout << threadID << '\t' << count << endl;
}
inNum.close();
-
+ //cout << threadID << '\t' << "here1 " << &wordGenusProb << '\t' << &num << endl; //
+ //cout << threadID << '\t' << &genusTotals << '\t' << endl;
+ //cout << threadID << '\t' << genusNodes.size() << endl;
while(in) {
in >> kmer;
-
+ //cout << threadID << '\t' << kmer << endl;
//set them all to zero value
for (int i = 0; i < genusNodes.size(); i++) {
wordGenusProb[kmer][i] = log(zeroCountProb[kmer] / (float) (genusTotals[i]+1));
}
-
+ //cout << threadID << '\t' << num[kmer] << "here" << endl;
//get probs for nonzero values
for (int i = 0; i < num[kmer]; i++) {
in >> name >> prob;
m->gobble(in);
}
in.close();
-
+ //cout << threadID << '\t' << "here" << endl;
#endif
}
catch(exception& e) {