Exemplo n.º 1
0
Arquivo: rest.py Projeto: mtog/AraGWAS
 def aggregated_statistics(self, request, pk):
     """ Retrieve the aggregation percentage for associations meeting filters criteria for this gene. Check the FAQ for details on the filters. """
     gene = elastic.load_gene_by_id(pk)
     zoom = int(request.query_params.get('zoom', 0))
     selected = bool(request.query_params.get('gene', '') == "1")
     # last_el = [request.query_params.get('lastel', '')]
     filters = _get_filter_from_params(request.query_params)
     filters['chr'] = [gene['chr']]
     filters['start'] = gene['positions']['gte'] - zoom
     filters['end'] = gene['positions']['lte'] + zoom
     if selected:
         filters['start'] = gene['positions']['gte']
         filters['end'] = gene['positions']['lte']
         filters['gene_id'] = gene['name']
     chr, maf, mac, type, annotations = elastic.get_aggregated_filtered_statistics(
         filters)
     chr_dict = _get_percentages_from_buckets(chr)
     maf_dict = _get_percentages_from_buckets(maf)
     mac_dict = _get_percentages_from_buckets(mac)
     type_dict = _get_percentages_from_buckets(type)
     annotations_dict = _get_percentages_from_buckets(annotations)
     return Response({
         'chromosomes': chr_dict,
         'maf': maf_dict,
         'mac': mac_dict,
         'types': type_dict,
         'annotations': annotations_dict
     })
Exemplo n.º 2
0
 def aggregated_statistics(self, requests):
     """ Retrieve general statistics (percentage) about all SNPs. """
     chr, maf, mac, type, annotations = elastic.get_aggregated_filtered_statistics({1:1})
     chr_dict = _get_percentages_from_buckets(chr)
     maf_dict = _get_percentages_from_buckets(maf)
     mac_dict = _get_percentages_from_buckets(mac)
     type_dict = _get_percentages_from_buckets(type)
     annotations_dict = _get_percentages_from_buckets(annotations)
     return Response({'chromosomes': chr_dict, 'maf': maf_dict, 'mac': mac_dict, 'types': type_dict, 'annotations': annotations_dict})
Exemplo n.º 3
0
 def aggregated_statistics(self, request):
     """ Retrieve the aggregation percentage for associations meeting filters criteria. Check the FAQ for details on the filters."""
     filters = _get_filter_from_params(request.query_params)
     chr, maf, mac, type, annotations = elastic.get_aggregated_filtered_statistics(filters)
     chr_dict = _get_percentages_from_buckets(chr)
     maf_dict = _get_percentages_from_buckets(maf)
     mac_dict = _get_percentages_from_buckets(mac)
     type_dict = _get_percentages_from_buckets(type)
     annotations_dict = _get_percentages_from_buckets(annotations)
     return Response({'chromosomes': chr_dict, 'maf': maf_dict, 'mac': mac_dict, 'types': type_dict, 'annotations': annotations_dict})
Exemplo n.º 4
0
 def aggregated_statistics(self, request, pk):
     """
     Retrieve the aggregation statistics of the top assocations for a study and a specific set of filters. Check the FAQ for details on the filters.
     """
     filters = _get_filter_from_params(request.query_params)
     filters['study_id'] = [pk]
     chr, maf, mac, type, annotations = elastic.get_aggregated_filtered_statistics(filters)
     chr_dict = _get_percentages_from_buckets(chr)
     maf_dict = _get_percentages_from_buckets(maf)
     mac_dict = _get_percentages_from_buckets(mac)
     type_dict = _get_percentages_from_buckets(type)
     annotations_dict = _get_percentages_from_buckets(annotations)
     return Response({'chromosomes': chr_dict, 'maf': maf_dict, 'mac': mac_dict, 'types': type_dict, 'annotations': annotations_dict})