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
657d1d9e
Commit
657d1d9e
authored
May 06, 2020
by
Kenzo-Hugo Hillion
♻
Browse files
do not erase kegg while linking eggnog for virgo
parent
e346db16
Pipeline
#29999
passed with stages
in 3 minutes and 29 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/apps/catalog/management/commands/commons/handle_functions.py
View file @
657d1d9e
...
...
@@ -9,6 +9,7 @@ logger = logging.getLogger(__name__)
class
HandleFunctions
:
FUN_SOURCE_TO_DELETE
=
[
'kegg'
,
'eggnog'
]
# links to get rid of everytime
def
_build_function_mapping
(
self
,
source
):
logger
.
info
(
"Building local mapping for %s function..."
,
source
)
...
...
@@ -67,11 +68,15 @@ class HandleFunctions:
mapping
.
append
(
GeneFunction
(
gene
=
genes
[
gene_id
],
function
=
function
))
return
mapping
def
_delete_previous_annotations
(
self
,
genes
):
for
function_source
in
self
.
FUN_SOURCE_TO_DELETE
:
GeneFunction
.
objects
.
filter
(
gene__in
=
genes
.
values
(),
function__source
=
function_source
).
delete
()
def
link_genes_to_functions
(
self
,
functions
):
cleaned_functions
=
self
.
_clean_functions
(
functions
)
genes
=
Gene
.
objects
.
in_bulk
(
cleaned_functions
.
keys
(),
field_name
=
'gene_id'
)
# Get all link with corresponding genes & Delete them
GeneFunction
.
objects
.
filter
(
gene__in
=
genes
.
values
()).
delete
(
)
self
.
_delete_previous_annotations
(
genes
)
# Generate table for bulk_create of function <-> gene and create it
GeneFunction
.
objects
.
bulk_create
(
self
.
_generate_gene_function_mapping
(
cleaned_functions
,
genes
)
...
...
backend/metagenedb/apps/catalog/management/commands/import_virgo_eggnog.py
View file @
657d1d9e
...
...
@@ -19,6 +19,8 @@ class ImportVirgoGeneEggNOGAnnotation(BaseImportGenes, HandleFunctions):
SOURCE
=
'virgo'
PARSER
=
VirgoEggNOGLineParser
FUN_SOURCE_TO_DELETE
=
[
'eggnog'
]
def
_clean_functions
(
self
,
functions
,
unknown_val
=
'unknown'
):
"""
Get rid of functions that are not in the db or entitled unknown
...
...
backend/metagenedb/apps/catalog/management/commands/import_virgo_kegg.py
View file @
657d1d9e
...
...
@@ -19,6 +19,8 @@ class ImportVirgoGeneKeggAnnotation(BaseImportGenes, HandleFunctions):
SOURCE
=
'virgo'
PARSER
=
VirgoKEGGLineParser
FUN_SOURCE_TO_DELETE
=
[
'kegg'
]
def
_clean_functions
(
self
,
functions
,
unknown_val
=
'unknown'
):
"""
Get rid of functions that are not in the db or entitled unknown
...
...
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