当前位置: 首页>>代码示例>>Python>>正文


Python ElasticQuery.query_match方法代码示例

本文整理汇总了Python中elastic.search.ElasticQuery.query_match方法的典型用法代码示例。如果您正苦于以下问题:Python ElasticQuery.query_match方法的具体用法?Python ElasticQuery.query_match怎么用?Python ElasticQuery.query_match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在elastic.search.ElasticQuery的用法示例。


在下文中一共展示了ElasticQuery.query_match方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _find_snp_position

# 需要导入模块: from elastic.search import ElasticQuery [as 别名]
# 或者: from elastic.search.ElasticQuery import query_match [as 别名]
def _find_snp_position(snp_track, name):
    if snp_track is None:
        query = ElasticQuery.query_match("id", name)
        elastic = Search(query, idx=ElasticSettings.idx('MARKER'))
        snpResult = elastic.get_json_response()
        if(len(snpResult['hits']['hits'])) > 0:
            snp = snpResult['hits']['hits'][0]['_source']
            chrom = snp['seqid'].replace('chr', "")
            position = snp['start']
            return {'chr': chrom, 'start': (position-1), 'end': position, 'name': name}
    else:
        mo = re.match(r"(.*)-(.*)", snp_track)
        (group, track) = mo.group(1, 2)
        try:
            snp_track_idx = ElasticSettings.idx('CP_STATS_'+group.upper(), snp_track.upper())
        except SettingsError:
            snp_track_idx = ElasticSettings.idx('CP_STATS_'+group.upper())+"/"+track

        query = ElasticQuery.query_match("name", name)
        elastic = Search(query, idx=snp_track_idx)
        snpResult = elastic.get_json_response()
        if(len(snpResult['hits']['hits'])) > 0:
            snp = snpResult['hits']['hits'][0]['_source']
            chrom = snp['seqid'].replace('chr', "")
            position = snp['start']
            return {'chr': chrom, 'start': (position-1), 'end': position, 'name': name}

    return {'error': 'Marker '+name+' does not exist in the currently selected dataset'}
开发者ID:D-I-L,项目名称:django-chicp,代码行数:30,代码来源:views.py

示例2: region_page

# 需要导入模块: from elastic.search import ElasticQuery [as 别名]
# 或者: from elastic.search.ElasticQuery import query_match [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')
开发者ID:D-I-L,项目名称:django_template,代码行数:11,代码来源:views.py

示例3: _find_snp_position

# 需要导入模块: from elastic.search import ElasticQuery [as 别名]
# 或者: from elastic.search.ElasticQuery import query_match [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'}
开发者ID:premanand17,项目名称:django-chicp,代码行数:21,代码来源:views.py

示例4: show_es_gene_section

# 需要导入模块: from elastic.search import ElasticQuery [as 别名]
# 或者: from elastic.search.ElasticQuery import query_match [as 别名]
def show_es_gene_section(gene_symbol=None, seqid=None,
                         start_pos=None, end_pos=None):
    ''' Template inclusion tag to render a gene section given a
    chado gene feature. '''
    seqid = str(seqid).replace('chr', '')
    if gene_symbol is not None:
        ''' gene symbol query'''
        query = ElasticQuery.query_match("symbol", gene_symbol)
    elif end_pos is None:
        ''' start and end are same, range query for snp'''
        query_bool = BoolQuery(must_arr=[Query.match("chromosome", seqid),
                                         RangeQuery("start", lte=start_pos),
                                         RangeQuery("stop", gte=start_pos)])
        query = ElasticQuery.bool(query_bool)
    else:
        ''' start and end are same, range query for snp'''
        query_bool = BoolQuery(must_arr=[Query.match("chromosome", seqid),
                                         RangeQuery("start", gte=start_pos),
                                         RangeQuery("stop", lte=end_pos)])
        query = ElasticQuery.bool(query_bool)

    elastic = Search(query, idx=ElasticSettings.idx(name='GENE'))
    return {'es_genes': elastic.search().docs}
开发者ID:D-I-L,项目名称:django_template,代码行数:25,代码来源:gene_tags.py


注:本文中的elastic.search.ElasticQuery.query_match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。