예제 #1
0
 def testRobinsonFoulds(self):
     """
     The correct Robinson Foulds distance must be calculated.
     """
     njtree1 = NJTree()
     njtree2 = NJTree()
     njtree1.tree = TreeNode.read(StringIO('((a,b),(c,d));'))
     njtree2.tree = TreeNode.read(StringIO('(((a,b),c),d);'))
     distance = njtree1.robinsonFoulds(njtree2)
     self.assertEqual(2.0, distance)
예제 #2
0
 def testRobinsonFouldsCompareAgainstItself(self):
     """
     If a tree is compared against itself, the Robinson Foulds distance must
     be 0.0.
     """
     njtree1 = NJTree()
     njtree2 = NJTree()
     njtree1.tree = TreeNode.read(StringIO('((a,b),(c,d));'))
     njtree2.tree = TreeNode.read(StringIO('((a,b),(c,d));'))
     distance = njtree1.robinsonFoulds(njtree2)
     self.assertEqual(0.0, distance)
예제 #3
0
 def testRobinsonFouldsProportionTrueReversed(self):
     """
     The correct Robinson Foulds distance must be calculated with
     proportion=True, if the trees are passed in reverse order.
     """
     njtree1 = NJTree()
     njtree2 = NJTree()
     njtree1.tree = TreeNode.read(StringIO('((a,b),(c,d));'))
     njtree2.tree = TreeNode.read(StringIO('(((a,b),c),d);'))
     distance = njtree2.robinsonFoulds(njtree1, proportion=True)
     self.assertEqual(0.5, distance)