當前位置: 首頁>>代碼示例>>Python>>正文


Python sdk.Artifact類代碼示例

本文整理匯總了Python中qiime.sdk.Artifact的典型用法代碼示例。如果您正苦於以下問題:Python Artifact類的具體用法?Python Artifact怎麽用?Python Artifact使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Artifact類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_call_with_no_parameters

    def test_call_with_no_parameters(self):
        merge_mappings = self.plugin.methods['merge_mappings']

        artifact1 = Artifact._from_view({'foo': 'abc', 'bar': 'def'}, Mapping,
                                        None)
        artifact2 = Artifact._from_view({'bazz': 'abc'}, Mapping, None)

        result = merge_mappings(artifact1, artifact2)

        self.assertIsInstance(result, Artifact)
        self.assertEqual(result.type, Mapping)

        provenance = result.provenance
        self.assertIsInstance(provenance, Provenance)
        self.assertIsInstance(provenance.execution_uuid, uuid.UUID)
        self.assertTrue(
            provenance.executor_reference.startswith(merge_mappings.id))
        self.assertEqual(provenance.artifact_uuids, {
            'mapping1': artifact1.uuid,
            'mapping2': artifact2.uuid
        })
        self.assertEqual(provenance.parameter_references, {})

        self.assertIsInstance(result.uuid, uuid.UUID)

        self.assertEqual(result.view(dict),
                         {'foo': 'abc', 'bar': 'def', 'bazz': 'abc'})
開發者ID:Kleptobismol,項目名稱:qiime2,代碼行數:27,代碼來源:test_method.py

示例2: get_artifacts

def get_artifacts(named=False):
    context_manager = Q2D3Context(os.getcwd())
    return sorted(
        [(context_manager.names[Artifact.load(fp).uuid], Artifact.load(fp))
         if named else Artifact.load(fp)
         for fp in context_manager.data.values()],
        key=lambda art: repr(art[1].type) if named else repr(art.type))
開發者ID:gregcaporaso,項目名稱:q2d3,代碼行數:7,代碼來源:__init__.py

示例3: setUp

    def setUp(self):
        # TODO standardize temporary directories created by QIIME
        self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-temp-')

        self.dummy_provenance = Provenance(
            job_uuid='7e909a23-21e2-44c2-be17-0723fae91dc8',
            artifact_uuids={
                'input1': 'f16ca3d0-fe83-4b1e-8eea-7e35db3f6b0f',
                'input2': '908dece5-db23-4562-ad03-876bb5750145',
            },
            parameters={
                'param1': 'abc',
                'param2': 100,
            },
            workflow_reference=(
                'dummy workflow reference, see '
                'https://github.com/biocore/qiime2/issues/26'
            )
        )

        self.artifact_with_provenance = Artifact._from_view(
            [-1, 42, 0, 43, 43], qiime.core.testing.TestType,
            self.dummy_provenance)

        self.artifact_without_provenance = Artifact._from_view(
            [-1, 42, 0, 43, 43], qiime.core.testing.TestType, None)
開發者ID:ebolyen,項目名稱:qiime2,代碼行數:26,代碼來源:test_artifact.py

示例4: test_import_data_with_unreachable_path

    def test_import_data_with_unreachable_path(self):
        with self.assertRaisesRegex(ValueError, "does not exist"):
            Artifact.import_data(IntSequence1,
                                 os.path.join(self.test_dir.name, 'foo.txt'))

        with self.assertRaisesRegex(ValueError, "does not exist"):
            Artifact.import_data(FourInts,
                                 os.path.join(self.test_dir.name, 'bar', ''))
開發者ID:qiime2,項目名稱:qiime2,代碼行數:8,代碼來源:test_artifact.py

示例5: test_import_data_with_filepath_multi_file_data_layout

    def test_import_data_with_filepath_multi_file_data_layout(self):
        fp = os.path.join(self.test_dir.name, 'test.txt')
        with open(fp, 'w') as fh:
            fh.write('42\n')

        with self.assertRaisesRegex(ValueError,
                                    "FourIntsDirectoryFormat.*directory"):
            Artifact.import_data(FourInts, fp)
