Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ChEMBL
C
ChEMBL
Main Web Interface
Elasticsearch Proxy API
Commits
65196a1c
Commit
65196a1c
authored
Jul 02, 2021
by
David Mendez
Browse files
Entities join: Add more cases to the joins
parent
49d6a58d
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
4 deletions
+68
-4
app/blueprints/entities_join/controllers/entities_join_controller.py
...nts/entities_join/controllers/entities_join_controller.py
+1
-0
app/entities_joiner/standardisation.py
app/entities_joiner/standardisation.py
+12
-2
functional_tests/specific_tests/data/entities_join_query_1.json
...onal_tests/specific_tests/data/entities_join_query_1.json
+29
-0
functional_tests/specific_tests/entities_join/fun_test_entities_join_7.py
.../specific_tests/entities_join/fun_test_entities_join_7.py
+22
-0
functional_tests/specific_tests/entities_join/fun_test_entities_join_all_tests.py
...c_tests/entities_join/fun_test_entities_join_all_tests.py
+4
-2
No files found.
app/blueprints/entities_join/controllers/entities_join_controller.py
View file @
65196a1c
...
...
@@ -40,4 +40,5 @@ def get_link_to_related_items():
selection_description
,
previous_hash
)
return
jsonify
(
json_response
)
except
entities_join_service
.
EntitiesJoinServiceError
as
error
:
app_logging
.
debug
(
str
(
error
))
abort
(
500
,
f
'Internal server error:
{
str
(
error
)
}
'
)
app/entities_joiner/standardisation.py
View file @
65196a1c
...
...
@@ -70,6 +70,7 @@ def create_simple_query_generator(destination_property):
:param destination_property: property to use to build the query
:return: a function to be used to build the join query
"""
def
join_function
(
ids
):
"""
:param ids: ids of the items matches
...
...
@@ -77,11 +78,20 @@ def create_simple_query_generator(destination_property):
"""
ids_clauses
=
" OR "
.
join
([
f
'"
{
item_id
}
"'
for
item_id
in
ids
])
return
f
'
{
destination_property
}
(
{
ids_clauses
}
)'
return
join_function
JOIN_PROPERTIES
=
{
'from'
:
{
PossibleDestinationEntities
.
CHEMBL_COMPOUNDS
:
{
'to'
:
{
PossibleDestinationEntities
.
CHEMBL_ACTIVITIES
:
{
'origin_property'
:
'molecule_chembl_id'
,
'destination_query_generator'
:
create_simple_query_generator
(
'molecule_chembl_id'
)
}
}
},
PossibleOriginEntities
.
CHEMBL_DRUG_WARNINGS
:
{
'to'
:
{
PossibleDestinationEntities
.
CHEMBL_ACTIVITIES
:
{
...
...
functional_tests/specific_tests/data/entities_join_query_1.json
0 → 100644
View file @
65196a1c
{
"query"
:
{
"bool"
:
{
"must"
:
[
{
"query_string"
:
{
"analyze_wildcard"
:
true
,
"query"
:
"*"
}
}
],
"filter"
:
[
[
{
"bool"
:
{
"should"
:
[
{
"term"
:
{
"molecule_type"
:
"Oligosaccharide"
}
}
]
}
}
]
]
}
}
}
\ No newline at end of file
functional_tests/specific_tests/entities_join/fun_test_entities_join_7.py
0 → 100644
View file @
65196a1c
# pylint: disable=import-error
"""
Module that tests the endpoints to do joins among entities from drug warnings to drug indications
"""
from
specific_tests
import
utils
from
specific_tests.entities_join
import
utils
as
entities_join_utils
def
run_test
(
server_base_url
,
delayed_jobs_server_base_path
):
"""
Tests doing a join among different entities from drug warnings to drug mechanisms
:param server_base_url: base url of the running server. E.g. http://127.0.0.1:5000
:param delayed_jobs_server_base_path: base path for the delayed_jobs
"""
print
(
'-------------------------------------------'
)
print
(
'Testing joins among entities selecting all none except'
)
print
(
'-------------------------------------------'
)
dataset_query
=
utils
.
load_json_data
(
'functional_tests/specific_tests/data/entities_join_query_1.json'
)
selection_description
=
{
"selectionMode"
:
"allItemsExcept"
,
"exceptions"
:
[]}
entities_join_utils
.
test_entities_join
(
dataset_query
,
selection_description
,
server_base_url
,
entity_from
=
'CHEMBL_COMPOUNDS'
,
entity_to
=
'CHEMBL_ACTIVITIES'
)
functional_tests/specific_tests/entities_join/fun_test_entities_join_all_tests.py
View file @
65196a1c
...
...
@@ -2,7 +2,8 @@
Module that runs all the tests related to the entities join
"""
from
specific_tests.entities_join
import
fun_test_entities_join_0
,
fun_test_entities_join_1
,
fun_test_entities_join_2
,
\
fun_test_entities_join_3
,
fun_test_entities_join_4
,
fun_test_entities_join_5
fun_test_entities_join_3
,
fun_test_entities_join_4
,
fun_test_entities_join_5
,
fun_test_entities_join_6
,
\
fun_test_entities_join_7
def
run_test
(
server_base_url
,
delayed_jobs_server_base_path
):
...
...
@@ -12,5 +13,6 @@ def run_test(server_base_url, delayed_jobs_server_base_path):
:param delayed_jobs_server_base_path: base path for the delayed_jobs
"""
for
test_module
in
[
fun_test_entities_join_0
,
fun_test_entities_join_1
,
fun_test_entities_join_2
,
fun_test_entities_join_3
,
fun_test_entities_join_4
,
fun_test_entities_join_5
]:
fun_test_entities_join_3
,
fun_test_entities_join_4
,
fun_test_entities_join_5
,
fun_test_entities_join_6
,
fun_test_entities_join_7
]:
test_module
.
run_test
(
server_base_url
,
delayed_jobs_server_base_path
)
Write
Preview
Markdown
is supported
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