本文整理匯總了Python中qiime.sdk.Artifact.save方法的典型用法代碼示例。如果您正苦於以下問題:Python Artifact.save方法的具體用法?Python Artifact.save怎麽用?Python Artifact.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qiime.sdk.Artifact
的用法示例。
在下文中一共展示了Artifact.save方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_constructor_no_provenance
# 需要導入模塊: from qiime.sdk import Artifact [as 別名]
# 或者: from qiime.sdk.Artifact import save [as 別名]
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)
示例2: test_save
# 需要導入模塊: from qiime.sdk import Artifact [as 別名]
# 或者: from qiime.sdk.Artifact import save [as 別名]
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)
示例3: retrieve_artifact_info
# 需要導入模塊: from qiime.sdk import Artifact [as 別名]
# 或者: from qiime.sdk.Artifact import save [as 別名]
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
示例4: setUp
# 需要導入模塊: from qiime.sdk import Artifact [as 別名]
# 或者: from qiime.sdk.Artifact import save [as 別名]
def setUp(self):
# TODO standardize temporary directories created by QIIME
self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-temp-')
self.workflow = Workflow.from_function(
dummy_function,
inputs={
'input1': DummyType,
'input2': DummyType,
'param1': Int,
'param2': Int
},
outputs=collections.OrderedDict([
('concatenated_inputs', DummyType)
]),
name='Concatenate things',
doc="Let's concatenate some things!"
)
self.artifact_fp1 = os.path.join(self.test_dir.name, 'artifact1.qtf')
self.artifact_fp2 = os.path.join(self.test_dir.name, 'artifact2.qtf')
Artifact.save([-1, 42, 0, 43, 43], DummyType, None, self.artifact_fp1)
Artifact.save([1, 2, 100], DummyType, None, self.artifact_fp2)
self.artifact_fp3 = os.path.join(self.test_dir.name, 'artifact3.qtf')
示例5: _test_to_script_or_to_markdown
# 需要導入模塊: from qiime.sdk import Artifact [as 別名]
# 或者: from qiime.sdk.Artifact import save [as 別名]
def _test_to_script_or_to_markdown(self, to_method, template_lines):
# These methods are so similar that it makes sense to have a helper
# that can test either one instead of duplicating a bunch of code.
workflow = Workflow.from_markdown(self.markdown_fp)
artifact_fp1 = os.path.join(self.test_dir.name, 'artifact1.qtf')
artifact_fp2 = os.path.join(self.test_dir.name, 'artifact2.qtf')
Artifact.save([-1, 42, 0, 43, 43], DummyType, None, artifact_fp1)
Artifact.save([1, 2, 100], DummyType, None, artifact_fp2)
artifact_fp3 = os.path.join(self.test_dir.name, 'artifact3.qtf')
job = to_method(
workflow,
input_artifact_filepaths={
'input1': artifact_fp1,
'input2': artifact_fp2
},
parameter_references={
'param1': 99,
'param2': -999,
},
output_artifact_filepaths={
'concatenated_inputs': artifact_fp3
}
)
provenance_lines = [
"provenance = Provenance(",
"parameters={",
"'param2': -999"
]
setup_lines = [
"input1 = Artifact(%r).data" % artifact_fp1,
"input2 = Artifact(%r).data" % artifact_fp2,
"param1 = 99",
"param2 = -999"
]
teardown_lines = [
"Artifact.save(concatenated_inputs, DummyType, provenance, "
"%r)" % artifact_fp3
]
for expected_lines in (provenance_lines, setup_lines, template_lines,
teardown_lines):
for expected_line in expected_lines:
self.assertIn(expected_line, job.code)
self.assertIsInstance(job.uuid, uuid.UUID)
self.assertEqual(job.uuid.version, 4)
self.assertEqual(
job.input_artifact_filepaths,
{'input1': artifact_fp1, 'input2': artifact_fp2})
self.assertEqual(
job.parameter_references,
{'param1': 99, 'param2': -999})
self.assertEqual(
job.output_artifact_filepaths,
{'concatenated_inputs': artifact_fp3})