當前位置: 首頁>>代碼示例>>Python>>正文


Python Variant.fromJSON方法代碼示例

本文整理匯總了Python中xbrowse.Variant.fromJSON方法的典型用法代碼示例。如果您正苦於以下問題:Python Variant.fromJSON方法的具體用法?Python Variant.fromJSON怎麽用?Python Variant.fromJSON使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xbrowse.Variant的用法示例。


在下文中一共展示了Variant.fromJSON方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: mendelian_variant_search_spec

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
def mendelian_variant_search_spec(request):

    project, family = get_project_and_family_for_user(request.user, request.GET)

    # TODO: use form

    search_hash = request.GET.get('search_hash')
    search_spec_dict, variants = cache_utils.get_cached_results(project.project_id, search_hash)
    search_spec = MendelianVariantSearchSpec.fromJSON(search_spec_dict)
    if variants is None:
        variants = api_utils.calculate_mendelian_variant_search(search_spec, family.xfamily())
    else:
        variants = [Variant.fromJSON(v) for v in variants]
    add_extra_info_to_variants_family(get_reference(), family, variants)
    return_type = request.GET.get('return_type')
    if return_type == 'json' or not return_type:
        return JSONResponse({
            'is_error': False,
            'variants': [v.toJSON() for v in variants],
            'search_spec': search_spec_dict,
        })
    elif request.GET.get('return_type') == 'csv':
        response = HttpResponse(content_type='text/csv')
        response['Content-Disposition'] = 'attachment; filename="results_{}.csv"'.format(search_hash)
        writer = csv.writer(response)
        indiv_ids = family.indiv_ids_with_variant_data()
        headers = xbrowse_displays.get_variant_display_headers(get_mall(project.project_id), project, indiv_ids)
        writer.writerow(headers)
        for variant in variants:
            fields = xbrowse_displays.get_display_fields_for_variant(get_mall(project.project_id), project, variant, indiv_ids)
            writer.writerow(fields)
        return response
開發者ID:frichter,項目名稱:seqr,代碼行數:34,代碼來源:views.py

示例2: get_variants

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants(self, project_id, family_id, genotype_filter=None, variant_filter=None):

        db_query = _make_db_query(genotype_filter, variant_filter)
        collection = self._get_family_collection(project_id, family_id)
        for variant_dict in collection.find(db_query).sort('xpos'):
            variant = Variant.fromJSON(variant_dict)
            if passes_variant_filter(variant, variant_filter)[0]:
                yield variant
開發者ID:statcgx,項目名稱:xbrowse,代碼行數:10,代碼來源:mongo_datastore.py

示例3: get_single_variant

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_single_variant(self, project_id, family_id, xpos, ref, alt):

        collection = self._get_family_collection(project_id, family_id)
        variant = collection.find_one({'xpos': xpos, 'ref': ref, 'alt': alt})
        if variant:
            return Variant.fromJSON(variant)
        else:
            return None
開發者ID:statcgx,項目名稱:xbrowse,代碼行數:10,代碼來源:mongo_datastore.py

示例4: get_variants_in_range

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
 def get_variants_in_range(self, project_id, family_id, xpos_start, xpos_end):
     collection = self._get_family_collection(project_id, family_id)
     if not collection:
         raise ValueError("Family not found: " + str(family_id))
     for variant_dict in collection.find({'$and': [{'xpos': {'$gte': xpos_start}}, {'xpos': {'$lte': xpos_end}}]}):
         variant = Variant.fromJSON(variant_dict)
         self.add_annotations_to_variant(variant, project_id)
         yield variant
開發者ID:burkesquires,項目名稱:xbrowse,代碼行數:10,代碼來源:mongo_datastore.py

示例5: get_variants_cohort

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants_cohort(self, project_id, cohort_id, variant_filter=None):

        db_query = self._make_db_query(None, variant_filter)
        collection = self._get_family_collection(project_id, cohort_id)
        for i, variant in enumerate(collection.find(db_query).sort('xpos').limit(settings.VARIANT_QUERY_RESULTS_LIMIT+5)):
            if i > settings.VARIANT_QUERY_RESULTS_LIMIT:
                raise Exception("ERROR: this search exceeded the %s variant result size limit. Please set additional filters and try again." % settings.VARIANT_QUERY_RESULTS_LIMIT)

            yield Variant.fromJSON(variant)
開發者ID:macarthur-lab,項目名稱:seqr,代碼行數:11,代碼來源:mongo_datastore.py

