+/*****************************************************************/
+void Tree::printBranch(int node, ostream& out, string mode, vector<Node>& theseNodes) {
+ try {
+
+ // you are not a leaf
+ if (theseNodes[node].getLChild() != -1) {
+ out << "(";
+ printBranch(theseNodes[node].getLChild(), out, mode);
+ out << ",";
+ printBranch(theseNodes[node].getRChild(), out, mode);
+ out << ")";
+ if (mode == "branch") {
+ //if there is a branch length then print it
+ if (theseNodes[node].getBranchLength() != -1) {
+ out << ":" << theseNodes[node].getBranchLength();
+ }
+ }else if (mode == "boot") {
+ //if there is a label then print it
+ if (theseNodes[node].getLabel() != -1) {
+ out << theseNodes[node].getLabel();
+ }
+ }else if (mode == "both") {
+ if (theseNodes[node].getLabel() != -1) {
+ out << theseNodes[node].getLabel();
+ }
+ //if there is a branch length then print it
+ if (theseNodes[node].getBranchLength() != -1) {
+ out << ":" << theseNodes[node].getBranchLength();
+ }
+ }
+ }else { //you are a leaf
+ vector<string> leafGroup = ct->getGroups(theseNodes[node].getName());
+
+ if (mode == "branch") {
+ out << leafGroup[0];
+ //if there is a branch length then print it
+ if (theseNodes[node].getBranchLength() != -1) {
+ out << ":" << theseNodes[node].getBranchLength();
+ }
+ }else if (mode == "boot") {
+ out << leafGroup[0];
+ //if there is a label then print it
+ if (theseNodes[node].getLabel() != -1) {
+ out << theseNodes[node].getLabel();
+ }
+ }else if (mode == "both") {
+ out << theseNodes[node].getName();
+ if (theseNodes[node].getLabel() != -1) {
+ out << theseNodes[node].getLabel();
+ }
+ //if there is a branch length then print it
+ if (theseNodes[node].getBranchLength() != -1) {
+ out << ":" << theseNodes[node].getBranchLength();
+ }
+ }
+ }
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Tree", "printBranch");
+ exit(1);
+ }
+}