/**************************************************************************************************/
TaxEqualizer::TaxEqualizer(string tfile, int c) : cutoff(c) {
try {
+ m = MothurOut::getInstance();
containsConfidence = false;
ifstream inTax;
openInputFile(tfile, inTax);
- int highestLevel = getHighestLevel(inTax);
+ highestLevel = getHighestLevel(inTax);
//if the user has specified a cutoff and it's smaller than the highest level
if ((cutoff != -1) && (cutoff < highestLevel)) {
highestLevel = cutoff;
}else if (cutoff > highestLevel) {
- mothurOut("The highest level taxonomy you have is " + toString(highestLevel) + " and your cutoff is " + toString(cutoff) + ". I will set the cutoff to " + toString(highestLevel));
- mothurOutEndLine();
+ m->mothurOut("The highest level taxonomy you have is " + toString(highestLevel) + " and your cutoff is " + toString(cutoff) + ". I will set the cutoff to " + toString(highestLevel));
+ m->mothurOutEndLine();
}
- inTax.close();
- openInputFile(tfile, inTax);
+ inTax.close();
+ ifstream in;
+ openInputFile(tfile, in);
ofstream out;
equalizedFile = getRootName(tfile) + "equalized.taxonomy";
openOutputFile(equalizedFile, out);
string name, tax;
- while (inTax) {
- inTax >> name >> tax; gobble(inTax);
+ while (in) {
+ in >> name >> tax; gobble(in);
if (containsConfidence) { removeConfidences(tax); }
//is this a taxonomy that needs to be extended?
if (seqLevels[name] < highestLevel) {
extendTaxonomy(name, tax, highestLevel);
- }else if (seqLevels[name] > highestLevel) { //this can happen if hte user enters a cutoff
+ }else if (seqLevels[name] > highestLevel) { //this can happen if the user enters a cutoff
truncateTaxonomy(name, tax, highestLevel);
}
out << name << '\t' << tax << endl;
}
- inTax.close();
+ in.close();
out.close();
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "TaxEqualizer");
+ m->errorOut(e, "TaxEqualizer", "TaxEqualizer");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "getHighestLevel");
+ m->errorOut(e, "TaxEqualizer", "getHighestLevel");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "extendTaxonomy");
+ m->errorOut(e, "TaxEqualizer", "extendTaxonomy");
exit(1);
}
}
tax += ";";
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "truncateTaxonomy");
+ m->errorOut(e, "TaxEqualizer", "truncateTaxonomy");
exit(1);
}
}
tax = newTax;
}
catch(exception& e) {
- errorOut(e, "TaxEqualizer", "removeConfidences");
+ m->errorOut(e, "TaxEqualizer", "removeConfidences");
exit(1);
}
}