def setUp(self):
        super().setUp()
        empty_table_fp = self.get_data_path('empty_table.biom')
        self.empty_table_as_BIOMV210Format = \
            BIOMV210Format(empty_table_fp, mode='r')
        input_table_fp = self.get_data_path('faith_test_table.biom')
        self.input_table_as_BIOMV210Format = \
            BIOMV210Format(input_table_fp, mode='r')
        rf_table_fp = self.get_data_path('faith_test_table_rf.biom')
        self.rf_table_as_BIOMV210Format = BIOMV210Format(rf_table_fp, mode='r')
        pa_table_fp = self.get_data_path('faith_test_table_pa.biom')
        self.pa_table_as_BIOMV210Format = BIOMV210Format(pa_table_fp, mode='r')

        empty_tree_fp = self.get_data_path('empty.tree')
        self.empty_tree_as_NewickFormat = NewickFormat(empty_tree_fp, mode='r')
        input_tree_fp = self.get_data_path('faith_test.tree')
        self.input_tree_as_NewickFormat = NewickFormat(input_tree_fp, mode='r')
        root_only_tree_fp = self.get_data_path('root_only.tree')
        self.root_only_tree_as_NewickFormat = \
            NewickFormat(root_only_tree_fp, mode='r')
        missing_tip_tree_fp = self.get_data_path('missing_tip.tree')
        self.missing_tip_tree_as_NewickFormat = \
            NewickFormat(missing_tip_tree_fp, mode='r')

        self.expected = pd.Series(
            {
                'S1': 0.5,
                'S2': 0.7,
                'S3': 1.0,
                'S4': 100.5,
                'S5': 101
            },
            name='faith_pd')
Exemple #2
0
    def setUp(self):
        super().setUp()
        # expected computed with diversity.beta_phylogenetic (weighted_unifrac)
        self.expected = skbio.DistanceMatrix(
            np.array([0.44656238, 0.23771096, 0.30489123, 0.23446002,
                      0.65723575, 0.44911772, 0.381904, 0.69144829,
                      0.39611776, 0.36568012, 0.53377975, 0.48908025,
                      0.35155196, 0.28318669, 0.57376916, 0.23395746,
                      0.24658122, 0.60271637, 0.39802552, 0.36567394,
                      0.68062701, 0.36862049, 0.48350632, 0.33024631,
                      0.33266697, 0.53464744, 0.74605075, 0.53951035,
                      0.49680733, 0.79178838, 0.37109012, 0.52629343,
                      0.22118218, 0.32400805, 0.43189708, 0.59705893]),
            ids=('10084.PC.481', '10084.PC.593', '10084.PC.356',
                 '10084.PC.355', '10084.PC.354', '10084.PC.636',
                 '10084.PC.635', '10084.PC.607', '10084.PC.634'))

        table_fp = self.get_data_path('crawford.biom')
        self.table_as_BIOMV210Format = BIOMV210Format(table_fp, mode='r')
        rel_freq_table_fp = self.get_data_path('crawford_rf.biom')
        self.rf_table_as_BIOMV210Format = BIOMV210Format(rel_freq_table_fp,
                                                         mode='r')

        tree_fp = self.get_data_path('crawford.nwk')
        self.tree_as_NewickFormat = NewickFormat(tree_fp, mode='r')
Exemple #3
0
    def setUp(self):
        super().setUp()
        valid_table_fp = self.get_data_path('two_feature_table.biom')
        self.valid_table_as_BIOMV210Format = \
            BIOMV210Format(valid_table_fp, mode='r')
        # empty table fp generated from self.empty_table with biom v2.1.7
        self.empty_table = biom.Table(np.array([]), [], [])
        empty_table_fp = self.get_data_path('empty_table.biom')
        self.empty_table_as_BIOMV210Format = \
            BIOMV210Format(empty_table_fp, mode='r')

        empty_tree_fp = self.get_data_path('empty.tree')
        self.empty_tree_as_NewickFormat = NewickFormat(empty_tree_fp, mode='r')
        root_only_tree_fp = self.get_data_path('root_only.tree')
        self.root_only_tree_as_NewickFormat = NewickFormat(root_only_tree_fp,
                                                           mode='r')
        missing_tip_tree_fp = self.get_data_path('missing_tip.tree')
        self.missing_tip_tree_as_NewickFormat = \
            NewickFormat(missing_tip_tree_fp, mode='r')
        two_feature_tree_fp = self.get_data_path('two_feature.tree')
        self.two_feature_tree_as_NewickFormat = \
            NewickFormat(two_feature_tree_fp, mode='r')
        extra_tip_tree_fp = self.get_data_path('extra_tip.tree')
        self.extra_tip_tree_as_NewickFormat = NewickFormat(extra_tip_tree_fp,
                                                           mode='r')
        valid_tree_fp = self.get_data_path('three_feature.tree')
        self.valid_tree_as_NewickFormat = NewickFormat(valid_tree_fp, mode='r')
