本文整理汇总了Python中qiita_db.study.Study.prep_templates方法的典型用法代码示例。如果您正苦于以下问题:Python Study.prep_templates方法的具体用法?Python Study.prep_templates怎么用?Python Study.prep_templates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qiita_db.study.Study
的用法示例。
在下文中一共展示了Study.prep_templates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestStudy
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import prep_templates [as 别名]
#.........这里部分代码省略.........
exp = ['123456', '7891011']
self.assertEqual(self.study.pmids, exp)
new_values = ['654321', '1101987']
self.study.pmids = new_values
self.assertEqual(self.study.pmids, new_values)
def test_pmids_setter_typeerror(self):
with self.assertRaises(TypeError):
self.study.pmids = '123456'
def test_retrieve_investigation(self):
self.assertEqual(self.study.investigation, 1)
def test_retrieve_investigation_empty(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
self.assertEqual(new.investigation, None)
def test_retrieve_sample_template(self):
self.assertEqual(self.study.sample_template, 1)
def test_retrieve_data_types(self):
self.assertEqual(self.study.data_types, ['18S'])
def test_retrieve_data_types_none(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
self.assertEqual(new.data_types, [])
def test_retrieve_raw_data(self):
self.assertEqual(self.study.raw_data(), [1])
def test_retrieve_raw_data_none(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
self.assertEqual(new.raw_data(), [])
def test_retrieve_prep_templates(self):
self.assertEqual(self.study.prep_templates(), [1])
def test_retrieve_prep_templates_none(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
self.assertEqual(new.prep_templates(), [])
def test_retrieve_preprocessed_data(self):
self.assertEqual(self.study.preprocessed_data(), [1, 2])
def test_retrieve_preprocessed_data_none(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
self.assertEqual(new.preprocessed_data(), [])
def test_retrieve_processed_data(self):
self.assertEqual(self.study.processed_data(), [1])
def test_retrieve_processed_data_none(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
self.assertEqual(new.processed_data(), [])
def test_add_pmid(self):
self._change_processed_data_status('sandbox')
self.study.add_pmid('4544444')
exp = ['123456', '7891011', '4544444']
self.assertEqual(self.study.pmids, exp)
def test_environmental_packages(self):
obs = self.study.environmental_packages
exp = ['soil', 'plant-associated']
self.assertEqual(sorted(obs), sorted(exp))
def test_environmental_packages_setter(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
obs = new.environmental_packages
exp = []
self.assertEqual(obs, exp)
new_values = ['air', 'human-oral']
new.environmental_packages = new_values
obs = new.environmental_packages
self.assertEqual(sorted(obs), sorted(new_values))
def test_environmental_packages_setter_typeerror(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
with self.assertRaises(TypeError):
new.environmental_packages = 'air'
def test_environmental_packages_setter_valueerror(self):
new = Study.create(User('[email protected]'), 'NOT Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
with self.assertRaises(ValueError):
new.environmental_packages = ['air', 'not a package']
def test_environmental_packages_sandboxed(self):
with self.assertRaises(QiitaDBStatusError):
self.study.environmental_packages = ['air']
示例2: study_get_req
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import prep_templates [as 别名]
def study_get_req(study_id, user_id):
"""Returns information available for the given study
Parameters
----------
study_id : int
Study id to get prep template info for
user_id : str
User requesting the info
Returns
-------
dict
Data types information in the form
{'status': status,
'message': message,
'info': dict of objects
status can be success, warning, or error depending on result
message has the warnings or errors
info contains study information seperated by data type, in the form
{col_name: value, ...} with value being a string, int, or list of
strings or ints
"""
access_error = check_access(study_id, user_id)
if access_error:
return access_error
# Can only pass ids over API, so need to instantiate object
study = Study(study_id)
study_info = study.info
# Add needed info that is not part of the initial info pull
study_info['publication_doi'] = []
study_info['publication_pid'] = []
for pub, is_doi in study.publications:
if is_doi:
study_info['publication_doi'].append(pub)
else:
study_info['publication_pid'].append(pub)
study_info['study_id'] = study.id
study_info['study_title'] = study.title
study_info['shared_with'] = [s.id for s in study.shared_with]
study_info['status'] = study.status
study_info['ebi_study_accession'] = study.ebi_study_accession
study_info['ebi_submission_status'] = study.ebi_submission_status
# Clean up StudyPerson objects to string for display
pi = study_info['principal_investigator']
study_info['principal_investigator'] = {
'name': pi.name,
'email': pi.email,
'affiliation': pi.affiliation}
lab_person = study_info['lab_person']
if lab_person:
study_info['lab_person'] = {
'name': lab_person.name,
'email': lab_person.email,
'affiliation': lab_person.affiliation}
samples = study.sample_template
study_info['num_samples'] = 0 if samples is None else len(list(samples))
study_info['owner'] = study.owner.id
# Study.has_access no_public=True, will return True only if the user_id is
# the owner of the study or if the study is shared with the user_id
study_info['has_access_to_raw_data'] = study.has_access(
User(user_id), True)
study_info['show_biom_download_button'] = 'BIOM' in [
a.artifact_type for a in study.artifacts()]
study_info['show_raw_download_button'] = any([
True for pt in study.prep_templates() if pt.artifact is not None])
# getting study processing status from redis
processing = False
study_info['level'] = ''
study_info['message'] = ''
job_info = r_client.get(STUDY_KEY_FORMAT % study_id)
if job_info:
job_info = defaultdict(lambda: '', loads(job_info))
job_id = job_info['job_id']
job = ProcessingJob(job_id)
job_status = job.status
processing = job_status not in ('success', 'error')
if processing:
study_info['level'] = 'info'
study_info['message'] = 'This study is currently being processed'
elif job_status == 'error':
study_info['level'] = 'danger'
study_info['message'] = job.log.msg.replace('\n', '</br>')
else:
study_info['level'] = job_info['alert_type']
study_info['message'] = job_info['alert_msg'].replace(
'\n', '</br>')
return {'status': 'success',
'message': '',
'study_info': study_info,
'editable': study.can_edit(User(user_id))}