Commit b63f5670 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

Change status when no content for gene_length

parent ecd074eb
import pandas as pd
from rest_framework.viewsets import GenericViewSet
from rest_framework import mixins
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.response import Response
......@@ -29,7 +30,7 @@ class GeneViewSet(mixins.ListModelMixin,
labels = []
for rg in all_ranges:
data.append(df[get_mask(df, rg, window_col)].count()['gene_length'])
data.append(df[get_mask(df, rg, window_col)].count()[window_col])
return {
'counts': data,
'labels': labels
......@@ -40,6 +41,11 @@ class GeneViewSet(mixins.ListModelMixin,
if 'window_size' in request.query_params:
window_size = int(request.query_params.get('window_size'))
df = pd.DataFrame(list(self.queryset.values(self.GENE_LENGTH_COL)))
if df.empty:
return Response(
{'results': {}},
return Response(
{'results': self._count_windows(df, window_size)}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment