当前位置: 首页>>代码示例>>Python>>正文


Python Artifact.import_data方法代码示例

本文整理汇总了Python中qiime2.Artifact.import_data方法的典型用法代码示例。如果您正苦于以下问题:Python Artifact.import_data方法的具体用法?Python Artifact.import_data怎么用?Python Artifact.import_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qiime2.Artifact的用法示例。


在下文中一共展示了Artifact.import_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_variadic_inputs

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_variadic_inputs(self):
        qiime_cli = RootCommand()
        command = qiime_cli.get_command(ctx=None, name='dummy-plugin')
        output_path = os.path.join(self.tempdir, 'output.qza')

        ints1 = Artifact.import_data('IntSequence1', [1, 2, 3]).save(
            os.path.join(self.tempdir, 'ints1.qza'))
        ints2 = Artifact.import_data('IntSequence2', [4, 5, 6]).save(
            os.path.join(self.tempdir, 'ints2.qza'))
        set1 = Artifact.import_data('SingleInt', 7).save(
            os.path.join(self.tempdir, 'set1.qza'))
        set2 = Artifact.import_data('SingleInt', 8).save(
            os.path.join(self.tempdir, 'set2.qza'))

        result = self.runner.invoke(
            command,
            ['variadic-input-method', '--i-ints', ints1, '--i-ints', ints2,
             '--i-int-set', set1, '--i-int-set', set2, '--p-nums', '9',
             '--p-nums', '10', '--p-opt-nums', '11', '--p-opt-nums', '12',
             '--p-opt-nums', '13', '--o-output', output_path, '--verbose'])

        self.assertEqual(result.exit_code, 0)
        self.assertTrue(os.path.exists(output_path))

        output = Artifact.load(output_path)
        self.assertEqual(output.view(list), list(range(1, 14)))
开发者ID:jakereps,项目名称:q2cli,代码行数:28,代码来源:test_cli.py

示例2: setUp

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def setUp(self):
        dummy_plugin = get_dummy_plugin()

        self.runner = CliRunner()
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.metadata_file_mixed_types = os.path.join(
                self.tempdir, 'metadata-mixed-types.tsv')
        with open(self.metadata_file_mixed_types, 'w') as f:
            f.write('id\tnumbers\tstrings\n0\t42\tabc\n1\t-1.5\tdef\n')

        self.bad_metadata_file = os.path.join(
                self.tempdir, 'bad-metadata.tsv')
        with open(self.bad_metadata_file, 'w') as f:
            f.write('wrong\tnumbers\tstrings\nid1\t42\tabc\nid2\t-1.5\tdef\n')

        self.metadata_artifact = os.path.join(self.tempdir, 'metadata.qza')
        Artifact.import_data(
            'Mapping', {'a': 'dog', 'b': 'cat'}).save(self.metadata_artifact)

        self.ints1 = os.path.join(self.tempdir, 'ints1.qza')
        ints1 = Artifact.import_data(
            'IntSequence1', [0, 42, 43], list)
        ints1.save(self.ints1)

        self.ints2 = os.path.join(self.tempdir, 'ints')
        ints1.export_data(self.ints2)

        self.viz = os.path.join(self.tempdir, 'viz.qzv')
        most_common_viz = dummy_plugin.actions['most_common_viz']
        self.viz = most_common_viz(ints1).visualization.save(self.viz)
开发者ID:jakereps,项目名称:q2cli,代码行数:33,代码来源:test_tools.py

示例3: test_core_metrics_phylogenetic_multiple_jobs

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_core_metrics_phylogenetic_multiple_jobs(self):
        table = biom.Table(np.array([[0, 11, 11], [13, 11, 11]]),
                           ['O1', 'O2'],
                           ['S1', 'S2', 'S3'])
        table = Artifact.import_data('FeatureTable[Frequency]', table)

        tree = skbio.TreeNode.read(io.StringIO(
            '((O1:0.25, O2:0.50):0.25, O3:0.75)root;'))
        tree = Artifact.import_data('Phylogeny[Rooted]', tree)

        metadata = Metadata(
            pd.DataFrame({'foo': ['1', '2', '3']},
                         index=pd.Index(['S1', 'S2', 'S3'], name='id')))

        results = self.core_metrics_phylogenetic(table, tree, 13, metadata,
                                                 n_jobs=2)

        self.assertEqual(len(results), 17)

        self.assertEqual(repr(results.bray_curtis_distance_matrix.type),
                         'DistanceMatrix')
        self.assertEqual(repr(results.jaccard_emperor.type), 'Visualization')

        # pipelines preserve the output's type, in this case, beta_phylogenetic
        # returns this type, and that is passed through to the final output
        # (as long as the type is a subtype of the signature).
        self.assertEqual(
            repr(results.faith_pd_vector.type),
            "SampleData[AlphaDiversity] % Properties(['phylogenetic'])")

        expected = pd.Series({'S1': 1, 'S2': 2, 'S3': 2},
                             name='observed_otus')
        pdt.assert_series_equal(results[2].view(pd.Series), expected)
