Пример #1
0
	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
Пример #2
0
 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
Пример #3
0
	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])
Пример #4
0
 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])
Пример #5
0
    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
Пример #6
0
	def setup (self):
		"""
		Build a tree that starts from root, radiates to ABC and DE and thence to AB (and
		A & B) and D and E.
		
		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
Пример #7
0
def test():
	"""
	Some code to walk the script through its paces.
	"""
	# make a tree
	from phylo.core.tree import Tree
	t = Tree()
	r = t.add_root ({'title': 'root'})
	nabcd, b = t.add_node (r, {'title': 'ABCD'})
	nef, b = t.add_node (r, {'title': 'EF'})
	nab, b = t.add_node (nabcd, {'title': 'AB'})
	ncd, b = t.add_node (nabcd, {'title': 'CD'})
	na, b = t.add_node (nab, {'title': 'A'})
	nb, b = t.add_node (nab, {'title': 'B'})
	nc, b = t.add_node (ncd, {'title': 'C'})
	nd, b = t.add_node (ncd, {'title': 'D'})
	ne, b = t.add_node (nef, {'title': 'E'})
	nf, b = t.add_node (nef, {'title': 'F'})
	
	from Bio.SeqRecord import SeqRecord
	from Bio.Seq import Seq
	from Bio.Align import MultipleSeqAlignment
	seqdata = [
		['A', 'XYGT'],
		['B', 'AYGT'],
		['C', 'ACGT'],
		['D', 'ACGT'],
		['E', 'ACGT'],
		['F', 'ACGT'],
	]
	srs = [SeqRecord (Seq (x[1]), id=x[0], name=x[0]) for x in seqdata]
	aln = MultipleSeqAlignment (srs)
	
	return t, aln
Пример #8
0
	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
Пример #9
0
    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()
Пример #10
0
# 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 

Пример #11
0
# 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