def test_qza_integration(self):
     table_qza = Artifact.import_data("FeatureTable[Frequency]", self.table)
     taxonomy_qza = Artifact.import_data(
         "FeatureData[Taxonomy]",
         self.taxonomy_df,
     )
     table = table_qza.view(biom.Table)
     taxonomy_df = taxonomy_qza.view(pd.DataFrame)
     taxonomy = Taxonomy(table, taxonomy_df)
     taxonomy.get_group(['sample-1', 'sample-2'], 'foo')
 def test_get_group(self):
     taxonomy = Taxonomy(self.table, self.taxonomy_df)
     exp = GroupTaxonomy(name='sample-2',
                         taxonomy='((((feature-1,((feature-2)e)d)c)b)a);',
                         features=['feature-1', 'feature-2'],
                         feature_values=[1. / 5, 4. / 5],
                         feature_variances=[0.0, 0.0])
     obs = taxonomy.get_group(['sample-2'])
     self.assertEqual(obs, exp)
 def test_get_group_with_variances(self):
     taxonomy = Taxonomy(self.table, self.taxonomy_df, self.table_vars)
     exp = GroupTaxonomy(
         name='sample-1',
         taxonomy='((((((feature-2)e)d)c)b,(((feature-3)h)g)f)a);',  # noqa
         features=['feature-2', 'feature-3'],
         feature_values=[2. / 5, 3. / 5],
         feature_variances=[2.0, 3.0])
     obs = taxonomy.get_group(['sample-1'])
     self.assertEqual(obs, exp)
 def test_get_group_multiple(self):
     taxonomy = Taxonomy(self.table, self.taxonomy_df)
     exp = GroupTaxonomy(
         name='foo',
         taxonomy=
         '((((feature-1,((feature-2)e)d)c)b,(((feature-3)h)g)f)a);',  # noqa
         features=['feature-1', 'feature-2', 'feature-3'],
         feature_values=[1. / 10, 6. / 10, 3. / 10],
         feature_variances=[0.0, 0.0, 0.0])
     obs = taxonomy.get_group(['sample-1', 'sample-2'], 'foo')
     self.assertEqual(obs.name, exp.name)
     self.assertEqual(obs.taxonomy, exp.taxonomy)
     self.assertEqual(obs.features, exp.features)
     npt.assert_almost_equal(obs.feature_values, exp.feature_values)
     self.assertEqual(obs.feature_variances, exp.feature_variances)
 def test_get_group_missing(self):
     taxonomy = Taxonomy(self.table, self.taxonomy_df)
     with self.assertRaisesRegex(UnknownID, "sample-X does not exist"):
         taxonomy.get_group(['sample-X'])