开发者ID:jakereps,项目名称:q2-diversity,代码行数:35,代码来源:test_core_metrics.py

示例4: test_add_artifacts

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_add_artifacts(self):
        # First two artifacts have the same data but different UUIDs.
        artifact1 = Artifact.import_data('Mapping', {'a': '1', 'b': '3'})
        self.mdc._add_artifacts([artifact1])

        artifact2 = Artifact.import_data('Mapping', {'a': '1', 'b': '3'})
        artifact3 = Artifact.import_data('IntSequence1', [1, 2, 3, 4])
        self.mdc._add_artifacts([artifact2, artifact3])

        self.assertEqual(self.mdc.artifacts, (artifact1, artifact2, artifact3))
开发者ID:thermokarst,项目名称:qiime2,代码行数:12,代码来源:test_metadata_column.py

示例5: test_artifact_mismatch

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_artifact_mismatch(self):
        # Metadata created from different artifacts shouldn't compare equal,
        # even if the data is the same.
        artifact1 = Artifact.import_data('Mapping', {'a': '1', 'b': '2'})
        artifact2 = Artifact.import_data('Mapping', {'a': '1', 'b': '2'})

        md1 = artifact1.view(Metadata)
        md2 = artifact2.view(Metadata)

        pdt.assert_frame_equal(md1.to_dataframe(), md2.to_dataframe())
        self.assertReallyNotEqual(md1, md2)
开发者ID:gregcaporaso,项目名称:qiime2,代码行数:13,代码来源:test_metadata.py

示例6: test_add_duplicate_artifact

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_add_duplicate_artifact(self):
        artifact1 = Artifact.import_data('Mapping', {'a': '1', 'b': '3'})
        artifact2 = Artifact.import_data('IntSequence1', [1, 2, 3, 4])
        self.mdc._add_artifacts([artifact1, artifact2])

        with self.assertRaisesRegex(
                ValueError, "Duplicate source artifacts.*DummyMetadataColumn.*"
                            "artifact: Mapping"):
            self.mdc._add_artifacts([artifact1])

        # Test that the object hasn't been mutated.
        self.assertEqual(self.mdc.artifacts, (artifact1, artifact2))
开发者ID:thermokarst,项目名称:qiime2,代码行数:14,代码来源:test_metadata_column.py

示例7: setUp

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def setUp(self):
        get_dummy_plugin()
        self.runner = CliRunner()
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')
        self.artifact1_path = os.path.join(self.tempdir, 'a1.qza')
        self.mapping_path = os.path.join(self.tempdir, 'mapping.qza')

        artifact1 = Artifact.import_data(IntSequence1, [0, 42, 43])
        artifact1.save(self.artifact1_path)
        self.artifact1_root_dir = str(artifact1.uuid)

        mapping = Artifact.import_data('Mapping', {'foo': '42'})
        mapping.save(self.mapping_path)
开发者ID:jakereps,项目名称:q2cli,代码行数:15,代码来源:test_cli.py

示例8: test_repeated_multiple_option

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_repeated_multiple_option(self):
        input_path = os.path.join(self.tempdir, 'ints.qza')
        artifact = Artifact.import_data(IntSequence1, [0, 42, 43], list)
        artifact.save(input_path)

        metadata_path1 = os.path.join(self.tempdir, 'metadata1.tsv')
        with open(metadata_path1, 'w') as f:
            f.write('id\tcol1\nid1\tfoo\nid2\tbar\n')
        metadata_path2 = os.path.join(self.tempdir, 'metadata2.tsv')
        with open(metadata_path2, 'w') as f:
            f.write('id\tcol2\nid1\tbaz\nid2\tbaa\n')

        output_path = os.path.join(self.tempdir, 'out.qza')

        qiime_cli = RootCommand()
        command = qiime_cli.get_command(ctx=None, name='dummy-plugin')

        result = self.runner.invoke(
            command, ['identity-with-metadata', '--i-ints', input_path,
                      '--o-out', output_path, '--m-metadata-file',
                      metadata_path1, '--m-metadata-file', metadata_path2,
                      '--verbose'])

        self.assertEqual(result.exit_code, 0)
        self.assertTrue(os.path.exists(output_path))
        self.assertEqual(Artifact.load(output_path).view(list), [0, 42, 43])
开发者ID:qiime2,项目名称:q2cli,代码行数:28,代码来源:test_core.py

示例9: test_add_non_artifact

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_add_non_artifact(self):
        artifact = Artifact.import_data('Mapping', {'a': '1', 'b': '3'})

        with self.assertRaisesRegex(TypeError, "Artifact object.*42"):
            self.mdc._add_artifacts([artifact, 42])

        # Test that the object hasn't been mutated.
        self.assertEqual(self.mdc.artifacts, ())
开发者ID:thermokarst,项目名称:qiime2,代码行数:10,代码来源:test_metadata_column.py

