Skip to content

Commit

Permalink
adding biolink prefix back to qualifier type ids in transform_results…
Browse files Browse the repository at this point in the history
…, improving tests to check for that
  • Loading branch information
EvanDietzMorris committed Aug 7, 2024
1 parent f877fc9 commit 4322e8f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion reasoner_transpiler/cypher.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def transform_attributes(result_item, node=False):
qualifiers = [key for key in result_item if key not in ignore_list
and bmt.is_qualifier(key)]
transformed_attributes['qualifiers'] = [
{"qualifier_type_id": key,
{"qualifier_type_id": f"biolink:{key}",
"qualifier_value": value}
for key, value in result_item.items() if key in qualifiers
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="reasoner-transpiler",
version="2.2.4",
version="2.2.5",
author="Patrick Wang",
author_email="[email protected]",
maintainer="Evan Morris",
Expand Down
17 changes: 13 additions & 4 deletions tests/test_qualifier_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def test_single_qualifier(neo4j_driver):
}
output = neo4j_driver.run(get_query(qgraph), convert_to_trapi=True, qgraph=qgraph)
assert len(output["results"]) == 1
# make sure any edge s
assert len(output["results"][0]["analyses"][0]["edge_bindings"]["e10a"]) == 1
qualified_predicate_output = {'qualifier_type_id': 'biolink:qualified_predicate', 'qualifier_value': 'biolink:causes'}
qualifier_output = output["knowledge_graph"]["edges"]["qualified_edge_multiple_qualifier"]["qualifiers"]
assert qualified_predicate_output in qualifier_output


def test_multi_qualifier(neo4j_driver):
Expand Down Expand Up @@ -77,6 +79,13 @@ def test_multi_qualifier(neo4j_driver):
output = neo4j_driver.run(get_query(qgraph), convert_to_trapi=True, qgraph=qgraph)
assert len(output["results"]) == 1
assert len(output["results"][0]["analyses"][0]["edge_bindings"]["e10a"]) == 2
direction_qualifier_output = {'qualifier_type_id': 'biolink:object_direction_qualifier', 'qualifier_value': 'decreased'}
qualified_predicate_output = {'qualifier_type_id': 'biolink:qualified_predicate', 'qualifier_value': 'biolink:causes'}
aspect_qualifier_output = {'qualifier_type_id': 'biolink:object_aspect_qualifier', 'qualifier_value': 'activity'}
qualifier_output = output["knowledge_graph"]["edges"]["qualified_edge_multiple_qualifier"]["qualifiers"]
assert direction_qualifier_output in qualifier_output
assert aspect_qualifier_output in qualifier_output
assert qualified_predicate_output in qualifier_output


def test_qualifier_heirarchy(neo4j_driver):
Expand Down Expand Up @@ -112,8 +121,8 @@ def test_qualifier_heirarchy(neo4j_driver):
assert len(output["results"][0]["analyses"][0]["edge_bindings"]["e10a"]) == 1


def test_phony_qualifier_value(neo4j_driver):
""" test that no edges are returned with a qualifier value that isn't valid"""
def test_mismatch_qualifier_value(neo4j_driver):
""" test that no edges are returned with a qualifier value that doesn't match any edges"""
qgraph = {
"nodes": {
"n0": {},
Expand Down Expand Up @@ -144,7 +153,7 @@ def test_phony_qualifier_value(neo4j_driver):


def test_empty_qualifier_set(neo4j_driver):
"""Test if edges satifying all constraints are returned"""
"""Test if edges satisfying all constraints are returned"""
qgraph = {
"nodes": {
"n0": {},
Expand Down

0 comments on commit 4322e8f

Please sign in to comment.