示例6: get_single_variant

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
 def get_single_variant(self, project_id, family_id, xpos, ref, alt, user=None):
     collection = self._get_family_collection(project_id, family_id)
     if not collection:
         return None
     variant_dict = collection.find_one({'xpos': xpos, 'ref': ref, 'alt': alt})
     if variant_dict:
         variant = Variant.fromJSON(variant_dict)
         self.add_annotations_to_variants([variant], project_id, family_id=family_id)
         return variant
     else:
         return None
開發者ID:macarthur-lab,項目名稱:seqr,代碼行數:13,代碼來源:mongo_datastore.py

示例7: get_variants_in_range

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants_in_range(self, project_id, family_id, xpos_start, xpos_end):
        collection = self._get_family_collection(project_id, family_id)
        if not collection:
            raise ValueError("Family not found: " + str(family_id))
        for i, variant_dict in enumerate(collection.find({'$and': [{'xpos': {'$gte': xpos_start}}, {'xpos': {'$lte': xpos_end}}]}).limit(MONGO_QUERY_RESULTS_LIMIT+5)):
            if i > MONGO_QUERY_RESULTS_LIMIT:
                raise Exception("ERROR: this search exceeded the %s variant result size limit. Please set additional filters and try again." % MONGO_QUERY_RESULTS_LIMIT)

            variant = Variant.fromJSON(variant_dict)
            self.add_annotations_to_variant(variant, project_id)
            yield variant
開發者ID:mattsolo1,項目名稱:seqr,代碼行數:13,代碼來源:mongo_datastore.py

示例8: get_variants

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants(self, project_id, family_id, genotype_filter=None, variant_filter=None):

        db_query = self._make_db_query(genotype_filter, variant_filter)
        collection = self._get_family_collection(project_id, family_id)
        if not collection:
            print("Error: mongodb collection not found for project %s family %s " % (project_id, family_id))
            return
        for variant_dict in collection.find(db_query).sort('xpos'):
            variant = Variant.fromJSON(variant_dict)
            self.add_annotations_to_variant(variant, project_id)
            if passes_variant_filter(variant, variant_filter)[0]:
                yield variant
開發者ID:burkesquires,項目名稱:xbrowse,代碼行數:14,代碼來源:mongo_datastore.py

示例9: get_variants

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants(self, project_id, variant_filter=None):

        variant_filter_t = VariantFilter(**(variant_filter if variant_filter else {}))

        db_query = self._make_db_query(None, variant_filter)
        collection = self._get_project_collection(project_id)
        for variant_dict in collection.find(db_query).sort('xpos'):
            variant = Variant.fromJSON(variant_dict)
            if variant_filter is None:
                yield variant
            if passes_variant_filter(variant, variant_filter_t)[0]:
                yield variant
開發者ID:ericminikel,項目名稱:xbrowse,代碼行數:14,代碼來源:project_datastore.py

示例10: get_variants

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants(self, project_id, family_id, genotype_filter=None, variant_filter=None):

        db_query = self._make_db_query(genotype_filter, variant_filter)
        collection = self._get_family_collection(project_id, family_id)
        if not collection:
            print("Error: mongodb collection not found for project %s family %s " % (project_id, family_id))
            return
        for i, variant_dict in enumerate(collection.find(db_query).sort('xpos').limit(MONGO_QUERY_RESULTS_LIMIT+5)):
            if i >= MONGO_QUERY_RESULTS_LIMIT:
                raise Exception("ERROR: this search exceeded the %s variant result size limit. Please set additional filters and try again." % MONGO_QUERY_RESULTS_LIMIT)

            variant = Variant.fromJSON(variant_dict)
            self.add_annotations_to_variant(variant, project_id)
            if passes_variant_filter(variant, variant_filter)[0]:
                yield variant
開發者ID:mattsolo1,項目名稱:seqr,代碼行數:17,代碼來源:mongo_datastore.py

示例11: get_variants

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants(self, project_id, family_id, genotype_filter=None, variant_filter=None, quality_filter=None, indivs_to_consider=None, user=None):
        db_query = self._make_db_query(genotype_filter, variant_filter)
        collection = self._get_family_collection(project_id, family_id)
        if not collection:
            logger.error("Error: mongodb collection not found for project %s family %s " % (project_id, family_id))
            return
        for i, variant_dict in enumerate(collection.find({'$and' : [{k: v} for k, v in db_query.items()]}).sort('xpos').limit(settings.VARIANT_QUERY_RESULTS_LIMIT+5)):
            if i >= settings.VARIANT_QUERY_RESULTS_LIMIT:
                raise Exception("ERROR: this search exceeded the %s variant result size limit. Please set additional filters and try again." % settings.VARIANT_QUERY_RESULTS_LIMIT)

            variant = Variant.fromJSON(variant_dict)
            variant.set_extra('project_id', project_id)
            variant.set_extra('family_id', family_id)
            self.add_annotations_to_variants([variant], project_id)

            if passes_variant_filter(variant, variant_filter)[0]:
                yield variant
