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
edaa9930
Commit
edaa9930
authored
Apr 15, 2021
by
Kenzo-Hugo Hillion
♻
Browse files
update filters and use from frontend
parent
580c2bdf
Pipeline
#53863
failed with stages
in 3 minutes and 45 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/api/catalog/filters/gene.py
View file @
edaa9930
...
...
@@ -24,6 +24,9 @@ class GeneFilter(filters.FilterSet):
tax_id
=
filters
.
CharFilter
(
method
=
'filter_annotated_tax'
)
source
=
filters
.
CharFilter
(
field_name
=
"source__slug"
)
function
=
filters
.
ModelMultipleChoiceFilter
(
queryset
=
Function
.
objects
.
all
(),
field_name
=
'functions__function_id'
,
...
...
@@ -37,4 +40,4 @@ class GeneFilter(filters.FilterSet):
class
Meta
:
model
=
Gene
fields
=
[
'length'
,
'name'
,
'source'
]
fields
=
[
'length'
,
'name'
]
backend/metagenedb/api/catalog/urls.py
View file @
edaa9930
...
...
@@ -61,6 +61,7 @@ api_router.register(r'kegg-orthologies', views.KeggOrthologyViewSet, basename='k
api_router
.
register
(
r
'eggnogs'
,
views
.
EggNOGViewSet
,
basename
=
'eggnogs'
)
api_router
.
register
(
r
'genes'
,
views
.
GeneViewSet
,
basename
=
'genes'
)
api_router
.
register
(
r
'taxonomy'
,
views
.
TaxonomyViewSet
,
basename
=
'taxonomy'
)
api_router
.
register
(
r
'sources'
,
views
.
SourceViewSet
,
basename
=
'sources'
)
api_router
.
register
(
r
'statistics'
,
views
.
StatisticsViewSet
,
basename
=
'statistics'
)
...
...
backend/metagenedb/api/catalog/views/__init__.py
View file @
edaa9930
from
.function
import
EggNOGViewSet
,
KeggOrthologyViewSet
,
FunctionViewSet
# noqa
from
.gene
import
GeneViewSet
# noqa
from
.statistics
import
StatisticsViewSet
# noqa
from
.source
import
SourceViewSet
# noqa
from
.taxonomy
import
TaxonomyViewSet
# noqa
backend/metagenedb/api/catalog/views/source.py
0 → 100644
View file @
edaa9930
from
drf_yasg.utils
import
swagger_auto_schema
from
metagenedb.apps.catalog.models
import
Source
from
metagenedb.apps.catalog.serializers
import
SourceSerializer
from
.base
import
BulkViewSet
class
SourceViewSet
(
BulkViewSet
):
queryset
=
Source
.
objects
.
all
()
serializer_class
=
SourceSerializer
lookup_field
=
'slug'
@
swagger_auto_schema
(
operation_description
=
"List all gene sources"
,
operation_summary
=
"API to list all gene sources of the catalog."
,
tags
=
[
'Source'
],
)
def
list
(
self
,
*
args
,
**
kwargs
):
return
super
().
list
(
*
args
,
**
kwargs
)
@
swagger_auto_schema
(
operation_description
=
"Retrieve gene source from a name"
,
operation_summary
=
"API to retrieve gene source."
,
tags
=
[
'Source'
],
)
def
retrieve
(
self
,
*
args
,
**
kwargs
):
return
super
().
retrieve
(
*
args
,
**
kwargs
)
@
swagger_auto_schema
(
tags
=
[
'Source'
],
)
def
create
(
self
,
*
args
,
**
kwargs
):
return
super
().
create
(
*
args
,
**
kwargs
)
@
swagger_auto_schema
(
tags
=
[
'Source'
],
)
def
update
(
self
,
*
args
,
**
kwargs
):
return
super
().
update
(
*
args
,
**
kwargs
)
@
swagger_auto_schema
(
tags
=
[
'Source'
],
)
def
partial_update
(
self
,
*
args
,
**
kwargs
):
return
super
().
partial_update
(
*
args
,
**
kwargs
)
backend/metagenedb/apps/catalog/admin/source.py
View file @
edaa9930
...
...
@@ -5,5 +5,5 @@ from metagenedb.apps.catalog.models import Source
@
admin
.
register
(
Source
)
class
SourceAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'name'
,
'url'
,
'doi'
)
list_display
=
(
'name'
,
'slug'
,
'url'
,
'doi'
)
search_fields
=
(
'name'
,)
backend/metagenedb/apps/catalog/migrations/0030_source_slug.py
0 → 100644
View file @
edaa9930
# Generated by Django 3.1.7 on 2021-04-15 13:16
from
django.db
import
migrations
,
models
from
slugify
import
slugify
def
add_slug
(
apps
,
schema_editor
):
Source
=
apps
.
get_model
(
'catalog'
,
'Source'
)
for
item
in
Source
.
objects
.
all
():
item
.
slug
=
slugify
(
item
.
name
)
item
.
save
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'catalog'
,
'0029_source'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'source'
,
name
=
'slug'
,
field
=
models
.
CharField
(
db_index
=
True
,
max_length
=
100
,
unique
=
True
,
null
=
True
),
preserve_default
=
False
,
),
migrations
.
RunPython
(
add_slug
),
migrations
.
AlterField
(
model_name
=
'source'
,
name
=
'slug'
,
field
=
models
.
CharField
(
db_index
=
True
,
max_length
=
100
,
unique
=
True
),
),
]
backend/metagenedb/apps/catalog/models/source.py
View file @
edaa9930
from
django.db
import
models
from
slugify
import
slugify
class
Source
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
db_index
=
True
)
slug
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
db_index
=
True
)
url
=
models
.
CharField
(
max_length
=
100
,
blank
=
True
)
doi
=
models
.
CharField
(
max_length
=
100
,
blank
=
True
)
tools
=
models
.
JSONField
(
blank
=
True
,
null
=
True
)
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
slug
=
slugify
(
self
.
name
)
super
(
Source
,
self
).
save
(
*
args
,
**
kwargs
)
def
__str__
(
self
):
return
f
"
{
self
.
name
}
"
backend/metagenedb/apps/catalog/serializers/__init__.py
View file @
edaa9930
from
.function
import
EggNOGSerializer
,
FunctionSerializer
,
KeggOrthologySerializer
# noqa
from
.gene
import
GeneSerializer
# noqa
from
.statistics
import
StatisticsSerializer
# noqa
from
.source
import
SourceSerializer
# noqa
from
.taxonomy
import
TaxonomySerializer
# noqa
backend/metagenedb/apps/catalog/serializers/source.py
View file @
edaa9930
...
...
@@ -7,5 +7,5 @@ class SourceSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Source
fields
=
(
'name'
,
'url'
,
'doi'
'name'
,
'slug'
,
'url'
,
'doi'
)
frontend/src/views/genes/genes.html
View file @
edaa9930
...
...
@@ -66,7 +66,7 @@
<!-- Gene source -->
<v-flex
xs12
sm6
md4
lg2
>
<v-select
:items=
"geneSources"
:items=
"
Object.keys(
geneSources
)
"
v-model=
"geneSource"
label=
"Gene source"
@
input=
"getTaxoPresenceOptional"
...
...
frontend/src/views/genes/genes.js
View file @
edaa9930
...
...
@@ -21,6 +21,8 @@ export default {
searchGeneName
:
null
,
filterGeneLength
:
false
,
geneLengthFilterRange
:
[
0
,
2000
],
// - Source
geneSources
:
{},
// - Taxonomy
taxLevel
:
null
,
taxItems
:
[],
...
...
@@ -63,12 +65,6 @@ export default {
];
return
this
.
formatList
(
texts
);
},
geneSources
()
{
const
texts
=
[
'
IGC
'
,
'
Virgo
'
,
];
return
this
.
formatList
(
texts
);
},
rowsPerPageItems
()
{
return
[
this
.
page_size
];
},
...
...
@@ -78,7 +74,7 @@ export default {
page
:
this
.
pageNumber
};
if
(
this
.
geneSource
&&
this
.
geneSource
!=
'
all
'
)
{
qParams
.
source
=
this
.
geneSource
qParams
.
source
=
this
.
geneSource
s
[
this
.
geneSource
];
}
if
(
this
.
filterGeneLength
)
{
qParams
.
length__gt
=
this
.
geneLengthFilterRange
[
0
];
...
...
@@ -199,6 +195,7 @@ export default {
}
},
mounted
()
{
this
.
getSources
();
this
.
getGenes
();
},
methods
:
{
...
...
@@ -270,6 +267,23 @@ export default {
this
.
requestDone
=
true
;
});
},
getSources
()
{
axios
.
get
(
'
/api/catalog/v1/sources
'
,
{
params
:
this
.
qParams
,
headers
:
{
Accept
:
'
application/json
'
,
},
})
.
then
((
response
)
=>
{
const
sources
=
response
.
data
.
results
;
sources
.
forEach
((
item
,
index
)
=>
{
this
.
geneSources
[
item
.
name
]
=
item
.
slug
;
});
})
.
catch
((
error
)
=>
{
console
.
error
(
error
);
});
},
forceFileDownload
(
response
,
fileName
){
const
url
=
window
.
URL
.
createObjectURL
(
new
Blob
([
response
.
data
]))
const
link
=
document
.
createElement
(
'
a
'
)
...
...
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