def releases(request): release_id = request.GET.get('release_id') if release_id: releases = DataRelease.objects.filter(id=release_id).values().all() else: releases = DataRelease.objects.values().all() latest = DataRelease.objects.order_by('-id')[0].id change_types = { x['name']: x['id'] for x in ChangeType.objects.values().all() } for release in releases: variants = Variant.objects.filter(Data_Release_id=release['id']) release['variants_added'] = variants.filter( Change_Type_id=change_types['new']).count() release['variants_classified'] = variants.filter( Q(Change_Type_id=change_types['changed_classification']) | Q(Change_Type_id=change_types['added_classification'])).count() release['variants_modified'] = variants.filter( Q(Change_Type_id=change_types['added_information']) | Q(Change_Type_id=change_types['changed_information'])).count() release['variants_deleted'] = variants.filter( Change_Type_id=change_types['deleted']).count() response = JsonResponse({"releases": list(releases), "latest": latest}) response['Access-Control-Allow-Origin'] = '*' return response
def range_filter(reference_genome, variants, reference_name, start, end): """Filters variants by range depending on the reference_genome""" if 'chr' in reference_name: reference_name = reference_name.replace('chr', '') variants = variants.filter(Chr=reference_name) if reference_genome == 'hg36': variants = variants.order_by('Hg36_Start') variants = variants.filter(Hg36_Start__lt=end, Hg36_End__gt=start) elif reference_genome == 'hg37': variants = variants.order_by('Hg37_Start') variants = variants.filter(Hg37_Start__lt=end, Hg37_End__gt=start) elif reference_genome == 'hg38': variants = variants.order_by('Hg38_Start') variants = variants.filter(Hg38_Start__lt=end, Hg38_End__gt=start) return variants
def releases(request): release_id = request.GET.get('release_id') if release_id: releases = DataRelease.objects.filter(id=release_id).values().all() else: releases = DataRelease.objects.values().all() latest = DataRelease.objects.order_by('-id')[0].id change_types = {x['name']: x['id'] for x in ChangeType.objects.values().all()} for release in releases: variants = Variant.objects.filter(Data_Release_id=release['id']) release['variants_added'] = variants.filter(Change_Type_id=change_types['new']).count() release['variants_classified'] = variants.filter( Q(Change_Type_id=change_types['changed_classification']) | Q(Change_Type_id=change_types['added_classification'])).count() release['variants_modified'] = variants.filter( Q(Change_Type_id=change_types['added_information']) | Q(Change_Type_id=change_types['changed_information'])).count() release['variants_deleted'] = variants.filter(Change_Type_id=change_types['deleted']).count() response = JsonResponse({"releases": list(releases), "latest": latest}) response['Access-Control-Allow-Origin'] = '*' return response