本文整理汇总了Python中criteria.helper.criteria.Criteria.get_feature_idx_n_idxtypes方法的典型用法代码示例。如果您正苦于以下问题:Python Criteria.get_feature_idx_n_idxtypes方法的具体用法?Python Criteria.get_feature_idx_n_idxtypes怎么用?Python Criteria.get_feature_idx_n_idxtypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类criteria.helper.criteria.Criteria
的用法示例。
在下文中一共展示了Criteria.get_feature_idx_n_idxtypes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_feature_idx_n_idxtypes
# 需要导入模块: from criteria.helper.criteria import Criteria [as 别名]
# 或者: from criteria.helper.criteria.Criteria import get_feature_idx_n_idxtypes [as 别名]
def test_get_feature_idx_n_idxtypes(self):
(idx, idx_types) = Criteria.get_feature_idx_n_idxtypes('gene')
self.assertEqual('pydgin_imb_criteria_gene', idx, 'Got the right idx back')
self.assertIn('cand_gene_in_study', idx_types, 'Got the right idx type back')
self.assertIn('cand_gene_in_region', idx_types, 'Got the right idx type back')
(idx, idx_types) = Criteria.get_feature_idx_n_idxtypes('marker')
self.assertEqual('pydgin_imb_criteria_marker', idx, 'Got the right idx back')
self.assertIn('is_an_index_snp', idx_types, 'Got the right idx type back')
self.assertIn('marker_is_gwas_significant_in_study', idx_types, 'Got the right idx type back')
self.assertIn('is_marker_in_mhc', idx_types, 'Got the right idx type back')
示例2: show_feature_criteria_details
# 需要导入模块: from criteria.helper.criteria import Criteria [as 别名]
# 或者: from criteria.helper.criteria.Criteria import get_feature_idx_n_idxtypes [as 别名]
def show_feature_criteria_details(feature_id, feature_type, feature_doc=None, section='criteria',
section_title="criteria"):
''' Template inclusion tag to render criteria details bar. '''
print('===================')
print(feature_id)
print(feature_type)
print('====================')
(idx, idx_types) = Criteria.get_feature_idx_n_idxtypes(feature_type)
criteria_disease_tags = Criteria.get_all_criteria_disease_tags([feature_id], idx, idx_types)
print(criteria_disease_tags)
return {'criteria': criteria_disease_tags, 'feature_id': feature_id, 'appname': feature_type,
'f': feature_doc, 'section': section, 'section_title': section_title}
示例3: filter_queryset
# 需要导入模块: from criteria.helper.criteria import Criteria [as 别名]
# 或者: from criteria.helper.criteria.Criteria import get_feature_idx_n_idxtypes [as 别名]
def filter_queryset(self, request, queryset, view):
''' Override this method to request just the documents required from elastic. '''
q_size = view.paginator.get_limit(request)
q_from = view.paginator.get_offset(request)
filterable = getattr(view, 'filter_fields', [])
filters = dict([(k, v) for k, v in request.GET.items() if k in filterable])
criteria_idx = self._get_index(filters.get('feature_type', 'GENE_CRITERIA'))
feature_type = filters.get('feature_type')
feature_id = filters.get('feature_id')
aggregate = filters.get('aggregate')
detail = filters.get('detail')
idx = criteria_idx
if type(criteria_idx) == list:
idx = ','.join(ElasticSettings.idx(name) for name in criteria_idx)
else:
idx = ElasticSettings.idx(criteria_idx)
results = []
if feature_id and aggregate == 'true':
disease_doc_tags = Criteria.get_disease_tags(feature_id, idx=idx)
disease_tags = [getattr(d, 'code') for d in disease_doc_tags]
new_obj = ElasticObject()
new_obj.qid = feature_id
new_obj.disease_tags = disease_tags
new_obj.criteria_type = None
results.append(new_obj)
return results
elif feature_id and detail == 'true':
(idx, idx_types) = Criteria.get_feature_idx_n_idxtypes(feature_type.lower())
criteria_details = Criteria.get_criteria_details(feature_id, idx=idx, idx_type=idx_types)
criteria_list = idx_types.split(',')
criteria_details_expanded = Criteria.add_meta_info(idx, criteria_list, criteria_details)
feature_details = self._get_feature_details(criteria_details_expanded)
for criteria, details in feature_details.items():
print(criteria)
new_obj = ElasticObject()
new_obj.qid = details['qid']
new_obj.criteria_type = criteria
disease_tags = details['disease_tags']
fdetails = list(details['fdetails'])
print('+++++++++++++++')
print(disease_tags)
print(fdetails)
print('+++++++++++++++')
new_obj.disease_tags = disease_tags
new_obj.feature_details = fdetails
results.append(new_obj)
return results
else:
q = ElasticQuery(Query.match_all())
s = Search(search_query=q, idx=idx, size=q_size, search_from=q_from)
json_results = s.get_json_response()
for result in json_results['hits']['hits']:
new_obj = ElasticObject(initial=result['_source'])
new_obj.uuid = result['_id']
new_obj.criteria_type = result['_type']
results.append(new_obj)
view.es_count = json_results['hits']['total']
return results