開發者ID:qiime2,項目名稱:qiime2,代碼行數:8,代碼來源:test_artifact.py

示例6: test_import_data_invalid_type

    def test_import_data_invalid_type(self):
        with self.assertRaisesRegex(TypeError,
                                    'concrete semantic type.*Visualization'):
            Artifact.import_data(qiime.core.type.Visualization, self.test_dir)

        with self.assertRaisesRegex(TypeError,
                                    'concrete semantic type.*Visualization'):
            Artifact.import_data('Visualization', self.test_dir)
開發者ID:qiime2,項目名稱:qiime2,代碼行數:8,代碼來源:test_artifact.py

示例7: test_eq_same_uuid

    def test_eq_same_uuid(self):
        fp = os.path.join(self.test_dir.name, 'artifact.qza')
        artifact1 = Artifact.import_data(FourInts, [-1, 42, 0, 43])
        artifact1.save(fp)

        artifact2 = Artifact.load(fp)

        self.assertEqual(artifact1, artifact2)
開發者ID:qiime2,項目名稱:qiime2,代碼行數:8,代碼來源:test_artifact.py

示例8: test_constructor_no_provenance

    def test_constructor_no_provenance(self):
        fp = os.path.join(self.test_dir.name, 'artifact.qtf')
        Artifact.save([-1, 42, 0, 43, 43], DummyType, None, fp)

        artifact = Artifact(fp)

        self.assertEqual(artifact.data, [-1, 42, 0, 43, 43])
        self.assertEqual(artifact.type, DummyType)
        self.assertEqual(artifact.provenance, None)
        self.assertIsInstance(artifact.uuid, uuid.UUID)
        self.assertEqual(artifact.uuid.version, 4)
開發者ID:gblanchard4,項目名稱:qiime2,代碼行數:11,代碼來源:test_artifact.py

示例9: test_async

    def test_async(self):
        concatenate_ints = self.plugin.methods['concatenate_ints']
        concatenate_ints_markdown = \
            self.plugin.methods['concatenate_ints_markdown']

        artifact1 = Artifact._from_view([0, 42, 43], IntSequence1, None)
        artifact2 = Artifact._from_view([99, -22], IntSequence2, None)

        for method in concatenate_ints, concatenate_ints_markdown:
            future = method.async(artifact1, artifact1, artifact2, 55, 1)

            self.assertIsInstance(future, concurrent.futures.Future)
            result = future.result()

            self.assertIsInstance(result, Artifact)
            self.assertEqual(result.type, IntSequence1)

            provenance = result.provenance
            self.assertIsInstance(provenance, Provenance)
            self.assertIsInstance(provenance.execution_uuid, uuid.UUID)
            self.assertTrue(
                provenance.executor_reference.startswith(method.id))
            self.assertEqual(provenance.artifact_uuids, {
                'ints1': artifact1.uuid,
                'ints2': artifact1.uuid,
                'ints3': artifact2.uuid
            })
            self.assertEqual(provenance.parameter_references, {
                'int1': '55',
                'int2': '1'
            })

            self.assertIsInstance(result.uuid, uuid.UUID)

            # Can retrieve multiple views of different type.
            exp_list_view = [0, 42, 43, 0, 42, 43, 99, -22, 55, 1]
            self.assertEqual(result.view(list), exp_list_view)
            self.assertEqual(result.view(list), exp_list_view)

            exp_counter_view = collections.Counter(
                {0: 2, 42: 2, 43: 2, 99: 1, -22: 1, 55: 1, 1: 1})
            self.assertEqual(result.view(collections.Counter),
                             exp_counter_view)
            self.assertEqual(result.view(collections.Counter),
                             exp_counter_view)

            # Accepts IntSequence1 | IntSequence2
            artifact3 = Artifact._from_view([10, 20], IntSequence2, None)
            future = method.async(artifact3, artifact1, artifact2, 55, 1)
            result = future.result()

            self.assertEqual(result.type, IntSequence1)
            self.assertEqual(result.view(list),
                             [10, 20, 0, 42, 43, 99, -22, 55, 1])
