+TaxNode PhyloTree::get(int i ){
+ try {
+ if (i < tree.size()) { return tree[i]; }
+ else { cout << i << '\t' << tree.size() << endl ; m->mothurOut("Mismatch with taxonomy and template files. Cannot continue."); m->mothurOutEndLine(); exit(1); }
+ }
+ catch(exception& e) {
+ m->errorOut(e, "PhyloTree", "get");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+TaxNode PhyloTree::get(string seqName){
+ try {
+ map<string, int>::iterator itFind = name2Taxonomy.find(seqName);
+
+ if (itFind != name2Taxonomy.end()) { return tree[name2Taxonomy[seqName]]; }
+ else { m->mothurOut("Cannot find " + seqName + ". Mismatch with taxonomy and template files. Cannot continue."); m->mothurOutEndLine(); exit(1);}
+ }
+ catch(exception& e) {
+ m->errorOut(e, "PhyloTree", "get");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+string PhyloTree::getName(int i ){
+ try {
+ if (i < tree.size()) { return tree[i].name; }
+ else { m->mothurOut("Mismatch with taxonomy and template files. Cannot continue."); m->mothurOutEndLine(); exit(1); }
+ }
+ catch(exception& e) {
+ m->errorOut(e, "PhyloTree", "get");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+int PhyloTree::getIndex(string seqName){
+ try {
+ map<string, int>::iterator itFind = name2Taxonomy.find(seqName);
+
+ if (itFind != name2Taxonomy.end()) { return name2Taxonomy[seqName]; }
+ else { m->mothurOut("Cannot find " + seqName + ". Mismatch with taxonomy and template files. Cannot continue."); m->mothurOutEndLine(); exit(1);}
+ }
+ catch(exception& e) {
+ m->errorOut(e, "PhyloTree", "get");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+bool PhyloTree::ErrorCheck(vector<string> templateFileNames){
+ try {
+
+ bool okay = true;
+ templateFileNames.push_back("unknown");
+
+ map<string, int>::iterator itFind;
+ map<string, int> 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();
+ okay = false;
+ }
+
+ //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;
+
+ for (itFind = taxonomyFileNames.begin(); itFind != taxonomyFileNames.end(); itFind++) {
+ m->mothurOut(itFind->first + " is in your taxonomy file and is not in your template file. Please correct."); m->mothurOutEndLine();
+ }
+ }
+
+ return okay;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "PhyloTree", "ErrorCheck");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+