本文整理汇总了Python中elastic.search.Search.get_result方法的典型用法代码示例。如果您正苦于以下问题:Python Search.get_result方法的具体用法?Python Search.get_result怎么用?Python Search.get_result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elastic.search.Search
的用法示例。
在下文中一共展示了Search.get_result方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: region_page
# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import get_result [as 别名]
def region_page(request, region):
''' Region elastic'''
query = ElasticQuery.query_match("attr.region_id", region)
elastic = Search(query, idx=ElasticSettings.idx(name='REGION'))
context = elastic.get_result()
context['title'] = "Region"
print(context)
return render(request, 'region/region.html', context,
content_type='text/html')
示例2: _build_frags_query
# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import get_result [as 别名]
def _build_frags_query(frags_idx, chrom, segmin, segmax):
query = ElasticQuery.filtered(Query.terms("seqid", [chrom, str("chr"+chrom)]),
Filter(RangeQuery("end", gte=segmin, lte=segmax)),
utils.bedFields)
fragsQuery = Search(search_query=query, search_from=0, size=2000000, idx=frags_idx)
fragsResult = fragsQuery.get_result()
frags = fragsResult['data']
frags = utils.makeRelative(int(segmin), int(segmax), ['start', 'end'], frags)
return frags
示例3: _build_exon_query
# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import get_result [as 别名]
def _build_exon_query(chrom, segmin, segmax, genes):
# get exonic structure for genes in this section
geneExons = dict()
query_bool = BoolQuery()
query_bool.must([Query.term("seqid", chrom)])
if len(genes) > 0:
for g in genes:
query = ElasticQuery.filtered_bool(Query.query_string(g["gene_id"], fields=["name"]),
query_bool, sources=utils.snpFields)
elastic = Search(query, idx=getattr(chicp_settings, 'CP_GENE_IDX')+'/exons/', search_from=0, size=2000)
result = elastic.get_result()
exons = result['data']
exons = utils.makeRelative(int(segmin), int(segmax), ['start', 'end'], exons)
geneExons[g["gene_id"]] = sorted(exons, key=operator.itemgetter("start"))
return geneExons
示例4: _build_hic_query
# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import get_result [as 别名]
def _build_hic_query(query, targetIdx, segmin=0, segmax=0):
hic = []
hicElastic = Search(query, idx=targetIdx, search_from=0, size=2000)
hicResult = hicElastic.get_result()
if len(hicResult['data']) > 0:
hic = hicResult['data']
if segmin == 0 or segmax == 0:
(segmin, segmax) = utils.segCoords(hic)
extension = int(0.05*(segmax-segmin))
segmin = segmin - extension
segmax = segmax + extension
hic = utils.makeRelative(int(segmin), int(segmax), ['baitStart', 'baitEnd', 'oeStart', 'oeEnd'], hic)
return hic, segmin, segmax
示例5: _find_snp_position
# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import get_result [as 别名]
def _find_snp_position(snp_track, name):
mo = re.match(r"(.*)-(.*)", snp_track)
(group, track) = mo.group(1, 2)
snp_track_idx = getattr(chicp_settings, 'CHICP_IDX').get(group).get('INDEX')
snp_track_type = ''
if getattr(chicp_settings, 'CHICP_IDX').get(group).get('TRACKS').get(snp_track):
snp_track_type = getattr(chicp_settings, 'CHICP_IDX').get(group).get('TRACKS') \
.get(snp_track).get('TYPE')
else:
snp_track_type = track
query = ElasticQuery.query_match("name", name)
elastic = Search(query, idx=snp_track_idx+'/'+snp_track_type)
snpResult = elastic.get_result()
if (len(snpResult['data']) > 0):
chrom = snpResult['data'][0]['seqid'].replace('chr', "")
position = snpResult['data'][0]['end']
return {'chr': chrom, 'start': (position-1), 'end': position, 'name': name}
return {'error': 'Marker '+name+' does not exist in the currently selected dataset'}
示例6: _build_snp_query
# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import get_result [as 别名]
def _build_snp_query(snp_track, chrom, segmin, segmax):
snps = []
snpMeta = {}
maxScore = -1
if snp_track and snp_track != 'None':
# get SNPs based on this segment
mo = re.match(r"(.*)-(.*)", snp_track)
(group, track) = mo.group(1, 2)
snp_track_idx = getattr(chicp_settings, 'CHICP_IDX').get(group).get('INDEX')
snp_track_type = ''
if getattr(chicp_settings, 'CHICP_IDX').get(group).get('TRACKS').get(snp_track):
snp_track_type = getattr(chicp_settings, 'CHICP_IDX').get(group).get('TRACKS') \
.get(snp_track).get('TYPE')
else:
snp_track_type = track
query = ElasticQuery.filtered(Query.terms("seqid", [chrom, str("chr"+chrom)]),
Filter(RangeQuery("end", gte=segmin, lte=segmax)),
utils.snpFields)
snpQuery = Search(search_query=query, search_from=0, size=2000000, idx=snp_track_idx+'/'+snp_track_type)
snpResult = snpQuery.get_result()
snps = snpResult['data']
snps = utils.makeRelative(int(segmin), int(segmax), ['start', 'end'], snps)
data_type = getattr(chicp_settings, 'CHICP_IDX').get(group).get('DATA_TYPE')
snpSettings = getattr(chicp_settings, 'STUDY_DEFAULTS').get(data_type)
# if 'max' in snpSettings:
# maxScore = float(snpSettings['max'])
# else:
for s in snps:
if float(s['score']) > maxScore:
maxScore = float(s['score'])
snpSettings['max'] = maxScore
snpMeta = snpSettings
return snps, snpMeta