def test_nj_dm1(self): self.assertEqual(nj(self.dm1, result_constructor=str), self.expected1_str) # what is the correct way to compare TreeNode objects for equality? actual_TreeNode = nj(self.dm1) self.assertEqual(actual_TreeNode.compare_tip_distances( self.expected1_TreeNode), 0.0)
def test_nj_dm1(self): self.assertEqual(nj(self.dm1, result_constructor=str), self.expected1_str) # what is the correct way to compare TreeNode objects for equality? actual_TreeNode = nj(self.dm1) self.assertEqual( actual_TreeNode.compare_tip_distances(self.expected1_TreeNode), 0.0)
def test_nj_zero_branch_length(self): # no nodes have negative branch length when we disallow negative # branch length. self is excluded as branch length is None tree = nj(self.dm4) for n in tree.postorder(include_self=False): self.assertTrue(n.length >= 0) # only tips associated with the large distance in the input # have positive branch lengths when we allow negative branch # length tree = nj(self.dm4, False) self.assertTrue(tree.find("a").length > 0) self.assertTrue(tree.find("b").length < 0) self.assertTrue(tree.find("c").length < 0) self.assertTrue(tree.find("d").length < 0) self.assertTrue(tree.find("e").length > 0)
def test_nj_trivial(self): data = [[0, 3, 2], [3, 0, 3], [2, 3, 0]] dm = DistanceMatrix(data, list('abc')) expected_str = "(b:2.000000, a:1.000000, c:1.000000);" self.assertEqual(nj(dm, result_constructor=str), expected_str)
def test_nj_dm3(self): actual_TreeNode = nj(self.dm3) self.assertAlmostEqual(actual_TreeNode.compare_tip_distances(self.expected3_TreeNode), 0.0)
def test_nj_dm3(self): actual_TreeNode = nj(self.dm3) self.assertAlmostEqual( actual_TreeNode.compare_tip_distances(self.expected3_TreeNode), 0.0)