Exemple #4
0
    def setUp(self):
        super().setUp()
        # expected computed with skbio.diversity.beta_diversity
        self.expected = skbio.DistanceMatrix([[0.00, 0.25, 0.25],
                                             [0.25, 0.00, 0.00],
                                             [0.25, 0.00, 0.00]],
                                             ids=['S1', 'S2', 'S3'])

        table_fp = self.get_data_path('two_feature_table.biom')
        self.table_as_BIOMV210Format = BIOMV210Format(table_fp, mode='r')
        rf_table_fp = self.get_data_path('two_feature_rf_table.biom')
        self.rf_table_as_BIOMV210Format = BIOMV210Format(rf_table_fp, mode='r')
        p_a_table_fp = self.get_data_path('two_feature_p_a_table.biom')
        self.p_a_table_as_BIOMV210Format = BIOMV210Format(p_a_table_fp,
                                                          mode='r')
        self.table_as_artifact = Artifact.import_data(
                    'FeatureTable[Frequency]', self.table_as_BIOMV210Format)

        tree_fp = self.get_data_path('three_feature.tree')
        self.tree_as_NewickFormat = NewickFormat(tree_fp, mode='r')
        self.tree_as_artifact = Artifact.import_data(
                    'Phylogeny[Rooted]', self.tree_as_NewickFormat)

        self.unweighted_unifrac_thru_framework = self.plugin.actions[
                    'unweighted_unifrac']
Exemple #5
0
def _2(obj : np.ndarray) -> BIOMV210Format :
    # for X in generate data, or generate constraint
    ff = BIOMV210Format()
    l1, l2 = [str(i) for i in range(len(obj[0]))],[str(i) for i in range(len(obj))]
    data = biom.Table(obj.T,observation_ids=l1,sample_ids=l2)
    with ff.open() as fh:
        data.to_hdf5(fh, generated_by='qiime2 %s' % version)
    return ff
Exemple #6
0
    def setUp(self):
        super().setUp()

        @_validate_requested_cpus
        def function_no_params():
            pass

        self.function_no_params = function_no_params

        @_validate_requested_cpus
        def function_w_param(n_jobs=3):
            return n_jobs

        self.function_w_n_jobs_param = function_w_param

        @_validate_requested_cpus
        def function_w_threads(threads=2):
            return threads

        self.function_w_threads_param = function_w_threads

        @_validate_requested_cpus
        def function_w_duplicate_params(n_jobs=3, threads=2):
            pass

        self.function_w_both = function_w_duplicate_params

        self.jaccard_thru_framework = self.plugin.actions['jaccard']
        self.unweighted_unifrac_thru_framework = self.plugin.actions[
            'unweighted_unifrac']

        two_feature_table_fp = self.get_data_path('two_feature_table.biom')
        self.two_feature_table = biom.load_table(two_feature_table_fp)
        self.two_feature_table_as_BIOMV210Format = BIOMV210Format(
            two_feature_table_fp, mode='r')
        self.two_feature_table_as_artifact = Artifact.import_data(
            'FeatureTable[Frequency]', two_feature_table_fp)

        larger_table_fp = self.get_data_path('crawford.biom')
        self.larger_table_as_artifact = Artifact.import_data(
            'FeatureTable[Frequency]', larger_table_fp)

        valid_tree_fp = self.get_data_path('three_feature.tree')
        self.valid_tree_as_NewickFormat = NewickFormat(valid_tree_fp, mode='r')
        self.valid_tree_as_artifact = Artifact.import_data(
            'Phylogeny[Rooted]', valid_tree_fp)

        larger_tree_fp = self.get_data_path('crawford.nwk')
        self.larger_tree_as_artifact = Artifact.import_data(
            'Phylogeny[Rooted]', larger_tree_fp)
Exemple #7
0
    def setUp(self):
        super().setUp()
        self.empty_table = biom.Table(np.array([]), [], [])
        # empty table generated from self.empty_table with biom v2.1.7
        empty_table_fp = self.get_data_path('empty_table.biom')
        self.empty_table_as_BIOMV210Format = BIOMV210Format(empty_table_fp,
                                                            mode='r')
        valid_table_fp = self.get_data_path('crawford.biom')
        self.valid_table_as_BIOMV210Format = BIOMV210Format(valid_table_fp,
                                                            mode='r')
        not_a_table_fp = self.get_data_path('crawford.nwk')
        self.invalid_view_type = NewickFormat(not_a_table_fp, mode='r')

        self.valid_table_list = [
            self.valid_table_as_BIOMV210Format,
            self.valid_table_as_BIOMV210Format
        ]
        self.invalid_table_list = [
            self.valid_table_as_BIOMV210Format, self.invalid_view_type
        ]
        self.has_empty_table_list = [
            self.empty_table_as_BIOMV210Format,
            self.valid_table_as_BIOMV210Format
        ]

        @_disallow_empty_tables
        def f1(table: biom.Table):
            pass

        self.function_with_table_param = f1

        @_disallow_empty_tables
        def f2():
            pass

        self.function_without_table_param = f2
Exemple #8
0
def _3(ff: BIOMV210Format) -> np.ndarray:
    # for X in regress
    with ff.open() as fh:
        table = biom.Table.from_hdf5(fh)
    array = table.matrix_data.toarray().T # numpy array
    return array
Exemple #9
0
    def test_biomv210_format_validate_negative(self):
        filepath = self.get_data_path('feature-table_v100.biom')
        format = BIOMV210Format(filepath, mode='r')

        with self.assertRaisesRegex(ValidationError, 'BIOMV210Format'):
            format.validate()
Exemple #10
0
    def test_biomv210_format_validate_positive(self):
        filepath = self.get_data_path('feature-table_v210.biom')
        format = BIOMV210Format(filepath, mode='r')

        format.validate()