Beispiel #1
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.getConsensusTree()
     sct = LogLikelihoodScoredTreeCollection(self.trees_rooted_at_A)
     ctra = sct.getConsensusTree()
     self.assertTrue(ctrr.sameTopology(ctra))
Beispiel #2
0
    def test_weighted_trees_satisyfing_cutoff(self):
        """build consensus tree from those satisfying cutoff"""
        sct = LogLikelihoodScoredTreeCollection(self.scored_trees)
        cts = sct.getWeightedTrees(cutoff=0.8)
        for weight, tree in cts:
            self.assertTrue(tree.sameTopology(Tree('((a,b),c,d);')))

        ct = cts.getConsensusTree()
        self.assertTrue(ct.sameTopology(Tree("((a,b),c,d);")))
Beispiel #3
0
 def test_weighted_trees_satisyfing_cutoff(self):
     """build consensus tree from those satisfying cutoff"""
     sct = LogLikelihoodScoredTreeCollection(self.scored_trees)
     cts = sct.getWeightedTrees(cutoff=0.8)
     for weight, tree in cts:
         self.assertTrue(tree.sameTopology(Tree('((a,b),c,d);')))
     
     ct = cts.getConsensusTree()
     self.assertTrue(ct.sameTopology(Tree("((a,b),c,d);")))
Beispiel #4
0
 def test_weighted_trees_satisyfing_cutoff(self):
     """build consensus tree from those satisfying cutoff"""
     sct = LogLikelihoodScoredTreeCollection(self.scored_trees)
     cts = sct.getWeightedTrees(cutoff=0.8)
     expected_trees = [Tree(t) for t in "((a,b),(c,d));", "((a,b),(c,d));",
                             "((a,b),c,d);"]
     for i in range(len(cts)):
         cts[i][1].sameTopology(expected_trees[i])
     
     ct = cts.getConsensusTree()
     self.assertTrue(ct.sameTopology(Tree("((a,b),(c,d));")))
Beispiel #5
0
 def test_weighted_trees_satisyfing_cutoff(self):
     """build consensus tree from those satisfying cutoff"""
     sct = LogLikelihoodScoredTreeCollection(self.scored_trees)
     cts = sct.getWeightedTrees(cutoff=0.8)
     expected_trees = [Tree(t) for t in "((a,b),(c,d));", "((a,b),(c,d));",
                             "((a,b),c,d);"]
     for i in range(len(cts)):
         cts[i][1].sameTopology(expected_trees[i])
     
     ct = cts.getConsensusTree()
     self.assertTrue(ct.sameTopology(Tree("((a,b),(c,d));")))
Beispiel #6
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.getConsensusTree()
     sct = LogLikelihoodScoredTreeCollection(self.trees_rooted_at_A)
     ctra = sct.getConsensusTree()
     self.assertTrue(ctrr.sameTopology(ctra))
Beispiel #7
0
 def test_tree_collection_read_write_file(self):
     """should correctly read / write a collection from a file"""
     def eval_klass(coll):
         coll.writeToFile('sample.trees')
         read = LoadTrees('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)
Beispiel #8
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.getConsensusTree()
     self.assertTrue(ct.sameTopology(Tree("((a,b),c,d);")))
Beispiel #9
0
 def test_consensus_from_scored_trees_collection(self):
     """tree collection should get same consensus as direct approach"""
     tree_list = [(1, t) for t in self.trees]
     sct = LogLikelihoodScoredTreeCollection(tree_list)
     ct = sct.getConsensusTree()
     self.assertTrue(ct.sameTopology(Tree("((c,d),a,b);")))
Beispiel #10
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.getConsensusTree()
     self.assertTrue(ct.sameTopology(Tree("((a,b),(c,d));")))
Beispiel #11
0
 def test_consensus_from_scored_trees_collection(self):
     """tree collection should get same consensus as direct approach"""
     sct = LogLikelihoodScoredTreeCollection([(1, t) for t in self.trees])
     ct = sct.getConsensusTree()
     self.assertTrue(ct.sameTopology(Tree("((c,d),(a,b));")))