X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=taxonomyequalizer.cpp;h=c0507261eaf2c96c9381172a646317c7cb6a1db3;hp=1d2832d5fc3a3ba31861d75d93dd202caf82261e;hb=1a20e24ee786195ab0e1cccd4f5aede7a88f3f4e;hpb=202846c98b9eff0eca7b20a570bfffa8ee4a5f4e diff --git a/taxonomyequalizer.cpp b/taxonomyequalizer.cpp index 1d2832d..c050726 100644 --- a/taxonomyequalizer.cpp +++ b/taxonomyequalizer.cpp @@ -16,7 +16,7 @@ TaxEqualizer::TaxEqualizer(string tfile, int c, string o) : cutoff(c), outputDir containsConfidence = false; ifstream inTax; - openInputFile(tfile, inTax); + m->openInputFile(tfile, inTax); highestLevel = getHighestLevel(inTax); @@ -32,11 +32,11 @@ TaxEqualizer::TaxEqualizer(string tfile, int c, string o) : cutoff(c), outputDir inTax.close(); ifstream in; - openInputFile(tfile, in); + m->openInputFile(tfile, in); ofstream out; - equalizedFile = outputDir + getRootName(getSimpleName(tfile)) + "equalized.taxonomy"; - openOutputFile(equalizedFile, out); + equalizedFile = outputDir + m->getRootName(m->getSimpleName(tfile)) + "equalized.taxonomy"; + m->openOutputFile(equalizedFile, out); string name, tax; @@ -44,9 +44,9 @@ TaxEqualizer::TaxEqualizer(string tfile, int c, string o) : cutoff(c), outputDir if (m->control_pressed) { break; } - in >> name >> tax; gobble(in); + in >> name >> tax; m->gobble(in); - if (containsConfidence) { removeConfidences(tax); } + if (containsConfidence) { m->removeConfidences(tax); } //is this a taxonomy that needs to be extended? if (seqLevels[name] < highestLevel) { @@ -61,7 +61,7 @@ TaxEqualizer::TaxEqualizer(string tfile, int c, string o) : cutoff(c), outputDir in.close(); out.close(); - if (m->control_pressed) { remove(equalizedFile.c_str()); } + if (m->control_pressed) { m->mothurRemove(equalizedFile); } }else { inTax.close(); } } @@ -78,7 +78,7 @@ int TaxEqualizer::getHighestLevel(ifstream& in) { string name, tax; while (in) { - in >> name >> tax; gobble(in); + in >> name >> tax; m->gobble(in); //count levels in this taxonomy int thisLevel = 0; @@ -152,29 +152,4 @@ void TaxEqualizer::truncateTaxonomy(string name, string& tax, int desiredLevel) } } /**************************************************************************************************/ -void TaxEqualizer::removeConfidences(string& tax) { - try { - - string taxon; - string newTax = ""; - - while (tax.find_first_of(';') != -1) { - //get taxon - taxon = tax.substr(0,tax.find_first_of(';')); - taxon = taxon.substr(0, taxon.find_first_of('(')); //rip off confidence - taxon += ";"; - - tax = tax.substr(tax.find_first_of(';')+1, tax.length()); - newTax += taxon; - } - - tax = newTax; - } - catch(exception& e) { - m->errorOut(e, "TaxEqualizer", "removeConfidences"); - exit(1); - } -} - -/**************************************************************************************************/