X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=phylotree.cpp;h=4ed3d8c1c02e1c5a1ee93b9dd6143309f5606f5c;hb=2009a1a1f47e7467094d844e7c07ab8ddf7bb447;hp=1fd4e5d238119bbcd6be5c54fbd7013fcdfc27bd;hpb=260ae19c36cb11a53ddc5a75b5e507f8dd8b31d6;p=mothur.git diff --git a/phylotree.cpp b/phylotree.cpp index 1fd4e5d..4ed3d8c 100644 --- a/phylotree.cpp +++ b/phylotree.cpp @@ -20,6 +20,7 @@ PhyloTree::PhyloTree(){ tree[0].heirarchyID = "0"; maxLevel = 0; calcTotals = true; + addSeqToTree("unknown", "unknown;"); } catch(exception& e) { m->errorOut(e, "PhyloTree", "PhyloTree"); @@ -127,11 +128,10 @@ PhyloTree::PhyloTree(string tfile){ maxLevel = 0; calcTotals = true; string name, tax; - #ifdef USE_MPI int pid, num, processors; - vector positions; + vector positions; MPI_Status status; MPI_File inMPI; @@ -191,7 +191,16 @@ PhyloTree::PhyloTree(string tfile){ #endif assignHeirarchyIDs(0); - + + + string unknownTax = "unknown;"; + //added last taxon until you get desired level + for (int i = 1; i < maxLevel; i++) { + unknownTax += "unclassfied;"; + } + + addSeqToTree("unknown", unknownTax); + //create file for summary if needed setUp(tfile); } @@ -232,7 +241,6 @@ string PhyloTree::getNextTaxon(string& heirarchy, string seqname){ int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){ try { - numSeqs++; map::iterator childPointer; @@ -241,6 +249,8 @@ int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){ int level = 1; tree[0].accessions.push_back(seqName); + m->removeConfidences(seqTaxonomy); + string taxon;// = getNextTaxon(seqTaxonomy); while(seqTaxonomy != ""){ @@ -275,6 +285,8 @@ int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){ if (seqTaxonomy == "") { uniqueTaxonomies[currentNode] = currentNode; } } + + return 0; } catch(exception& e) { m->errorOut(e, "PhyloTree", "addSeqToTree"); @@ -371,7 +383,7 @@ void PhyloTree::binUnclassified(string file){ map::iterator childPointer; vector copy = tree; - + //fill out tree fillOutTree(0, copy); @@ -480,16 +492,16 @@ string PhyloTree::getFullTaxonomy(string seqName) { void PhyloTree::print(ofstream& out, vector& copy){ try { - + //output mothur version out << "#" << m->getVersion() << endl; out << copy.size() << endl; out << maxLevel << endl; - + for (int i = 0; i < copy.size(); i++) { - + out << copy[i].level << '\t'<< copy[i].name << '\t' << copy[i].children.size() << '\t'; map::iterator it; @@ -602,23 +614,27 @@ bool PhyloTree::ErrorCheck(vector templateFileNames){ try { bool okay = true; + templateFileNames.push_back("unknown"); map::iterator itFind; map taxonomyFileNames = name2Taxonomy; + if (m->debug) { m->mothurOut("[DEBUG]: in error check. Numseqs in template = " + toString(templateFileNames.size()) + ". Numseqs in taxonomy = " + toString(taxonomyFileNames.size()) + ".\n"); } + for (int i = 0; i < templateFileNames.size(); i++) { itFind = taxonomyFileNames.find(templateFileNames[i]); if (itFind != taxonomyFileNames.end()) { //found it so erase it taxonomyFileNames.erase(itFind); }else { - m->mothurOut(templateFileNames[i] + " is in your template file and is not in your taxonomy file. Please correct."); m->mothurOutEndLine(); + m->mothurOut("'" +templateFileNames[i] + "' is in your template file and is not in your taxonomy file. Please correct."); m->mothurOutEndLine(); okay = false; } - templateFileNames.erase(templateFileNames.begin()+i); - i--; + //templateFileNames.erase(templateFileNames.begin()+i); + //i--; } + templateFileNames.clear(); if (taxonomyFileNames.size() > 0) { //there are names in tax file that are not in template okay = false;