PhyloTree::PhyloTree(){
try {
+ m = MothurOut::getInstance();
numNodes = 1;
numSeqs = 0;
tree.push_back(TaxNode("Root"));
maxLevel = 0;
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "PhyloTree");
+ m->errorOut(e, "PhyloTree", "PhyloTree");
exit(1);
}
}
PhyloTree::PhyloTree(string tfile){
try {
+ m = MothurOut::getInstance();
numNodes = 1;
numSeqs = 0;
tree.push_back(TaxNode("Root"));
assignHeirarchyIDs(0);
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "PhyloTree");
+ m->errorOut(e, "PhyloTree", "PhyloTree");
exit(1);
}
}
try {
string currentLevel = "";
if(heirarchy != ""){
- currentLevel=heirarchy.substr(0,heirarchy.find_first_of(';'));
- heirarchy=heirarchy.substr(heirarchy.find_first_of(';')+1);
+ int pos = heirarchy.find_first_of(';');
+ currentLevel=heirarchy.substr(0,pos);
+ if (pos != (heirarchy.length()-1)) { heirarchy=heirarchy.substr(pos+1); }
+ else { heirarchy = ""; }
}
return currentLevel;
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "getNextTaxon");
+ m->errorOut(e, "PhyloTree", "getNextTaxon");
exit(1);
}
}
/**************************************************************************************************/
-void PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){
+int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){
try {
numSeqs++;
level++;
+ if (m->control_pressed) { return 0; }
+
//somehow the parent is getting one too many accnos
//use print to reassign the taxa id
taxon = getNextTaxon(seqTaxonomy);
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "addSeqToTree");
+ m->errorOut(e, "PhyloTree", "addSeqToTree");
exit(1);
}
}
return genusIndex;
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "getGenusNodes");
+ m->errorOut(e, "PhyloTree", "getGenusNodes");
exit(1);
}
}
tree[it->second].heirarchyID = tree[index].heirarchyID + '.' + toString(counter);
counter++;
tree[it->second].level = tree[index].level + 1;
-
+
//save maxLevel for binning the unclassified seqs
if (tree[it->second].level > maxLevel) { maxLevel = tree[it->second].level; }
}
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "assignHeirarchyIDs");
+ m->errorOut(e, "PhyloTree", "assignHeirarchyIDs");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "binUnclassified");
+ m->errorOut(e, "PhyloTree", "binUnclassified");
exit(1);
}
}
return tax;
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "getFullTaxonomy");
+ m->errorOut(e, "PhyloTree", "getFullTaxonomy");
exit(1);
}
}
print(0, out);
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "print");
+ m->errorOut(e, "PhyloTree", "print");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PhyloTree", "print");
+ m->errorOut(e, "PhyloTree", "print");
exit(1);
}
}