示例10: setUp

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def setUp(self):
        super().setUp()
        self.align_to_tree_mafft_fasttree = self.plugin.pipelines[
                                    'align_to_tree_mafft_fasttree']

        input_sequences_fp = self.get_data_path('dna-sequences-1.fasta')
        self.input_sequences = Artifact.import_data('FeatureData[Sequence]',
                                                    input_sequences_fp)
开发者ID:qiime2,项目名称:q2-phylogeny,代码行数:10,代码来源:test_align_to_tree_mafft_fasttree.py

示例11: test_with_artifacts

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_with_artifacts(self):
        artifact1 = Artifact.import_data('Mapping', {'a': '1', 'b': '2'})
        artifact2 = Artifact.import_data('Mapping', {'d': '4'})

        mdc = DummyMetadataColumn(pd.Series(
            [1, 2, 3], name='col1',
            index=pd.Index(['a', 'b', 'c'], name='id')))
        mdc._add_artifacts([artifact1, artifact2])

        obs = mdc.filter_ids({'a', 'c'})

        exp = DummyMetadataColumn(pd.Series(
            [1, 3], name='col1', index=pd.Index(['a', 'c'], name='id')))
        exp._add_artifacts([artifact1, artifact2])

        self.assertEqual(obs, exp)
        self.assertEqual(obs.artifacts, (artifact1, artifact2))
开发者ID:thermokarst,项目名称:qiime2,代码行数:19,代码来源:test_metadata_column.py

示例12: test_artifacts_mismatch

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_artifacts_mismatch(self):
        artifact1 = Artifact.import_data('Mapping', {'a': '1', 'b': '2'})
        artifact2 = Artifact.import_data('Mapping', {'a': '1', 'b': '2'})
        series = pd.Series([42, 43], name='col1',
                           index=pd.Index(['id1', 'id2'], name='id'))

        # No artifacts
        mdc1 = DummyMetadataColumn(series)

        # Has an artifact
        mdc2 = DummyMetadataColumn(series)
        mdc2._add_artifacts([artifact1])

        # Has a different artifact
        mdc3 = DummyMetadataColumn(series)
        mdc3._add_artifacts([artifact2])

        self.assertReallyNotEqual(mdc1, mdc2)
        self.assertReallyNotEqual(mdc2, mdc3)
开发者ID:thermokarst,项目名称:qiime2,代码行数:21,代码来源:test_metadata_column.py

示例13: test_source_mismatch

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_source_mismatch(self):
        # Metadata created from an artifact vs not shouldn't compare equal,
        # even if the data is the same.
        artifact = Artifact.import_data('Mapping', {'a': '1', 'b': '2'})
        md_from_artifact = artifact.view(Metadata)

        md_no_artifact = Metadata(md_from_artifact.to_dataframe())

        pdt.assert_frame_equal(md_from_artifact.to_dataframe(),
                               md_no_artifact.to_dataframe())
        self.assertReallyNotEqual(md_from_artifact, md_no_artifact)
开发者ID:gregcaporaso,项目名称:qiime2,代码行数:13,代码来源:test_metadata.py

示例14: test_artifacts_are_propagated

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_artifacts_are_propagated(self):
        A = Artifact.import_data('Mapping', {'a': '1', 'b': '3'})
        md = A.view(Metadata)

        obs = md.get_column('b')

        # TODO update to use MetadataColumn.__eq__
        self.assertEqual(obs.artifacts, (A,))
        pdt.assert_series_equal(
            obs.to_series(),
            pd.Series(['3'], index=pd.Index(['0'], name='id'), name='b'))
开发者ID:gregcaporaso,项目名称:qiime2,代码行数:13,代码来源:test_metadata.py

示例15: test_core_metrics_phylogenetic_rarefy_drops_sample

# 需要导入模块: from qiime2 import Artifact [as 别名]
# 或者: from qiime2.Artifact import import_data [as 别名]
    def test_core_metrics_phylogenetic_rarefy_drops_sample(self):
        table = biom.Table(np.array([[0, 11, 11], [12, 11, 11]]),
                           ['O1', 'O2'],
                           ['S1', 'S2', 'S3'])
        table = Artifact.import_data('FeatureTable[Frequency]', table)

        tree = skbio.TreeNode.read(io.StringIO(
            '((O1:0.25, O2:0.50):0.25, O3:0.75)root;'))
        tree = Artifact.import_data('Phylogeny[Rooted]', tree)

        metadata = Metadata(pd.DataFrame({'foo': ['1', '2', '3']},
                                         index=['S1', 'S2', 'S3']))

        results = self.core_metrics_phylogenetic(table, tree, 13, metadata)

        self.assertEqual(len(results), 17)

        expected = pd.Series({'S2': 2, 'S3': 2},
                             name='observed_otus')
        pdt.assert_series_equal(results[2].view(pd.Series), expected)
开发者ID:gregcaporaso,项目名称:diversity,代码行数:22,代码来源:test_core_metrics.py


注:本文中的qiime2.Artifact.import_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。