X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothurout.cpp;h=32f3b85819bb05206cb789d4e41e70d02fcd2e65;hb=74dc92cf53df65fd8b14d8eaf35489bbecbccac6;hp=90d6f37434d7cb4df231817be6d1759df80b45bb;hpb=4c5e7a20a03ddc6feb49ff9d21fcb4c79bc5508d;p=mothur.git diff --git a/mothurout.cpp b/mothurout.cpp index 90d6f37..32f3b85 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -2020,6 +2020,46 @@ bool MothurOut::isContainingOnlyDigits(string input) { } } /**************************************************************************************************/ +int MothurOut::removeConfidences(string& tax) { + try { + + string taxon; + string newTax = ""; + + while (tax.find_first_of(';') != -1) { + + if (control_pressed) { return 0; } + + //get taxon + taxon = tax.substr(0,tax.find_first_of(';')); + + int pos = taxon.find_last_of('('); + if (pos != -1) { + //is it a number? + int pos2 = taxon.find_last_of(')'); + if (pos2 != -1) { + string confidenceScore = taxon.substr(pos+1, (pos2-(pos+1))); + if (isContainingOnlyDigits(confidenceScore)) { + taxon = taxon.substr(0, pos); //rip off confidence + } + } + } + taxon += ";"; + + tax = tax.substr(tax.find_first_of(';')+1, tax.length()); + newTax += taxon; + } + + tax = newTax; + + return 0; + } + catch(exception& e) { + errorOut(e, "MothurOut", "removeConfidences"); + exit(1); + } +} +/**************************************************************************************************/