本文整理汇总了Python中qiita_db.study.Study.get_info方法的典型用法代码示例。如果您正苦于以下问题:Python Study.get_info方法的具体用法?Python Study.get_info怎么用?Python Study.get_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qiita_db.study.Study
的用法示例。
在下文中一共展示了Study.get_info方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_info
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import get_info [as 别名]
def get_info(self, portal="QIITA"):
# Add the portals and, optionally, checkbox to the information
studies = [s.id for s in Portal(portal).get_studies()]
if not studies:
return []
study_info = Study.get_info(studies, info_cols=self.study_cols)
info = []
for s in study_info:
# Make sure in correct order
hold = dict(s)
hold["portals"] = ", ".join(sorted(Study(s["study_id"])._portals))
info.append(hold)
return info
示例2: _build_study_info
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import get_info [as 别名]
def _build_study_info(user, study_proc=None, proc_samples=None):
"""Builds list of dicts for studies table, with all HTML formatted
Parameters
----------
user : User object
logged in user
study_proc : dict of lists, optional
Dictionary keyed on study_id that lists all processed data associated
with that study. Required if proc_samples given.
proc_samples : dict of lists, optional
Dictionary keyed on proc_data_id that lists all samples associated with
that processed data. Required if study_proc given.
Returns
-------
infolist: list of dict of lists and dicts
study and processed data info for JSON serialiation for datatables
Each dict in the list is a single study, and contains the text
Notes
-----
Both study_proc and proc_samples must be passed, or neither passed.
"""
build_samples = False
# Logic check to make sure both needed parts passed
if study_proc is not None and proc_samples is None:
raise IncompetentQiitaDeveloperError(
'Must pass proc_samples when study_proc given')
elif proc_samples is not None and study_proc is None:
raise IncompetentQiitaDeveloperError(
'Must pass study_proc when proc_samples given')
elif study_proc is None:
build_samples = True
# get list of studies for table
study_set = user.user_studies.union(
Study.get_by_status('public')).union(user.shared_studies)
if study_proc is not None:
study_set = study_set.intersection(study_proc)
if not study_set:
# No studies left so no need to continue
return []
# get info for the studies
cols = ['study_id', 'email', 'principal_investigator_id',
'pmid', 'study_title', 'metadata_complete',
'number_samples_collected', 'study_abstract']
study_info = Study.get_info(study_set, cols)
infolist = []
for info in study_info:
# Convert DictCursor to proper dict
info = dict(info)
study = Study(info['study_id'])
# Build the processed data info for the study if none passed
if build_samples:
proc_data_list = study.processed_data()
proc_samples = {}
study_proc = {study.id: defaultdict(list)}
for pid in proc_data_list:
proc_data = ProcessedData(pid)
study_proc[study.id][proc_data.data_type()].append(pid)
proc_samples[pid] = proc_data.samples
study_info = _build_single_study_info(study, info, study_proc,
proc_samples)
infolist.append(study_info)
return infolist
示例3: test_get_info
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import get_info [as 别名]
def test_get_info(self):
# Test get all info for single study
qiita_config.portal = 'QIITA'
obs = Study.get_info([1])
self.assertEqual(len(obs), 1)
obs = dict(obs[0])
exp = {
'mixs_compliant': True, 'metadata_complete': True,
'reprocess': False, 'timeseries_type': 'None',
'number_samples_promised': 27, 'emp_person_id': 2,
'funding': None, 'vamps_id': None,
'first_contact': datetime(2014, 5, 19, 16, 10),
'principal_investigator_id': 3, 'timeseries_type_id': 1,
'pmid': ['123456', '7891011'], 'study_alias': 'Cannabis Soils',
'spatial_series': False,
'study_abstract': 'This is a preliminary study to examine the '
'microbiota associated with the Cannabis plant. Soils samples from'
' the bulk soil, soil associated with the roots, and the '
'rhizosphere were extracted and the DNA sequenced. Roots from '
'three independent plants of different strains were examined. '
'These roots were obtained November 11, 2011 from plants that had '
'been harvested in the summer. Future studies will attempt to '
'analyze the soils and rhizospheres from the same location at '
'different time points in the plant lifecycle.',
'study_description': 'Analysis of the Cannabis Plant Microbiome',
'intervention_type': 'None', 'email': '[email protected]',
'study_id': 1,
'most_recent_contact': datetime(2014, 5, 19, 16, 11),
'lab_person_id': 1,
'study_title': 'Identification of the Microbiomes for Cannabis '
'Soils', 'number_samples_collected': 27}
self.assertItemsEqual(obs, exp)
# Test get specific keys for single study
exp_keys = ['metadata_complete', 'reprocess', 'timeseries_type',
'pmid', 'study_title']
obs = Study.get_info([1], exp_keys)
self.assertEqual(len(obs), 1)
obs = dict(obs[0])
exp = {
'metadata_complete': True, 'reprocess': False,
'timeseries_type': 'None',
'pmid': ['123456', '7891011'],
'study_title': 'Identification of the Microbiomes for Cannabis '
'Soils'}
self.assertItemsEqual(obs, exp)
# Test get specific keys for all studies
info = {
'timeseries_type_id': 1,
'lab_person_id': None,
'principal_investigator_id': 3,
'metadata_complete': False,
'mixs_compliant': True,
'study_description': 'desc',
'study_alias': 'alias',
'study_abstract': 'abstract'}
user = User('[email protected]')
Study.create(user, 'test_study_1', efo=[1], info=info)
obs = Study.get_info(info_cols=exp_keys)
exp = [[True, ['123456', '7891011'], False,
'Identification of the Microbiomes for Cannabis Soils',
'None'],
[False, None, False, 'test_study_1', 'None']]
self.assertEqual(obs, exp)
# test portal restriction working
qiita_config.portal = 'EMP'
with self.assertRaises(QiitaDBError):
Study.get_info([1])
示例4: _build_study_info
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import get_info [as 别名]
def _build_study_info(user, results=None):
"""builds list of dicts for studies table, with all html formatted"""
# get list of studies for table
study_list = user.user_studies.union(
Study.get_by_status('public')).union(user.shared_studies)
if results is not None:
study_list = study_list.intersection(results)
if not study_list:
# No studies left so no need to continue
return []
# get info for the studies
cols = ['study_id', 'email', 'principal_investigator_id',
'pmid', 'study_title', 'metadata_complete',
'number_samples_collected', 'study_abstract']
study_info = Study.get_info(study_list, cols)
infolist = []
for row, info in enumerate(study_info):
study = Study(info['study_id'])
status = study.status
# Just passing the email address as the name here, since
# name is not a required field in qiita.qiita_user
PI = StudyPerson(info['principal_investigator_id'])
PI = study_person_linkifier((PI.email, PI.name))
if info['pmid'] is not None:
pmids = ", ".join([pubmed_linkifier([p])
for p in info['pmid']])
else:
pmids = ""
if info["number_samples_collected"] is None:
info["number_samples_collected"] = "0"
shared = _get_shared_links_for_study(study)
meta_complete_glyph = "ok" if info["metadata_complete"] else "remove"
# build the HTML elements needed for table cell
title = ("<a href='#' data-toggle='modal' "
"data-target='#study-abstract-modal' "
"onclick='fillAbstract(\"studies-table\", {0})'>"
"<span class='glyphicon glyphicon-file' "
"aria-hidden='true'></span></a> | "
"<a href='/study/description/{1}' "
"id='study{0}-title'>{2}</a>").format(
str(row), str(study.id), info["study_title"])
meta_complete = "<span class='glyphicon glyphicon-%s'></span>" % \
meta_complete_glyph
if status == 'public':
shared = "Not Available"
else:
shared = ("<span id='shared_html_{0}'>{1}</span><br/>"
"<a class='btn btn-primary btn-xs' data-toggle='modal' "
"data-target='#share-study-modal-view' "
"onclick='modify_sharing({0});'>Modify</a>".format(
study.id, shared))
infolist.append({
"checkbox": "<input type='checkbox' value='%d' />" % study.id,
"id": study.id,
"title": title,
"meta_complete": meta_complete,
"num_samples": info["number_samples_collected"],
"shared": shared,
"num_raw_data": len(study.raw_data()),
"pi": PI,
"pmid": pmids,
"status": status,
"abstract": info["study_abstract"]
})
return infolist
示例5: test_get_info
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import get_info [as 别名]
def test_get_info(self):
# Test get all info for single study
qiita_config.portal = "QIITA"
obs = Study.get_info([1])
self.assertEqual(len(obs), 1)
obs = dict(obs[0])
exp = {
"mixs_compliant": True,
"metadata_complete": True,
"reprocess": False,
"timeseries_type": "None",
"number_samples_promised": 27,
"emp_person_id": 2,
"funding": None,
"vamps_id": None,
"first_contact": datetime(2014, 5, 19, 16, 10),
"principal_investigator_id": 3,
"timeseries_type_id": 1,
"pmid": ["123456", "7891011"],
"study_alias": "Cannabis Soils",
"spatial_series": False,
"study_abstract": "This is a preliminary study to examine the "
"microbiota associated with the Cannabis plant. Soils samples from"
" the bulk soil, soil associated with the roots, and the "
"rhizosphere were extracted and the DNA sequenced. Roots from "
"three independent plants of different strains were examined. "
"These roots were obtained November 11, 2011 from plants that had "
"been harvested in the summer. Future studies will attempt to "
"analyze the soils and rhizospheres from the same location at "
"different time points in the plant lifecycle.",
"study_description": "Analysis of the Cannabis Plant Microbiome",
"intervention_type": "None",
"email": "[email protected]",
"study_id": 1,
"most_recent_contact": datetime(2014, 5, 19, 16, 11),
"lab_person_id": 1,
"study_title": "Identification of the Microbiomes for Cannabis " "Soils",
"number_samples_collected": 27,
}
self.assertItemsEqual(obs, exp)
# Test get specific keys for single study
exp_keys = ["metadata_complete", "reprocess", "timeseries_type", "pmid", "study_title"]
obs = Study.get_info([1], exp_keys)
self.assertEqual(len(obs), 1)
obs = dict(obs[0])
exp = {
"metadata_complete": True,
"reprocess": False,
"timeseries_type": "None",
"pmid": ["123456", "7891011"],
"study_title": "Identification of the Microbiomes for Cannabis " "Soils",
}
self.assertItemsEqual(obs, exp)
# Test get specific keys for all studies
info = {
"timeseries_type_id": 1,
"lab_person_id": None,
"principal_investigator_id": 3,
"metadata_complete": False,
"mixs_compliant": True,
"study_description": "desc",
"study_alias": "alias",
"study_abstract": "abstract",
}
user = User("[email protected]")
Study.create(user, "test_study_1", efo=[1], info=info)
obs = Study.get_info(info_cols=exp_keys)
exp = [
[True, ["123456", "7891011"], False, "Identification of the Microbiomes for Cannabis Soils", "None"],
[False, None, False, "test_study_1", "None"],
]
self.assertEqual(obs, exp)
# test portal restriction working
qiita_config.portal = "EMP"
with self.assertRaises(QiitaDBError):
Study.get_info([1])