Example #1
0
    def test_consensus_tree_branch_lengths(self):
        """consensus trees should average branch lengths properly"""
        def get_ac(tree):
            for edge in tree.getEdgeVector(include_root=False):
                if set('ac') == set([c.Name for c in edge.Children]):
                    return edge

        sct = ScoredTreeCollection(self.unrooted_trees_lengths)
        ct = sct.getConsensusTree()
        maj_tree = self.unrooted_trees_lengths[0][1]
        self.assertTrue(abs(get_ac(ct).Length-get_ac(maj_tree).Length) < 1e-9)

        sct = ScoredTreeCollection(self.rooted_trees_lengths)
        ct = sct.getConsensusTree(method='rooted')
        maj_tree = self.rooted_trees_lengths[0][1]
        self.assertTrue(abs(get_ac(ct).Length-get_ac(maj_tree).Length) < 1e-9)
Example #2
0
    def test_consensus_tree_branch_lengths(self):
        """consensus trees should average branch lengths properly"""
        def get_ac(tree):
            for edge in tree.getEdgeVector(include_root=False):
                if set('ac') == set([c.Name for c in edge.Children]):
                    return edge

        sct = ScoredTreeCollection(self.unrooted_trees_lengths)
        ct = sct.getConsensusTree()
        maj_tree = self.unrooted_trees_lengths[0][1]
        self.assertTrue(
            abs(get_ac(ct).Length - get_ac(maj_tree).Length) < 1e-9)

        sct = ScoredTreeCollection(self.rooted_trees_lengths)
        ct = sct.getConsensusTree(method='rooted')
        maj_tree = self.rooted_trees_lengths[0][1]
        self.assertTrue(
            abs(get_ac(ct).Length - get_ac(maj_tree).Length) < 1e-9)