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
6bbb575f
Commit
6bbb575f
authored
May 04, 2020
by
Kenzo-Hugo Hillion
♻
Browse files
add end to end test for kegg annotation of virgo
parent
220bb356
Pipeline
#29794
passed with stages
in 3 minutes and 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/apps/catalog/management/commands/tests/test_files/virgo_kegg.tsv
0 → 100644
View file @
6bbb575f
V1 K12345 ljo:LJ0360 dvvi:GSVIVP00035275001 GSVIVT00035275001; assembled CDS; K02948 small subunit ribosomal protein S11
V2 K67890 shg:Sph21_4943 dtni:5367 ;
backend/metagenedb/apps/catalog/management/commands/tests/test_import_virgo_kegg.py
0 → 100644
View file @
6bbb575f
import
os
from
rest_framework.test
import
APITestCase
from
metagenedb.apps.catalog.models
import
Gene
from
metagenedb.apps.catalog.management.commands.import_virgo_genes
import
ImportVirgoGenes
from
metagenedb.apps.catalog.management.commands.import_virgo_kegg
import
ImportVirgoGeneKeggAnnotation
from
metagenedb.apps.catalog.factory.function
import
generate_fake_functions_db
class
TestEndToEnd
(
APITestCase
):
"""
This test depends on two files, one to create genes (gene_length) and the other for this test (kegg)
"""
@
classmethod
def
setUpTestData
(
cls
):
generate_fake_functions_db
()
virgo_gene_length_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"./test_files/virgo_gene_length.tsv"
)
loader
=
ImportVirgoGenes
(
virgo_gene_length_file
)
loader
.
load_all
()
def
test_end_to_end
(
self
):
test_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"./test_files/virgo_kegg.tsv"
)
loader
=
ImportVirgoGeneKeggAnnotation
(
test_file
)
expected_genes
=
{
'v1'
:
{
'source'
:
'virgo'
,
'name'
:
'V1'
,
'functions'
:
{
'kegg'
:
'K12345'
,
}
},
'v2'
:
{
'source'
:
'virgo'
,
'name'
:
'V2'
,
'functions'
:
{
'kegg'
:
'K67890'
,
}
},
}
loader
.
load_all
()
created_genes
=
Gene
.
objects
.
all
().
prefetch_related
(
'functions'
)
for
created_gene
in
created_genes
:
for
key
in
[
'source'
,
'name'
]:
self
.
assertEqual
(
getattr
(
created_gene
,
key
),
expected_genes
[
created_gene
.
gene_id
][
key
])
# Check functions
for
function
in
created_gene
.
functions
.
all
():
self
.
assertIn
(
function
.
source
,
[
'kegg'
,
'eggnog'
])
self
.
assertEqual
(
function
.
function_id
,
expected_genes
[
created_gene
.
gene_id
][
'functions'
][
function
.
source
]
)
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