void process_tree(struct rooted_tree *tree, struct parameters params) { struct llist *outgroup_nodes = get_outgroup_nodes(tree, params.labels); if (! params.deroot) { /* re-root according to outgroup nodes */ enum reroot_status result = reroot(tree, outgroup_nodes, params.i_node_lbl_as_support); switch (result) { case REROOT_OK: dump_newick(tree->root); break; case LCA_IS_TREE_ROOT: if (params.try_ingroup) try_ingroup(tree, params); else { fprintf (stderr, "ERROR: Outgroup's LCA is tree's root " "- cannot reroot. Try -l.\n"); } break; case NOT_PHYLOGRAM: fprintf (stderr, "ERROR: Tree must be a phylogram, but some " "branch lengths are not defined - aborting.\n"); break; default: assert(0); } destroy_all_rnodes(NULL); destroy_tree(tree); } else { enum deroot_status result = deroot(tree); switch (result) { case DEROOT_OK: dump_newick(tree->root); break; case NOT_BIFURCATING: fprintf (stderr, "ERROR: tree is already unrooted, or root" " has only 1 child - cannot deroot.\n"); break; case BALANCED: fprintf (stderr, "ERROR: can't decide which of root's " "children is the outgroup.\n"); break; case MEM_PROB: perror(NULL); break; default: assert(0); } destroy_all_rnodes(NULL); destroy_tree(tree); } destroy_llist(outgroup_nodes); }
void process_tree(struct rooted_tree *tree, struct parameters params) { struct llist *outgroup_nodes = get_outgroup_nodes(tree, params.labels); if (! params.deroot) { /* re-root according to outgroup nodes */ enum reroot_status result = reroot(tree, outgroup_nodes); switch (result) { case REROOT_OK: dump_newick(tree->root); break; case LCA_IS_TREE_ROOT: if (params.try_ingroup) try_ingroup(tree, params); else { fprintf (stderr, "Outgroup's LCA is tree's root " "- cannot reroot. Try -l.\n"); } break; default: assert(0); } destroy_tree_cb(tree, NULL); } else { enum deroot_status result = deroot(tree); switch (result) { case DEROOT_OK: dump_newick(tree->root); break; case NOT_BIFURCATING: fprintf (stderr, "WARNING: tree is already unrooted, or root" " has only 1 child - cannot deroot.\n"); break; case BALANCED: fprintf (stderr, "WARNING: can't decide which of root's " "children is the outgroup.\n"); break; default: assert(0); } destroy_tree_cb(tree, NULL); } destroy_llist(outgroup_nodes); }