X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=phylotree.cpp;h=dba1e3b56951f8ae1c484ace22187a9b65053d35;hb=8dd3c225255d7084e3aff8740aa4f1f1cabb367a;hp=2ea219350c1f8bf8099b7cfc40d28ddcdfc9d872;hpb=050220fe7822cc660615972a0054cf4a83eefbe4;p=mothur.git diff --git a/phylotree.cpp b/phylotree.cpp index 2ea2193..dba1e3b 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"); @@ -55,24 +56,24 @@ PhyloTree::PhyloTree(ifstream& in, string filename){ delete buffer; //read version - getline(iss); gobble(iss); + m->getline(iss); m->gobble(iss); - iss >> numNodes; gobble(iss); + iss >> numNodes; m->gobble(iss); tree.resize(numNodes); for (int i = 0; i < tree.size(); i++) { - iss >> tree[i].name >> tree[i].level >> tree[i].parent; gobble(iss); + iss >> tree[i].name >> tree[i].level >> tree[i].parent; m->gobble(iss); } //read genus nodes int numGenus = 0; - iss >> numGenus; gobble(iss); + iss >> numGenus; m->gobble(iss); int gnode, gsize; totals.clear(); for (int i = 0; i < numGenus; i++) { - iss >> gnode >> gsize; gobble(iss); + iss >> gnode >> gsize; m->gobble(iss); uniqueTaxonomies[gnode] = gnode; totals.push_back(gsize); @@ -82,24 +83,24 @@ PhyloTree::PhyloTree(ifstream& in, string filename){ #else //read version - string line = getline(in); gobble(in); + string line = m->getline(in); m->gobble(in); - in >> numNodes; gobble(in); + in >> numNodes; m->gobble(in); tree.resize(numNodes); for (int i = 0; i < tree.size(); i++) { - in >> tree[i].name >> tree[i].level >> tree[i].parent; gobble(in); + in >> tree[i].name >> tree[i].level >> tree[i].parent; m->gobble(in); } //read genus nodes int numGenus = 0; - in >> numGenus; gobble(in); + in >> numGenus; m->gobble(in); int gnode, gsize; totals.clear(); for (int i = 0; i < numGenus; i++) { - in >> gnode >> gsize; gobble(in); + in >> gnode >> gsize; m->gobble(in); uniqueTaxonomies[gnode] = gnode; totals.push_back(gsize); @@ -127,11 +128,12 @@ PhyloTree::PhyloTree(string tfile){ maxLevel = 0; calcTotals = true; string name, tax; + addSeqToTree("unknown", "unknown;"); #ifdef USE_MPI int pid, num, processors; - vector positions; + vector positions; MPI_Status status; MPI_File inMPI; @@ -144,7 +146,7 @@ PhyloTree::PhyloTree(string tfile){ MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer if (pid == 0) { - positions = setFilePosEachLine(tfile, num); + positions = m->setFilePosEachLine(tfile, num); //send file positions to all processes for(int i = 1; i < processors; i++) { @@ -179,11 +181,11 @@ PhyloTree::PhyloTree(string tfile){ #else ifstream in; - openInputFile(tfile, in); + m->openInputFile(tfile, in); //read in users taxonomy file and add sequences to tree while(!in.eof()){ - in >> name >> tax; gobble(in); + in >> name >> tax; m->gobble(in); addSeqToTree(name, tax); } @@ -232,7 +234,6 @@ string PhyloTree::getNextTaxon(string& heirarchy, string seqname){ int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){ try { - numSeqs++; map::iterator childPointer; @@ -241,6 +242,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 +278,8 @@ int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){ if (seqTaxonomy == "") { uniqueTaxonomies[currentNode] = currentNode; } } + + return 0; } catch(exception& e) { m->errorOut(e, "PhyloTree", "addSeqToTree"); @@ -365,13 +370,13 @@ void PhyloTree::binUnclassified(string file){ try { ofstream out; - openOutputFile(file, out); + m->openOutputFile(file, out); map::iterator itBin; map::iterator childPointer; vector copy = tree; - + //fill out tree fillOutTree(0, copy); @@ -480,16 +485,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; @@ -519,7 +524,7 @@ void PhyloTree::printTreeNodes(string treefilename) { #endif ofstream outTree; - openOutputFile(treefilename, outTree); + m->openOutputFile(treefilename, outTree); //output mothur version outTree << "#" << m->getVersion() << endl; @@ -602,6 +607,7 @@ bool PhyloTree::ErrorCheck(vector templateFileNames){ try { bool okay = true; + templateFileNames.push_back("unknown"); map::iterator itFind; map taxonomyFileNames = name2Taxonomy; @@ -616,9 +622,10 @@ bool PhyloTree::ErrorCheck(vector templateFileNames){ 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;