]> git.donarmstrong.com Git - mothur.git/blobdiff - mothurout.cpp
working on chimera.perseus. made removeConfidences function smarter. Fixed bug in...
[mothur.git] / mothurout.cpp
index 90d6f37434d7cb4df231817be6d1759df80b45bb..32f3b85819bb05206cb789d4e41e70d02fcd2e65 100644 (file)
@@ -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);
+       }
+}
+/**************************************************************************************************/