Exemplo n.º 1
0
    def test_weighted_trees_satisyfing_cutoff(self):
        """build consensus tree from those satisfying cutoff"""
        sct = LogLikelihoodScoredTreeCollection(self.scored_trees)
        cts = sct.get_weighted_trees(cutoff=0.8)
        for weight, tree in cts:
            self.assertTrue(tree.same_topology(Tree("((a,b),c,d);")))

        ct = cts.get_consensus_tree()
        self.assertTrue(ct.same_topology(Tree("((a,b),c,d);")))
Exemplo n.º 2
0
 def test_weighted_consensus_from_scored_trees_collection_ii(self):
     """root positions in input tree collection should not effect result"""
     sct = LogLikelihoodScoredTreeCollection(self.trees_randomly_rooted)
     ctrr = sct.get_consensus_tree()
     sct = LogLikelihoodScoredTreeCollection(self.trees_rooted_at_A)
     ctra = sct.get_consensus_tree()
     self.assertTrue(ctrr.same_topology(ctra))
Exemplo n.º 3
0
    def test_tree_collection_read_write_file(self):
        """should correctly read / write a collection from a file"""

        def eval_klass(coll):
            coll.write("sample.trees")
            read = make_trees("sample.trees")
            self.assertTrue(type(read) == type(coll))

        eval_klass(LogLikelihoodScoredTreeCollection(self.scored_trees))

        # convert lnL into p
        eval_klass(WeightedTreeCollection([(exp(s), t) for s, t in self.scored_trees]))
        remove_files(["sample.trees"], error_on_missing=False)
Exemplo n.º 4
0
 def test_weighted_consensus_from_scored_trees_collection(self):
     """weighted consensus from a tree collection should be different"""
     sct = LogLikelihoodScoredTreeCollection(self.scored_trees)
     ct = sct.get_consensus_tree()
     self.assertTrue(ct.same_topology(Tree("((a,b),c,d);")))
Exemplo n.º 5
0
 def test_consensus_from_scored_trees_collection(self):
     """tree collection should get same consensus as direct approach"""
     tree_list = [(i * -1, t) for i, t in enumerate(self.trees)]
     sct = LogLikelihoodScoredTreeCollection(tree_list)
     ct = sct.get_consensus_tree()
     self.assertTrue(ct.same_topology(Tree("((c,d),a,b);")))