def setup(self): # create a test tree t = Tree() a = t.add_root({'title': 'A'}) b, br = t.add_node(a, {'title': 'B'}) c, br = t.add_node(a, {'title': 'C'}) d, br = t.add_node(b, {'title': 'D'}) e, br = t.add_node(b, {'title': 'E'}) f, br = t.add_node(c, {'title': 'F'}) g, br = t.add_node(c, {'title': 'G'}) self.tree = t
def setup(self): """ Build a tree that starts from root, radiates to AB, CD. EF and then A to F. """ t = Tree() r = t.add_root({'title': 'root'}) nab, b = t.add_node(r, {'title': 'AB'}, branch_props={ 'title': 'root-AB', 'distance': 1.0 }) na, b = t.add_node(nab, {'title': 'A'}, branch_props={ 'title': 'A-AB', 'distance': 1.1 }) nb, b = t.add_node(nab, {'title': 'B'}, branch_props={ 'title': 'B-AB', 'distance': 1.2 }) ncd, b = t.add_node(r, {'title': 'CD'}, branch_props={ 'title': 'root-CD', 'distance': 1.3 }) nc, b = t.add_node(ncd, {'title': 'C'}, branch_props={ 'title': 'C-CD', 'distance': 1.4 }) nd, b = t.add_node(ncd, {'title': 'D'}, branch_props={ 'title': 'D-CD', 'distance': 1.5 }) nef, b = t.add_node(r, {'title': 'EF'}, branch_props={ 'title': 'root-EF', 'distance': 1.6 }) ne, b = t.add_node(nef, {'title': 'E'}, branch_props={ 'title': 'E-EF', 'distance': 1.7 }) nf, b = t.add_node(nef, {'title': 'F'}, branch_props={ 'title': 'F-EF', 'distance': 1.8 }) self.tree = t
def setup(self): """ Build a tree that starts from root, radiates to AB, CD. EF and then A to F. Our tree is: - root - ABC - AB - A - B - C - DE - D - E """ t = Tree() r = t.add_root({'title': 'root'}) node_abc, b = t.add_node(r, {'title': 'ABC'}) node_de, b = t.add_node(r, {'title': 'DE'}) node_ab, b = t.add_node(node_abc, {'title': 'AB'}) node_c, b = t.add_node(node_abc, {'title': 'C'}) node_a, b = t.add_node(node_ab, {'title': 'A'}) node_b, b = t.add_node(node_ab, {'title': 'B'}) node_d, b = t.add_node(node_de, {'title': 'D'}) node_e, b = t.add_node(node_de, {'title': 'E'}) # record for use in test functions self.tree = t self.nodes = {} for n in [ r, node_a, node_b, node_c, node_d, node_e, node_ab, node_abc, node_de ]: self.nodes[n.title] = n self.solo_tree = Tree() self.solo_tree.add_root()
def setup(self): # make up a dummy tree to test upon from phylo.core.tree import Tree t = Tree() a = t.add_root({'title': 'A'}) b, br = t.add_node(a, {'title': 'B'}) c, br = t.add_node(a, {'title': 'C'}) d, br = t.add_node(b, {'title': 'D'}) e, br = t.add_node(b, {'title': 'E'}) f, br = t.add_node(c, {'title': 'F'}) g, br = t.add_node(c, {'title': 'G'}) self.tree = t # record the nodes for later convenience self.nodes = dict([(n.title, n) for n in t.nodes])
# create a test tree from phylo.core.tree import Tree t = Tree() a = t.add_root({'title': 'A'}) b, br = t.add_node(a, {'title': 'B'}) c, br = t.add_node(a, {'title': 'C'}) d, br = t.add_node(b, {'title': 'D'}) e, br = t.add_node(b, {'title': 'E'}) f, br = t.add_node(c, {'title': 'F'}) g, br = t.add_node(c, {'title': 'G'}) for n in t.nodes: print n print t.node_children(n) print