+
+/***********************************************************************/
+void SharedChao1::updateBranchf1(IntNode* node, vector<int> bin, int index) {
+ try {
+ //if you have more than one group
+ if (index == (bin.size()-1)) {
+ if (bin[index] == 1) { node->lvalue++; node->rvalue++; }
+ else { node->rvalue++; }
+ }else {
+ if (bin[index] == 1) {
+ //follow path as if you are 1
+ updateBranchf1(node->left, bin, index+1);
+ }
+ //follow path as if you are +
+ updateBranchf1(node->right, bin, index+1);
+ }
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SharedChao1", "updateBranchf1");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+void SharedChao1::updateBranchf2(IntNode* node, vector<int> bin, int index) {
+ try {
+ //if you have more than one group
+ if (index == (bin.size()-1)) {
+ if (bin[index] == 2) { node->lvalue++; node->rvalue++; }
+ else { node->rvalue++; }
+ }else {
+ if (bin[index] == 2) {
+ //follow path as if you are 1
+ updateBranchf2(node->left, bin, index+1);
+ }
+ //follow path as if you are +
+ updateBranchf2(node->right, bin, index+1);
+ }
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SharedChao1", "updateBranchf2");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+void SharedChao1::setCoef(IntNode* node, int coef) {
+ try {
+ if (node->left != NULL) {
+ setCoef(node->left, coef+1);
+ setCoef(node->right, coef);
+ }else {
+ node->lcoef = coef+1;
+ node->rcoef = coef;
+ }
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SharedChao1", "setCoef");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+//for debugging purposes
+void SharedChao1::printTree() {
+
+ m->mothurOut("F1 leaves"); m->mothurOutEndLine();
+ printBranch(f1root);
+
+ m->mothurOut("F2 leaves"); m->mothurOutEndLine();
+ printBranch(f2root);
+
+
+}
+/*****************************************************************/
+void SharedChao1::printBranch(IntNode* node) {
+ try {
+
+ // you are not a leaf
+ if (node->left != NULL) {
+ printBranch(node->left);
+ printBranch(node->right);
+ }else { //you are a leaf
+ m->mothurOut(toString(node->lvalue)); m->mothurOutEndLine();
+ m->mothurOut(toString(node->rvalue)); m->mothurOutEndLine();
+ }
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SharedChao1", "printBranch");
+ exit(1);
+ }
+}
+
+/*****************************************************************/
+
+
+
+