開發者ID:Kleptobismol,項目名稱:qiime2,代碼行數:54,代碼來源:test_method.py

示例10: test_import_data_with_invalid_format_single_file

    def test_import_data_with_invalid_format_single_file(self):
        fp = os.path.join(self.test_dir.name, 'foo.txt')
        with open(fp, 'w') as fh:
            fh.write('42\n')
            fh.write('43\n')
            fh.write('abc\n')
            fh.write('123\n')

        error_regex = "foo.txt.*IntSequenceFormat"
        with self.assertRaisesRegex(ValueError, error_regex):
            Artifact.import_data(IntSequence1, fp)
開發者ID:qiime2,項目名稱:qiime2,代碼行數:11,代碼來源:test_artifact.py

示例11: test_save

    def test_save(self):
        fp = os.path.join(self.test_dir.name, 'artifact.qtf')
        Artifact.save([-1, 42, 0, 43, 43], DummyType, self.dummy_provenance,
                      fp)

        with tarfile.open(fp, mode='r') as tar:
            fps = set(tar.getnames())
            expected = {'artifact', 'artifact/metadata.yaml',
                        'artifact/README.md', 'artifact/data',
                        'artifact/data/data.txt'}
            self.assertEqual(fps, expected)
開發者ID:gblanchard4,項目名稱:qiime2,代碼行數:11,代碼來源:test_artifact.py

示例12: test_peek

    def test_peek(self):
        artifact = Artifact._from_view([0, 0, 42, 1000], FourInts, None)
        fp = os.path.join(self.test_dir.name, 'artifact.qza')
        artifact.save(fp)

        metadata = Artifact.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, FourInts)
        self.assertIsNone(metadata.provenance)
        self.assertEqual(metadata.uuid, artifact.uuid)
開發者ID:Kleptobismol,項目名稱:qiime2,代碼行數:11,代碼來源:test_artifact.py

示例13: test_load

    def test_load(self):
        saved_artifact = Artifact.import_data(FourInts, [-1, 42, 0, 43])
        fp = os.path.join(self.test_dir.name, 'artifact.qza')
        saved_artifact.save(fp)

        artifact = Artifact.load(fp)

        self.assertEqual(artifact.type, FourInts)
        self.assertEqual(artifact.uuid, saved_artifact.uuid)
        self.assertEqual(artifact.view(list), [-1, 42, 0, 43])
        self.assertEqual(artifact.view(list), [-1, 42, 0, 43])
開發者ID:qiime2,項目名稱:qiime2,代碼行數:11,代碼來源:test_artifact.py

示例14: test_peek

    def test_peek(self):
        artifact = Artifact.import_data(FourInts, [0, 0, 42, 1000])
        fp = os.path.join(self.test_dir.name, 'artifact.qza')
        artifact.save(fp)

        metadata = Artifact.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, 'FourInts')
        self.assertEqual(metadata.uuid, str(artifact.uuid))
        self.assertEqual(metadata.format, 'FourIntsDirectoryFormat')
開發者ID:qiime2,項目名稱:qiime2,代碼行數:11,代碼來源:test_artifact.py

示例15: retrieve_artifact_info

def retrieve_artifact_info(qclient, artifact_id, artifact_type):
    fps_info = qclient.get("/qiita_db/artifacts/%s/filepaths/" % artifact_id)
    filepaths = fps_info['filepaths']
    translator_lookup = get_artifact_translators_lookup()
    input_translator, _, _ = translator_lookup[str(artifact_type)]
    artifact_data = input_translator(filepaths)
    fd, temp_file_name = mkstemp(suffix='.qtf')
    close(fd)
    # TODO: None is the provenance
    Artifact.save(artifact_data, artifact_type, None, temp_file_name)
    return temp_file_name
開發者ID:gregcaporaso,項目名稱:qp-qiime2,代碼行數:11,代碼來源:plugin.py


注:本文中的qiime.sdk.Artifact類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。