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
d2ffd8c9
Commit
d2ffd8c9
authored
Dec 06, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
add requirement for JWT token to create database
parent
9821e311
Pipeline
#19395
failed with stages
in 2 minutes and 17 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
backend/metagenedb/settings/django.py
View file @
d2ffd8c9
...
...
@@ -116,7 +116,7 @@ REST_FRAMEWORK = {
# JWT Authorization settings
JWT_AUTH
=
{
'JWT_EXPIRATION_DELTA'
:
datetime
.
timedelta
(
seconds
=
3600
)
'JWT_EXPIRATION_DELTA'
:
datetime
.
timedelta
(
days
=
7
)
}
...
...
backend/scripts/populate_db/import_igc_data.py
View file @
d2ffd8c9
...
...
@@ -24,12 +24,12 @@ class ImportIGCGenes(object):
GENUS_COL
=
'taxo_genus'
SELECTED_KEYS
=
[
'gene_id'
,
'length'
,
'kegg_ko'
,
PHYLUM_COL
,
GENUS_COL
]
def
__init__
(
self
,
annotation_file
,
url
,
skip_tax
=
False
,
skip_functions
=
False
):
def
__init__
(
self
,
annotation_file
,
url
,
jwt_token
,
skip_tax
=
False
,
skip_functions
=
False
):
self
.
annotation_file
=
annotation_file
self
.
url
=
url
self
.
metagenedb_gene_api
=
self
.
METAGENEDB_GENE_API
(
base_url
=
self
.
url
)
self
.
metagenedb_taxonomy_api
=
self
.
METAGENEDB_TAXONOMY_API
(
base_url
=
self
.
url
)
self
.
metagenedb_function_api
=
self
.
METAGENEDB_FUNCTION_API
(
base_url
=
self
.
url
)
self
.
metagenedb_gene_api
=
self
.
METAGENEDB_GENE_API
(
base_url
=
self
.
url
,
jwt_token
=
jwt_token
)
self
.
metagenedb_taxonomy_api
=
self
.
METAGENEDB_TAXONOMY_API
(
base_url
=
self
.
url
,
jwt_token
=
jwt_token
)
self
.
metagenedb_function_api
=
self
.
METAGENEDB_FUNCTION_API
(
base_url
=
self
.
url
,
jwt_token
=
jwt_token
)
self
.
total_genes
=
self
.
_get_number_genes
()
self
.
_reset_counters
()
# Skip some insertion if specified in script options
...
...
@@ -177,6 +177,7 @@ def parse_arguments():
# Common arguments for analysis and annotations
parser
.
add_argument
(
'annotation'
,
help
=
'IGC annotation file'
)
parser
.
add_argument
(
'--url'
,
help
=
'base URL of the instance.'
,
default
=
'http://localhost/'
)
parser
.
add_argument
(
'-t'
,
'--jwt_token'
,
help
=
'your JWT token obtain from web app'
,
required
=
True
)
parser
.
add_argument
(
'--chunk_size'
,
type
=
int
,
default
=
1000
,
help
=
'How many genes to handle and create in the same time.'
)
parser
.
add_argument
(
'--skip_taxonomy'
,
action
=
'store_true'
,
help
=
'Skip taxonomy information from genes.'
)
...
...
@@ -194,7 +195,7 @@ def run():
args
=
parse_arguments
()
if
args
.
verbose
:
logger
.
setLevel
(
logging
.
INFO
)
import_igc_genes
=
ImportIGCGenes
(
args
.
annotation
,
args
.
url
,
import_igc_genes
=
ImportIGCGenes
(
args
.
annotation
,
args
.
url
,
args
.
jwt_token
,
skip_tax
=
args
.
skip_taxonomy
,
skip_functions
=
args
.
skip_functions
)
import_igc_genes
.
load_annotation_file_to_db_in_chunks
(
chunk_size
=
args
.
chunk_size
,
test
=
args
.
test
)
...
...
backend/scripts/populate_db/import_ncbi_taxonomy.py
View file @
d2ffd8c9
...
...
@@ -18,8 +18,8 @@ class ImportNCBITaxonomy(object):
METAGENEDB_TAX_API
=
MetageneDBCatalogTaxonomyAPI
FOREIGN_KEY_FIELDS
=
[
'parent_tax_id'
]
def
__init__
(
self
,
url
,
tax_names_file
,
tax_nodes_file
):
self
.
metagenedb_tax_api
=
self
.
METAGENEDB_TAX_API
(
base_url
=
url
)
def
__init__
(
self
,
url
,
jwt_token
,
tax_names_file
,
tax_nodes_file
):
self
.
metagenedb_tax_api
=
self
.
METAGENEDB_TAX_API
(
base_url
=
url
,
jwt_token
=
jwt_token
)
self
.
tax_names_file
=
tax_names_file
self
.
tax_nodes_file
=
tax_nodes_file
self
.
total_tax
=
self
.
_get_number_nodes
()
...
...
@@ -104,6 +104,7 @@ def parse_arguments():
parser
.
add_argument
(
'--names'
,
help
=
'names.dmp file from ncbi_taxonomy'
,
required
=
True
)
parser
.
add_argument
(
'--skip_creation'
,
action
=
'store_true'
,
help
=
'Skip taxonomy creation.'
)
parser
.
add_argument
(
'--url'
,
help
=
'base URL of the instance.'
,
default
=
'http://localhost/'
)
parser
.
add_argument
(
'-t'
,
'--jwt_token'
,
help
=
'your JWT token obtain from web app'
,
required
=
True
)
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
)
try
:
...
...
@@ -116,7 +117,7 @@ def run():
args
=
parse_arguments
()
if
args
.
verbose
:
logger
.
setLevel
(
logging
.
INFO
)
import_ncbi_tax
=
ImportNCBITaxonomy
(
args
.
url
,
args
.
names
,
args
.
nodes
)
import_ncbi_tax
=
ImportNCBITaxonomy
(
args
.
url
,
args
.
jwt_token
,
args
.
names
,
args
.
nodes
)
taxonomy_names
=
import_ncbi_tax
.
import_names
()
if
not
args
.
skip_creation
:
import_ncbi_tax
.
create_taxo_nodes
(
taxonomy_names
)
...
...
backend/scripts/populate_db/load_kegg_ko.py
View file @
d2ffd8c9
...
...
@@ -21,9 +21,9 @@ class ImportKEGGKO(object):
ORM_SOURCE_KEY
=
'source'
KEGG_SOURCE
=
'kegg'
def
__init__
(
self
,
url
,
kegg_ko_list_api
=
KEGG_KO_LIST_API
):
def
__init__
(
self
,
url
,
jwt_token
,
kegg_ko_list_api
=
KEGG_KO_LIST_API
):
self
.
kegg_ko_list_api
=
kegg_ko_list_api
self
.
metagenedb_function_api
=
self
.
METAGENEDB_FUNCTION_API
(
base_url
=
url
)
self
.
metagenedb_function_api
=
self
.
METAGENEDB_FUNCTION_API
(
base_url
=
url
,
jwt_token
=
jwt_token
)
self
.
processed_kegg
=
0
self
.
created_kegg
=
0
self
.
updated_kegg
=
0
...
...
@@ -55,6 +55,7 @@ def parse_arguments():
"""
parser
=
argparse
.
ArgumentParser
(
description
=
f
'Populate KEGG KO database from
{
KEGG_KO_LIST_API
}
.'
)
parser
.
add_argument
(
'--url'
,
help
=
'base URL of the instance.'
,
default
=
'http://localhost/'
)
parser
.
add_argument
(
'-t'
,
'--jwt_token'
,
help
=
'your JWT token obtain from web app'
,
required
=
True
)
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
)
try
:
return
parser
.
parse_args
()
...
...
@@ -66,7 +67,7 @@ def run():
args
=
parse_arguments
()
if
args
.
verbose
:
logger
.
setLevel
(
logging
.
INFO
)
import_kegg_ko
=
ImportKEGGKO
(
args
.
url
)
import_kegg_ko
=
ImportKEGGKO
(
args
.
url
,
args
.
jwt_token
)
import_kegg_ko
.
load_all_kegg_ko
()
...
...
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