開發者ID:macarthur-lab,項目名稱:seqr,代碼行數:19,代碼來源:mongo_datastore.py

示例12: get_variants_in_gene

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants_in_gene(self, project_id, gene_id, variant_filter=None):

        if variant_filter is None:
            modified_variant_filter = VariantFilter()
        else:
            modified_variant_filter = copy.deepcopy(variant_filter)
        modified_variant_filter.add_gene(gene_id)

        db_query = self._make_db_query(None, modified_variant_filter)
        collection = self._get_project_collection(project_id)

        variants = []
        for variant_dict in collection.find(db_query).hint([('gene_ids', pymongo.ASCENDING), ('xpos', pymongo.ASCENDING)]):
            variant = Variant.fromJSON(variant_dict)
            if passes_variant_filter(variant, modified_variant_filter):
                variants.append(variant)
        variants = sorted(variants, key=lambda v: v.unique_tuple())
        return variants
開發者ID:ericminikel,項目名稱:xbrowse,代碼行數:20,代碼來源:project_datastore.py

示例13: cohort_variant_search_spec

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
def cohort_variant_search_spec(request):

    project, cohort = get_project_and_cohort_for_user(request.user, request.GET)

    # TODO: use form

    search_spec_dict, variants = cache_utils.get_cached_results(project.project_id, request.GET.get('search_hash'))
    search_spec = MendelianVariantSearchSpec.fromJSON(search_spec_dict)
    if variants is None:
        variants = api_utils.calculate_mendelian_variant_search(search_spec, cohort.xfamily())
    else:
        variants = [Variant.fromJSON(v) for v in variants]
    api_utils.add_extra_info_to_variants_cohort(get_reference(), cohort, variants)

    return JSONResponse({
        'is_error': False,
        'variants': [v.toJSON() for v in variants],
        'search_spec': search_spec.toJSON(),
    })
開發者ID:frichter,項目名稱:seqr,代碼行數:21,代碼來源:views.py

示例14: get_project_variants_in_gene

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_project_variants_in_gene(self, project_id, gene_id, variant_filter=None):

        if variant_filter is None:
            modified_variant_filter = VariantFilter()
        else:
            modified_variant_filter = copy.deepcopy(variant_filter)
        modified_variant_filter.add_gene(gene_id)

        db_query = self._make_db_query(None, modified_variant_filter)
        logger.info("Project Gene Search: " + str(project_id) + " all variants query: " + str(db_query))
        collection = self._get_project_collection(project_id)
        # we have to collect list in memory here because mongo can't sort on xpos,
        # as result size can get too big.
        # need to find a better way to do this.
        variants = [Variant.fromJSON(variant_dict) for variant_dict in collection.find(db_query).hint([('db_gene_ids', pymongo.ASCENDING), ('xpos', pymongo.ASCENDING)])]
        self.add_annotations_to_variants(variants, project_id)
        variants = filter(lambda variant: passes_variant_filter(variant, modified_variant_filter), variants)
        variants = sorted(variants, key=lambda v: v.unique_tuple())
        return variants
開發者ID:macarthur-lab,項目名稱:seqr,代碼行數:21,代碼來源:mongo_datastore.py

示例15: get_variants_in_gene

# 需要導入模塊: from xbrowse import Variant [as 別名]
# 或者: from xbrowse.Variant import fromJSON [as 別名]
    def get_variants_in_gene(self, project_id, family_id, gene_id, genotype_filter=None, variant_filter=None):

        if variant_filter is None:
            modified_variant_filter = VariantFilter()
        else:
            modified_variant_filter = copy.deepcopy(variant_filter)
        modified_variant_filter.add_gene(gene_id)

        db_query = _make_db_query(genotype_filter, modified_variant_filter)
        collection = self._get_family_collection(project_id, family_id)

        # we have to collect list in memory here because mongo can't sort on xpos,
        # as result size can get too big.
        # need to find a better way to do this.
        variants = []
        for variant_dict in collection.find(db_query).hint([('gene_ids', pymongo.ASCENDING), ('xpos', pymongo.ASCENDING)]):
            variant = Variant.fromJSON(variant_dict)
            if passes_variant_filter(variant, modified_variant_filter):
                variants.append(variant)
        variants = sorted(variants, key=lambda v: v.unique_tuple())
        for v in variants:
            yield v
開發者ID:statcgx,項目名稱:xbrowse,代碼行數:24,代碼來源:mongo_datastore.py


注:本文中的xbrowse.Variant.fromJSON方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。