X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=phylosummary.cpp;h=5f7bbc3c73a2161417a1841f567719a4bd1f8c4a;hb=f06b339c5fc4b6d1b9d2a08fe16bf7670bf7aeb4;hp=b645bac794777a1050de116407fa834370e7940e;hpb=4f2c7f477a1ef2d60a1c0c84ab1ba8243af67f87;p=mothur.git diff --git a/phylosummary.cpp b/phylosummary.cpp index b645bac..5f7bbc3 100644 --- a/phylosummary.cpp +++ b/phylosummary.cpp @@ -25,7 +25,7 @@ PhyloSummary::PhyloSummary(string refTfile, string groupFile){ } //check for necessary files - string taxFileNameTest = refTfile.substr(0,refTfile.find_last_of(".")+1) + "tree.sum"; + string taxFileNameTest = m->getFullPathName((refTfile.substr(0,refTfile.find_last_of(".")+1) + "tree.sum")); ifstream FileTest(taxFileNameTest.c_str()); if (!FileTest) { @@ -73,24 +73,16 @@ PhyloSummary::PhyloSummary(string groupFile){ int PhyloSummary::summarize(string userTfile){ try { - - ifstream in; - m->openInputFile(userTfile, in); - - //read in users taxonomy file and add sequences to tree - string name, tax; - int numSeqs = 0; - while(!in.eof()){ - in >> name >> tax; m->gobble(in); - - addSeqToTree(name, tax); + map temp; + m->readTax(userTfile, temp); + + for (map::iterator itTemp = temp.begin(); itTemp != temp.end();) { + addSeqToTree(itTemp->first, itTemp->second); numSeqs++; - - if (m->control_pressed) { break; } - } - in.close(); - - return numSeqs; + temp.erase(itTemp++); + } + + return numSeqs; } catch(exception& e) { m->errorOut(e, "PhyloSummary", "summarize"); @@ -121,6 +113,7 @@ string PhyloSummary::getNextTaxon(string& heirarchy){ int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){ try { + numSeqs++; map::iterator childPointer; @@ -131,7 +124,7 @@ int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){ int level = 0; //are there confidence scores, if so remove them - if (seqTaxonomy.find_first_of('(') != -1) { removeConfidences(seqTaxonomy); } + if (seqTaxonomy.find_first_of('(') != -1) { m->removeConfidences(seqTaxonomy); } while (seqTaxonomy != "") { @@ -229,7 +222,7 @@ int PhyloSummary::addSeqToTree(string seqTaxonomy, vector names){ int level = 0; //are there confidence scores, if so remove them - if (seqTaxonomy.find_first_of('(') != -1) { removeConfidences(seqTaxonomy); } + if (seqTaxonomy.find_first_of('(') != -1) { m->removeConfidences(seqTaxonomy); } while (seqTaxonomy != "") { @@ -496,35 +489,6 @@ void PhyloSummary::readTreeStruct(ifstream& in){ } } /**************************************************************************************************/ -void PhyloSummary::removeConfidences(string& tax) { - try { - - string taxon; - string newTax = ""; - - while (tax.find_first_of(';') != -1) { - //get taxon - taxon = tax.substr(0,tax.find_first_of(';')); - - int pos = taxon.find_first_of('('); - if (pos != -1) { - taxon = taxon.substr(0, pos); //rip off confidence - } - - taxon += ";"; - - tax = tax.substr(tax.find_first_of(';')+1, tax.length()); - newTax += taxon; - } - - tax = newTax; - } - catch(exception& e) { - m->errorOut(e, "PhyloSummary", "removeConfidences"); - exit(1); - } -} -/**************************************************************************************************/