Skip to content
GitLab
Menu
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
7fb4d79e
Commit
7fb4d79e
authored
Aug 07, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
change name gene length to length
parent
65ee2b07
Pipeline
#13610
failed with stages
in 1 minute and 37 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/api/catalog/views/gene.py
View file @
7fb4d79e
import
pandas
as
pd
import
django_filters.rest_framework
from
drf_yasg
import
openapi
from
drf_yasg.utils
import
swagger_auto_schema
from
rest_framework.viewsets
import
GenericViewSet
from
rest_framework.viewsets
import
GenericViewSet
,
ModelViewSet
from
rest_framework
import
mixins
from
rest_framework
import
status
from
rest_framework.decorators
import
action
...
...
@@ -15,16 +16,14 @@ from metagenedb.apps.catalog.serializers import GeneSerializer
# Define global variable for API documentation
window_size_param
=
openapi
.
Parameter
(
'window_size'
,
in_
=
openapi
.
IN_QUERY
,
description
=
'Size of the window.'
,
type
=
openapi
.
TYPE_INTEGER
,
default
=
10000
)
gene_length_schema
=
openapi
.
Schema
(
"pouet"
,
{},
type
=
{
'hihi'
:
'haha'
})
gene_length_response
=
openapi
.
Response
(
'Get the distribution of gene length for a given window size'
,
schema
=
gene_length_schema
)
#
gene_length_schema = openapi.Schema("pouet", {}, type={'hihi': 'haha'})
#
gene_length_response = openapi.Response('Get the distribution of gene length for a given window size', schema=gene_length_schema)
class
GeneViewSet
(
mixins
.
ListModelMixin
,
mixins
.
RetrieveModelMixin
,
GenericViewSet
):
class
GeneViewSet
(
ModelViewSet
):
queryset
=
Gene
.
objects
.
all
()
serializer_class
=
GeneSerializer
GENE_LENGTH_COL
=
'
gene_
length'
GENE_LENGTH_COL
=
'length'
def
_count_windows
(
self
,
df
,
window_size
=
10000
,
window_col
=
GENE_LENGTH_COL
):
"""
...
...
@@ -48,10 +47,9 @@ class GeneViewSet(mixins.ListModelMixin,
@
swagger_auto_schema
(
manual_parameters
=
[
window_size_param
],
responses
=
{
'200'
:
gene_length_response
,
#
'200': gene_length_response,
'204'
:
'no content'
},
security
=
[],
operation_id
=
'List of categories'
,
)
@
action
(
methods
=
[
'get'
],
detail
=
False
)
...
...
backend/metagenedb/apps/catalog/admin/gene.py
View file @
7fb4d79e
...
...
@@ -6,7 +6,7 @@ from metagenedb.apps.catalog.models import Gene
@
admin
.
register
(
Gene
)
class
GeneAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'gene_id'
,
'
gene_
length'
,
'get_functions'
,
'get_taxonomy'
)
list_display
=
(
'gene_id'
,
'length'
,
'get_functions'
,
'get_taxonomy'
)
search_fields
=
(
'gene_id'
,)
def
get_functions
(
self
,
obj
):
...
...
backend/metagenedb/apps/catalog/migrations/0007_
gene_
length_positive.py
→
backend/metagenedb/apps/catalog/migrations/0007_length_
name_and_
positive
_int
.py
View file @
7fb4d79e
# Generated by Django 2.2.1 on 2019-08-07 1
3:2
0
# Generated by Django 2.2.1 on 2019-08-07 1
4:1
0
from
django.db
import
migrations
,
models
...
...
@@ -15,4 +15,9 @@ class Migration(migrations.Migration):
name
=
'gene_length'
,
field
=
models
.
PositiveIntegerField
(),
),
migrations
.
RenameField
(
model_name
=
'gene'
,
old_name
=
'gene_length'
,
new_name
=
'length'
,
),
]
backend/metagenedb/apps/catalog/models/gene.py
View file @
7fb4d79e
...
...
@@ -5,7 +5,7 @@ from .function import Function
class
Gene
(
models
.
Model
):
gene_id
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
db_index
=
True
)
gene_
length
=
models
.
PositiveIntegerField
()
length
=
models
.
PositiveIntegerField
()
functions
=
models
.
ManyToManyField
(
Function
)
taxonomy
=
models
.
ForeignKey
(
'Taxonomy'
,
related_name
=
'genes'
,
...
...
backend/metagenedb/apps/catalog/serializers/gene.py
View file @
7fb4d79e
...
...
@@ -4,7 +4,7 @@ from metagenedb.apps.catalog.serializers import FunctionSerializer
class
GeneSerializer
(
serializers
.
ModelSerializer
):
functions
=
FunctionSerializer
(
many
=
True
,
re
ad_only
=
Tru
e
)
functions
=
FunctionSerializer
(
many
=
True
,
re
quired
=
Fals
e
)
taxonomy
=
serializers
.
SlugRelatedField
(
queryset
=
Taxonomy
.
objects
.
all
(),
slug_field
=
'tax_id'
,
...
...
@@ -13,4 +13,4 @@ class GeneSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Gene
fields
=
(
'gene_id'
,
'
gene_
length'
,
'functions'
,
'taxonomy'
)
fields
=
(
'gene_id'
,
'length'
,
'functions'
,
'taxonomy'
)
backend/metagenedb/settings/django.py
View file @
7fb4d79e
...
...
@@ -106,7 +106,7 @@ REST_FRAMEWORK = {
# 'rest_framework.authentication.BasicAuthentication',
),
'DEFAULT_PAGINATION_CLASS'
:
'rest_framework.pagination.PageNumberPagination'
,
'PAGE_SIZE'
:
100
'PAGE_SIZE'
:
100
,
}
...
...
backend/metagenedb/urls.py
View file @
7fb4d79e
...
...
@@ -39,4 +39,5 @@ urlpatterns = [
path
(
'admin/'
,
admin
.
site
.
urls
),
url
(
r
'^swagger(?P<format>\.json|\.yaml)$'
,
schema_view
.
without_ui
(
cache_timeout
=
0
),
name
=
'schema-json'
),
url
(
r
'^swagger/$'
,
schema_view
.
with_ui
(
'swagger'
,
cache_timeout
=
0
),
name
=
'schema-swagger-ui'
),
url
(
r
'^redoc/$'
,
schema_view
.
with_ui
(
'redoc'
,
cache_timeout
=
0
),
name
=
'schema-redoc'
),
]
nginx/dev/dev.conf
View file @
7fb4d79e
...
...
@@ -41,7 +41,7 @@ http {
}
# backend urls
location
~ ^/(
admin
|
api
|
swagger
|
static
) {
location
~ ^/(
admin
|
api
|
swagger
|
redoc
|
static
) {
proxy_redirect
off
;
proxy_pass
http
://
backend
;
proxy_set_header
X
-
Forwarded
-
For
$
proxy_add_x_forwarded_for
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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