本文整理汇总了Python中qiita_db.metadata_template.PrepTemplate.data_type方法的典型用法代码示例。如果您正苦于以下问题:Python PrepTemplate.data_type方法的具体用法?Python PrepTemplate.data_type怎么用?Python PrepTemplate.data_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qiita_db.metadata_template.PrepTemplate
的用法示例。
在下文中一共展示了PrepTemplate.data_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _template_generator
# 需要导入模块: from qiita_db.metadata_template import PrepTemplate [as 别名]
# 或者: from qiita_db.metadata_template.PrepTemplate import data_type [as 别名]
def _template_generator(study, full_access):
"""Generates tuples of prep template information
Parameters
----------
study : Study
The study to get all the prep templates
full_access : boolean
A boolean that indicates if the user has full access to the study
Returns
-------
Generator of tuples of (int, str, PrepTemplate, (str, str, str))
Each tuple contains the prep template id, the prep template data_type
the PrepTemplate object and a tuple with 3 strings for the style of
the prep template status icons
"""
for pt_id in sorted(study.prep_templates()):
pt = PrepTemplate(pt_id)
if full_access or pt.status == 'public':
yield (pt.id, pt.data_type(), pt, STATUS_STYLER[pt.status])
示例2: PreprocessedDataTests
# 需要导入模块: from qiita_db.metadata_template import PrepTemplate [as 别名]
# 或者: from qiita_db.metadata_template.PrepTemplate import data_type [as 别名]
class PreprocessedDataTests(TestCase):
"""Tests the PreprocessedData class"""
def setUp(self):
self.prep_template = PrepTemplate(1)
self.study = Study(1)
self.params_table = "preprocessed_sequence_illumina_params"
self.params_id = 1
fd, self.fna_fp = mkstemp(suffix='_seqs.fna')
close(fd)
fd, self.qual_fp = mkstemp(suffix='_seqs.qual')
close(fd)
self.filepaths = [(self.fna_fp, 4), (self.qual_fp, 5)]
_, self.db_test_ppd_dir = get_mountpoint(
'preprocessed_data')[0]
self.ebi_submission_accession = "EBI123456-A"
self.ebi_study_accession = "EBI123456-B"
with open(self.fna_fp, "w") as f:
f.write("\n")
with open(self.qual_fp, "w") as f:
f.write("\n")
self._clean_up_files = []
def tearDown(self):
for f in self._clean_up_files:
remove(f)
def test_create(self):
"""Correctly creates the preprocessed data object"""
# Check that the returned object has the correct id
new_id = get_count('qiita.preprocessed_data') + 1
obs = PreprocessedData.create(
self.study, self.params_table,
self.params_id, self.filepaths, prep_template=self.prep_template)
self.assertEqual(obs.id, new_id)
# Check that all the information is initialized correctly
self.assertEqual(obs.processed_data, [])
self.assertEqual(obs.prep_template, self.prep_template.id)
self.assertEqual(obs.study, self.study.id)
self.assertEqual(obs.data_type(), self.prep_template.data_type())
self.assertEqual(obs.data_type(ret_id=True),
self.prep_template.data_type(ret_id=True))
self.assertEqual(obs.submitted_to_vamps_status(), "not submitted")
self.assertEqual(obs.processing_status, "not_processed")
self.assertEqual(obs.status, "sandbox")
self.assertEqual(obs.preprocessing_info,
(self.params_table, self.params_id))
def test_create_data_type_only(self):
# Check that the returned object has the correct id
new_id = get_count('qiita.preprocessed_data') + 1
obs = PreprocessedData.create(self.study, self.params_table,
self.params_id, self.filepaths,
data_type="18S")
self.assertEqual(obs.id, new_id)
# Check that all the information is initialized correctly
self.assertEqual(obs.processed_data, [])
self.assertEqual(obs.prep_template, [])
self.assertEqual(obs.study, self.study.id)
self.assertEqual(obs.data_type(), "18S")
self.assertEqual(obs.data_type(ret_id=True),
convert_to_id("18S", "data_type"))
self.assertEqual(obs.submitted_to_vamps_status(), "not submitted")
self.assertEqual(obs.processing_status, "not_processed")
self.assertEqual(obs.status, "sandbox")
self.assertEqual(obs.preprocessing_info,
(self.params_table, self.params_id))
def test_delete_basic(self):
"""Correctly deletes a preprocessed data"""
# testing regular delete
ppd = PreprocessedData.create(
self.study, self.params_table,
self.params_id, self.filepaths, prep_template=self.prep_template)
PreprocessedData.delete(ppd.id)
# testing that the deleted preprocessed data can't be instantiated
with self.assertRaises(QiitaDBUnknownIDError):
PreprocessedData(ppd.id)
# and for completeness testing that it raises an error if ID
# doesn't exist
with self.assertRaises(QiitaDBUnknownIDError):
PreprocessedData.delete(ppd.id)
# testing that we can not remove cause the preprocessed data != sandbox
with self.assertRaises(QiitaDBStatusError):
PreprocessedData.delete(1)
def test_delete_advanced(self):
# testing that we can not remove cause preprocessed data has been
# submitted to EBI or VAMPS
ppd = PreprocessedData.create(
self.study, self.params_table,
self.params_id, self.filepaths, prep_template=self.prep_template)
# fails due to VAMPS submission
ppd.update_vamps_status('success')
with self.assertRaises(QiitaDBStatusError):
#.........这里部分代码省略.........