Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Metagenomics
metagenedb
Commits
b63f5670
Commit
b63f5670
authored
Aug 06, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
Change status when no content for gene_length
parent
ecd074eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/api/catalog/views/gene.py
View file @
b63f5670
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
:
labels
.
append
(
f
"
{
rg
[
0
]
}
-
{
rg
[
1
]
-
1
}
"
)
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'
:
{}},
status
=
status
.
HTTP_204_NO_CONTENT
)
return
Response
(
{
'results'
:
self
.
_count_windows
(
df
,
window_size
)}
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment