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


Python Search.range_overlap_query方法代码示例

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


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

示例1: ajax_range_overlap_search

# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import range_overlap_query [as 别名]
def ajax_range_overlap_search(request, src, start, stop, search_idx, ajax):
    ''' Return count or paginated range elastic result as a JSON '''
    if ajax == 'count':
        elastic = Search.range_overlap_query(src, start, stop, idx=search_idx)
        return JsonResponse(elastic.get_count())
    search_from = request.POST.get("from")
    size = request.POST.get("size")
    elastic = Search.range_overlap_query(src, start, stop, search_from=search_from,
                                         size=size, idx=search_idx)
    return JsonResponse(elastic.get_json_response())
开发者ID:D-I-L,项目名称:django_template,代码行数:12,代码来源:views.py

示例2: gene_in_region

# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import range_overlap_query [as 别名]
    def gene_in_region(cls, hit, section=None, config=None, result_container={}):

        try:
            padded_region_doc = utils.Region.pad_region_doc(Document(hit))
        except:
            logger.warn('Region padding error ')
            return result_container

        # 'build_info': {'end': 22411939, 'seqid': '1', 'build': 38, 'start': 22326008}, 'region_id': '1p36.12_008'}
        region_id = getattr(padded_region_doc, "region_id")
        region_name = getattr(padded_region_doc, "region_name")
        build_info = getattr(padded_region_doc, "build_info")
        diseases = getattr(padded_region_doc, "tags")['disease']
        seqid = build_info['seqid']
        start = build_info['start']
        end = build_info['end']

        gene_index = ElasticSettings.idx('GENE', idx_type='GENE')
        elastic = Search.range_overlap_query(seqid=seqid, start_range=start, end_range=end,
                                             idx=gene_index, field_list=['start', 'stop', '_id'],
                                             seqid_param="chromosome",
                                             end_param="stop", size=10000)
        result_docs = elastic.search().docs

        genes = set()
        for doc in result_docs:
            genes.add(doc.doc_id())

        result_container_populated = cls.populate_container(region_id,
                                                            region_name,
                                                            fnotes=None, features=genes,
                                                            diseases=diseases,
                                                            result_container=result_container)
        return result_container_populated
开发者ID:D-I-L,项目名称:django-criteria,代码行数:36,代码来源:gene_criteria.py

示例3: get_genes_for_region

# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import range_overlap_query [as 别名]
def get_genes_for_region(seqid, start, end, must=None):
    coding = []
    non_coding = []
    gene_index = ElasticSettings.idx('GENE', idx_type='GENE')
    elastic = Search.range_overlap_query(seqid=seqid.lower(), start_range=start, end_range=end,
                                         idx=gene_index, field_list=['start', 'stop', '_id', 'biotype', 'symbol'],
                                         seqid_param="chromosome", end_param="stop", size=10000)
    for doc in elastic.search().docs:
        if getattr(doc, "biotype") == "protein_coding":
            coding.append(doc)
        else:
            non_coding.append(doc)
    return (coding, non_coding)
开发者ID:D-I-L,项目名称:pydgin,代码行数:15,代码来源:views.py

示例4: _build_gene_query

# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import range_overlap_query [as 别名]
def _build_gene_query(chrom, segmin, segmax):
    # get genes based on this segment
    geneQuery = Search.range_overlap_query(seqid=chrom, start_range=segmin, end_range=segmax, search_from=0,
                                           size=2000, idx=getattr(chicp_settings, 'CP_GENE_IDX')+'/genes/',
                                           field_list=utils.geneFields)
    geneResult = geneQuery.get_result()
    genes = geneResult['data']
    genes = utils.makeRelative(int(segmin), int(segmax), ['start', 'end'], genes)
    genes = [utils.flattenAttr(o) for o in genes]
    for o in genes:
        o.update({"bumpLevel": 0})
        o.update({"length": (o['end']-o['start'])})
    genes.sort(key=operator.itemgetter('length'))
    return genes
开发者ID:premanand17,项目名称:django-chicp,代码行数:16,代码来源:views.py

示例5: range_overlap_search

# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import range_overlap_query [as 别名]
def range_overlap_search(request, src, start, stop, search_idx=ElasticSettings.indices_str()):
    ''' Renders a elastic result page based on the src, start and stop '''
    elastic = Search.range_overlap_query(src, start, stop, idx=search_idx)

    result = elastic.search()
    context = {}
    context['diseases'] = _add_diseases()
    context['total'] = result.hits_total
    context['db'] = result.idx
    context['size'] = result.size
    context['query'] = result.query
    context["idxs"] = _categories(result.idx)
    context["chromosome"] = src
    context["start"] = start
    context["stop"] = stop
    return render(request, 'search/searchresults.html', context,
                  content_type='text/html')
开发者ID:D-I-L,项目名称:django_template,代码行数:19,代码来源:views.py

示例6: filter_queryset

# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import range_overlap_query [as 别名]
    def filter_queryset(self, request, queryset, view):
        ''' Override this method to request feature locations. '''
        try:
            filterable = getattr(view, 'filter_fields', [])
            filters = dict([(k, v) for k, v in request.GET.items() if k in filterable])
            ftype = filters.get('ftype').upper()
            build = self._get_build(filters.get('build', settings.DEFAULT_BUILD))
            if ftype is None or ftype == '':
                return [ElasticObject(initial={'error': 'No feature type provided.'})]

            idx = 'REGION' if ftype == 'ASSOC_SNP' else ftype
            idx_type = 'STUDY_HITS' if idx == 'REGION' else ftype
            print(idx_type)

            doc_class_str = ElasticSettings.get_label(idx, idx_type, label='class')
            doc_class = import_string(doc_class_str) if doc_class_str is not None else None

            if ftype == 'REGION':
                features = doc_class.get_overlapping_features(build, filters.get('chr').replace('chr', ''),
                                                              filters.get('start'), filters.get('end'))
                return features

            if ftype == 'ASSOC_SNP':
                hits = doc_class.get_overlapping_hits(build, filters.get('chr').replace('chr', ''),
                                                      filters.get('start'), filters.get('end'))
                features = Region.get_immune_snps(hits)
                return features

            sources = ['start', 'stop', 'seqid', 'chromosome', 'strand',
                       'biotype', 'giestain', 'name', 'symbol', 'id', 'ref', 'alt']

            seqid_param = 'seqid'
            end_param = 'stop'
            start_param = 'start'

            if ftype == 'GENE':
                seqid_param = 'chromosome'

            elastic = Search.range_overlap_query(filters.get('chr').replace('chr', ''), filters.get('start'),
                                                 filters.get('end'), idx=ElasticSettings.idx(idx, idx_type), size=10000,
                                                 seqid_param=seqid_param, end_param=end_param, start_param=start_param,
                                                 field_list=sources)
            docs = elastic.search().docs
            features = []
            for doc in docs:
                if isinstance(doc, RegionDocument):
                    doc = Region.pad_region_doc(doc)

                loc = doc.get_position(build=build).split(':')
                pos = loc[1].replace(',', '').split('-')
                attributes = {}
                feature = {
                    'name': doc.get_name(),
                    'id': doc.doc_id(),
                    'chr': loc[0],
                    'start': int(pos[0]),
                    'end': int(pos[1]) if len(pos) > 1 else int(pos[0]),
                    'strand': doc.get_strand_as_int()
                }

                if hasattr(doc, "biotype") and getattr(doc, "biotype") is not None:
                    attributes["biotype"] = getattr(doc, "biotype")
                if hasattr(doc, "giestain") and getattr(doc, "giestain") is not None:
                    attributes["stain"] = getattr(doc, "giestain")
                if hasattr(doc, "ref") and hasattr(doc, "alt") and getattr(doc, "ref") is not None and getattr(doc, "alt") is not None:
                    attributes["alleles"] = getattr(doc, "ref")+"/"+getattr(doc, "alt")
                feature['attributes'] = attributes
                features.append(ElasticObject(feature))
            return features
        except (ConnectionError) as err:
            logger.error(err)
            raise Http404
开发者ID:D-I-L,项目名称:pydgin,代码行数:74,代码来源:feature_resources.py


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