コード例 #1
0
ファイル: test_tree.py プロジェクト: miklou/pycogent
 def test_addChildren(self):
     """RangeNode add_children should add specified # children to list"""
     t = RangeNode()
     t2 = RangeNode(Parent=t)
     t.addChildren(5)
     self.assertEqual(len(t.Children), 6)
     assert t.Children[0] is t2
     for c in t.Children:
         assert c.Parent is t
コード例 #2
0
ファイル: microarray.py プロジェクト: chungtseng/pycogent
    def __init__(self, Length=0, Array=None, *args, **kwargs):
        """Returns new MicroarrayNode object.

        Length:   float giving the branch length (sd to add to data)
        Array:          array of float giving the expression vector, or None
        Additional args for superclass:
        Name:           usually a text label giving the name of the node
        LeafRange:      range of leaves that the node spans
        Id:             unique numeric identifier from the node
        Children:       list of Node objects specifying the children
        Parent:         Node object specifying the parent
        """
        RangeNode.__init__(self, *args, **kwargs)
        self.Length = Length
        self.Array = Array
コード例 #3
0
ファイル: test_tree.py プロジェクト: miklou/pycogent
 def test_fromBreakpoints(self):
     """RangeNode fromBreakpoints should have correct topology"""
     breakpoints = [4,2,1,0,3,6,5]
     t = RangeNode.fromBreakpoints(breakpoints)
     #check number of leaves
     self.assertEqual(len(list(t.traverse())), 8)
     self.assertEqual(len(list(t.traverse(self_before=True))), 15)
     #check that leaves were created in right order
     self.assertEqual([i.Id for i in t.traverse()], range(8))
     #check that whole toplogy is right wrt ids...
     nodes = list(t.traverse(self_before=True))
     obs = [i.Id for i in nodes]
     exp = [8, 9, 11, 13, 0, 1, 2, 12, 3, 4, 10, 14, 5, 6, 7]
     self.assertEqual(obs, exp)
     #...and ranges
     obs = [i.LeafRange for i in nodes]
     exp = [(0,8),(0,5),(0,3),(0,2),(0,1),(1,2),(2,3),(3,5),(3,4),(4,5), \
         (5,8),(5,7),(5,6),(6,7),(7,8)]
     self.assertEqual(obs, exp)