X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=phylotree.cpp;h=2e3136e1f42e1a93d15fcab921b2e612f55f3997;hb=e9a30aafc8985389dd99301ca6f2898f52c4d214;hp=8a7c712b0f255db20da492fd95bc15d3116ce151;hpb=159fd324dfecacb6617669246d85c787ae67f630;p=mothur.git diff --git a/phylotree.cpp b/phylotree.cpp index 8a7c712..2e3136e 100644 --- a/phylotree.cpp +++ b/phylotree.cpp @@ -233,6 +233,48 @@ string PhyloTree::getNextTaxon(string& heirarchy, string seqname){ exit(1); } } +/**************************************************************************************************/ + +vector PhyloTree::getSeqs(string seqTaxonomy){ + try { + string taxCopy = seqTaxonomy; + vector names; + map::iterator childPointer; + + int currentNode = 0; + + m->removeConfidences(seqTaxonomy); + + string taxon; + while(seqTaxonomy != ""){ + + if (m->control_pressed) { return names; } + + taxon = getNextTaxon(seqTaxonomy, ""); + + if (m->debug) { m->mothurOut(taxon +'\n'); } + + if (taxon == "") { m->mothurOut(taxCopy + " has an error in the taxonomy. This may be due to a ;;"); m->mothurOutEndLine(); break; } + + childPointer = tree[currentNode].children.find(taxon); + + if(childPointer != tree[currentNode].children.end()){ //if the node already exists, move on + currentNode = childPointer->second; + } + else{ //otherwise, error this taxonomy is not in tree + m->mothurOut("[ERROR]: " + taxCopy + " is not in taxonomy tree, please correct."); m->mothurOutEndLine(); m->control_pressed = true; return names; + } + + if (seqTaxonomy == "") { names = tree[currentNode].accessions; } + } + + return names; + } + catch(exception& e) { + m->errorOut(e, "PhyloTree", "getSeqs"); + exit(1); + } +} /**************************************************************************************************/ @@ -259,6 +301,8 @@ int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){ //somehow the parent is getting one too many accnos //use print to reassign the taxa id taxon = getNextTaxon(seqTaxonomy, seqName); + + if (m->debug) { m->mothurOut(seqName +'\t' + taxon +'\n'); } if (taxon == "") { m->mothurOut(seqName + " has an error in the taxonomy. This may be due to a ;;"); m->mothurOutEndLine(); if (currentNode != 0) { uniqueTaxonomies.insert(currentNode); } break; } @@ -341,6 +385,9 @@ void PhyloTree::assignHeirarchyIDs(int index){ int counter = 1; for(it=tree[index].children.begin();it!=tree[index].children.end();it++){ + + if (m->debug) { m->mothurOut(toString(index) +'\t' + tree[it->second].name +'\n'); } + tree[it->second].heirarchyID = tree[index].heirarchyID + '.' + toString(counter); counter++; tree[it->second].level = tree[index].level + 1; @@ -399,6 +446,8 @@ void PhyloTree::binUnclassified(string file){ } } + if (m->debug) { m->mothurOut("maxLevel = " + toString(maxLevel) +'\n'); } + int copyNodes = copy.size(); //go through the seqs and if a sequence finest taxon is not the same level as the most finely defined taxon then classify it as unclassified where necessary @@ -409,11 +458,14 @@ void PhyloTree::binUnclassified(string file){ int level = copy[itLeaf->second].level; int currentNode = itLeaf->second; + + if (m->debug) { m->mothurOut(copy[currentNode].name +'\n'); } //this sequence is unclassified at some levels while(level < maxLevel){ level++; + if (m->debug) { m->mothurOut("level = " + toString(level) +'\n'); } string taxon = "unclassified";