def test_clone(): """ This test illustrates how a tree can be assembled programmatically. """ newick = '(A,B,(C,D)E)F' tree1 = parse_node(newick) def clone_node(n): c = Node(name=n.name) for nn in n.descendants: c.add_descendant(clone_node(nn)) return c assert clone_node(tree1).newick == newick
action='store_true', help= "If elements span multiple chains, report them as non-mapping. These will then be reported as gains or losses, according to the maximum-parsimony predictions. This is the default mapping behavior for bnMapper. By default, mapGL.pys will follow the mapping convention used by liftOver, whereas the longest mapped alignment is reported for split elements." ) parser.add_argument("-i", "--in_format", choices=["BED", "narrowPeak"], default="BED", help="Input file format.") opt = parser.parse_args() log.setLevel(LOG_LEVELS[opt.verbose]) # Load up the newick tree log.info("Parsing species tree: {}".format(opt.tree)) phylo_full = newick.parse_node(opt.tree) log.debug("Full tree:\n{}".format( phylo_full.ascii_art(show_internal=False, strict=True))) # Prune the terminal outgroup (furthest from the query species) # to use in ambiguous cases. For now, this is assumed to be the # last species in the leaves list. phylo_pruned = newick.parse_node(opt.tree) leaves = phylo_pruned.get_leaves() leaves[-1].ancestor.descendants.remove(leaves[-1]) phylo_pruned = newick.parse_node(leaves[-1].ancestor.newick) phylo_pruned.remove_redundant_nodes() log.debug("Pruned tree:\n{}".format( phylo_pruned.ascii_art(show_internal=False, strict=True))) leaves = phylo_full.get_leaf_names()