Exemplo n.º 1
0
 def test_format_summarize_taxa(self):
     """format_summarize_taxa functions as expected"""
     exp = '\n'.join(['Taxon\tfoo\tbar\tfoobar',
                      'a;b;c\t0\t1\t2',
                      'd;e;f\t3\t4\t5\n'])
     obs = ''.join(list(format_summarize_taxa(self.taxa_summary, \
                                              self.taxa_header)))
     self.assertEqual(obs, exp)
Exemplo n.º 2
0
    def test_format_summarize_taxa(self):
        """format_summarize_taxa functions as expected"""
        # Classic format.
        exp = "\n".join(["Taxon\tfoo\tbar\tfoobar", "a;b;c\t0\t1\t2", "d;e;f\t3\t4\t5\n"])
        obs = "".join(list(format_summarize_taxa(self.taxa_summary, self.taxa_header)))
        self.assertEqual(obs, exp)

        # BIOM format. Test by converting our expected output to a biom table
        # and comparing that to our observed table.
        exp = parse_classic_table_to_rich_table(exp.split("\n"), None, None, None, SparseTaxonTable)
        obs = "".join(list(format_summarize_taxa(self.taxa_summary, self.taxa_header, file_format="biom")))
        obs = parse_biom_table(obs)
        self.assertEqual(obs, exp)

        # Bad file_format argument.
        with self.assertRaises(ValueError):
            list(format_summarize_taxa(self.taxa_summary, self.taxa_header, file_format="foo"))
Exemplo n.º 3
0
    def test_format_summarize_taxa(self):
        """format_summarize_taxa functions as expected"""
        # Classic format.
        exp = '\n'.join(['Taxon\tfoo\tbar\tfoobar',
                         'a;b;c\t0\t1\t2',
                         'd;e;f\t3\t4\t5\n'])
        obs = ''.join(list(format_summarize_taxa(self.taxa_summary,
                                                 self.taxa_header)))
        self.assertEqual(obs, exp)

        # BIOM format. Test by converting our expected output to a biom table
        # and comparing that to our observed table.
        exp = parse_classic_table_to_rich_table(exp.split('\n'), None, None,
                                                None, SparseTaxonTable)
        obs = ''.join(list(format_summarize_taxa(self.taxa_summary,
                                                 self.taxa_header,
                                                 file_format='biom')))
        obs = parse_biom_table(obs)
        self.assertEqual(obs, exp)

        # Bad file_format argument.
        with self.assertRaises(ValueError):
            list(format_summarize_taxa(self.taxa_summary, self.taxa_header,
                 file_format='foo'))