Пример #1
0
 def testNormalized1(self):
     for i in xrange(0xFF):
         s = treesplit.split_as_string(i, 8, ".", "*")[::-1]
         r = paup.paup_group_to_mask(s, normalized=True)
         normalized = containers.NormalizedBitmaskDict.normalize(i, 0xFF)
         self.assertEqual(r, normalized, "%s  =>  %s  =>  %s" \
             % (treesplit.split_as_string(i, 8), s, treesplit.split_as_string(normalized, 8)))
Пример #2
0
        def count_splits(self, is_rooted=False):
            if self.tree_filepath is None:
                _LOG.warning("Null Test Case")
                return
            p = paup.PaupRunner()
            p.stage_execute_file(self.taxa_filepath, clear_trees=True)
            p.stage_list_taxa()
            p.stage_load_trees(tree_filepaths=[self.tree_filepath], is_rooted=is_rooted)
            p.stage_count_splits()
            p.run()
            taxon_set = p.parse_taxon_set()
            tree_count, bipartition_counts = p.parse_group_freqs()

            self.assertEqual(self.expected_num_trees, tree_count)
            self.assertEqual(len(self.expected_split_freqs), len(bipartition_counts))
            for g in self.expected_split_freqs:
                self.assertIn(g, bipartition_counts)
                self.assertEqual(self.expected_split_freqs[g], bipartition_counts[g])

            sd = paup.build_split_distribution(bipartition_counts,
                                               tree_count,
                                               taxon_set,
                                               is_rooted=is_rooted)
            sf = sd.split_frequencies
            for g in bipartition_counts:
                s = paup.paup_group_to_mask(g, normalized=not is_rooted)
                self.assertIn(s, sd.splits)
                self.assertIn(s, sd.split_counts)
                self.assertEqual(sd.split_counts[s], bipartition_counts[g])
                self.assertEqual(sd.total_trees_counted, self.expected_num_trees)
                self.assertAlmostEqual(sf[s], float(bipartition_counts[g]) / self.expected_num_trees)
Пример #3
0
 def testUnnormalized(self):
     for i in xrange(0xFF):
         s = treesplit.split_as_string(i, 8, ".", "*")[::-1]
         r = paup.paup_group_to_mask(s, normalized=False)
         self.assertEqual(r, i, "%s  =>  %s  =>  %s" \
             % (treesplit.split_as_string(i, 8), s, treesplit.split_as_string(r, 8)))
Пример #4
0
 def testUnnormalized(self):
     for i in xrange(0xFF):
         s = treesplit.split_as_string(i, 8, ".", "*")[::-1]
         r = paup.paup_group_to_mask(s, normalized=False)
         self.assertEqual(r, i, "%s  =>  %s  =>  %s" \
             % (treesplit.split_as_string(i, 8), s, treesplit.split_as_string(r, 8)))