Skip to content

Commit a44e83b

Browse files
committed
Merge remote-tracking branch 'origin/master' into precompute_stats
2 parents 534c301 + c0753f5 commit a44e83b

2 files changed

Lines changed: 16 additions & 77 deletions

File tree

cohd/TRAPI14.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ info:
4141
url: https://github.com/NCATSTranslator/translator_extensions/blob/\
4242
production/x-translator/
4343
x-trapi:
44-
version: 1.4.2
44+
version: 1.4.0
4545
asyncquery: false
4646
operations:
4747
- lookup

test_cohd_trapi.py

Lines changed: 15 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -589,67 +589,8 @@ def test_translator_query_q2_multiple_ids():
589589
_print_trapi_log(json)
590590

591591

592-
# TODO: Temporarily replacing this test to not use CHEMBL.COMPOUND since Node Norm is currently missing mappings to MeSH
593-
# def test_translator_query_q1_q2_multiple_ids():
594-
# """ Check the TRAPI endpoint when using multiple IDs in the subject and object nodes. Expect COHD to return 12+
595-
# results """
596-
# print(f'\ntest_cohd_trapi: testing TRAPI query with multiple IDs in both query nodes on {cr.server}..... ')
597-
#
598-
# url = f'{cr.server}/query'
599-
# query = '''
600-
# {
601-
# "message": {
602-
# "query_graph": {
603-
# "nodes": {
604-
# "subj": {
605-
# "ids": ["DOID:9053", "UMLS:C2939141", "HP:0002907", "MONDO:0001375"]
606-
# },
607-
# "obj": {
608-
# "ids": ["CHEMBL.COMPOUND:CHEMBL1242", "PUBCHEM.COMPOUND:129211", "UNII:K9P6MC7092"]
609-
# }
610-
# },
611-
# "edges": {
612-
# "e0": {
613-
# "subject": "subj",
614-
# "object": "obj",
615-
# "predicates": ["biolink:correlated_with"]
616-
# }
617-
# }
618-
# }
619-
# },
620-
# "query_options": {
621-
# "max_results": 50
622-
# }
623-
# }
624-
# '''
625-
# query = j.loads(query)
626-
# query['query_options']['query_id'] = str(uuid.uuid4())
627-
# print(j.dumps(query))
628-
# resp = requests.post(url, json=query, timeout=300)
629-
#
630-
# # Expect HTTP 200 status response
631-
# assert resp.status_code == 200, 'Expected an HTTP 200 status response code' \
632-
# f'Received {resp.status_code}: {resp.text}'
633-
#
634-
# # Use the Reasoner Validator Python package to validate against Reasoner Standard API
635-
# json = resp.json()
636-
# _validate_trapi_response(json)
637-
#
638-
# # There should be at least 12 results
639-
# assert len(json['message']['results']) >= 12, _print_trapi_log(json)
640-
#
641-
# # All pairs of the queried IDs should appear in at least one of the results
642-
# subj_ids = ["DOID:9053", "UMLS:C2939141", "HP:0002907", "MONDO:0001375"]
643-
# obj_ids = ["CHEMBL.COMPOUND:CHEMBL1242", "PUBCHEM.COMPOUND:129211", "UNII:K9P6MC7092"]
644-
# result_id_pairs = [(r['node_bindings']['subj'][0]['id'], r['node_bindings']['obj'][0]['id'])
645-
# for r in json['message']['results']]
646-
# for pair in product(subj_ids, obj_ids):
647-
# assert pair in result_id_pairs, f'Query pair {pair} is not found in results pairs {result_id_pairs}.' + \
648-
# _print_trapi_log(json)
649-
#
650-
# print('...passed')
651592
def test_translator_query_q1_q2_multiple_ids():
652-
""" Check the TRAPI endpoint when using multiple IDs in the subject and object nodes. Expect COHD to return 12+
593+
""" Check the TRAPI endpoint when using multiple IDs in the subject and object nodes. Expect > 4 results
653594
results """
654595
print(f'\ntest_cohd_trapi::test_translator_query_q1_q2_multiple_ids: testing TRAPI query with multiple IDs in both '
655596
f'query nodes on {cr.server}..... ')
@@ -664,7 +605,7 @@ def test_translator_query_q1_q2_multiple_ids():
664605
"ids": ["DOID:9053", "UMLS:C2939141", "HP:0002907", "MONDO:0001375"]
665606
},
666607
"obj": {
667-
"ids": ["PUBCHEM.COMPOUND:129211", "UNII:K9P6MC7092"]
608+
"ids": ["PUBCHEM.COMPOUND:4756", "PUBCHEM.COMPOUND:129211", "PUBCHEM.COMPOUND:4101"]
668609
}
669610
},
670611
"edges": {
@@ -694,17 +635,18 @@ def test_translator_query_q1_q2_multiple_ids():
694635
json = resp.json()
695636
_validate_trapi_response(json)
696637

697-
# There should be at least 12 results
698-
assert len(json['message']['results']) >= 8, _print_trapi_log(json)
638+
# There should be more than 4 results
639+
assert len(json['message']['results']) > 4, _print_trapi_log(json)
699640

700-
# All pairs of the queried IDs should appear in at least one of the results
641+
# Each of the IDs should appear in at least 1 result
701642
subj_ids = ["DOID:9053", "UMLS:C2939141", "HP:0002907", "MONDO:0001375"]
702-
obj_ids = ["PUBCHEM.COMPOUND:129211", "UNII:K9P6MC7092"]
703-
result_id_pairs = [(r['node_bindings']['subj'][0]['id'], r['node_bindings']['obj'][0]['id'])
704-
for r in json['message']['results']]
705-
for pair in product(subj_ids, obj_ids):
706-
assert pair in result_id_pairs, f'Query pair {pair} is not found in results pairs {result_id_pairs}.' + \
707-
_print_trapi_log(json)
643+
obj_ids = ["PUBCHEM.COMPOUND:4756", "PUBCHEM.COMPOUND:129211", "PUBCHEM.COMPOUND:4101"]
644+
result_subj_ids = [r['node_bindings']['subj'][0]['id'] for r in json['message']['results']]
645+
result_obj_ids = [r['node_bindings']['obj'][0]['id'] for r in json['message']['results']]
646+
for id in subj_ids:
647+
assert id in result_subj_ids, f'Qnode {id} not found in results {result_subj_ids}.' + _print_trapi_log(json)
648+
for id in obj_ids:
649+
assert id in result_obj_ids, f'Qnode {id} not found in results {result_obj_ids}.' + _print_trapi_log(json)
708650

709651

710652
def test_translator_query_multiple_categories():
@@ -846,11 +788,8 @@ def test_translator_query_multiple_categories():
846788

847789
def test_translator_query_qnode_subclasses():
848790
""" Check the TRAPI endpoint to make sure we're also querying for ID subclasses. The TRAPI query will only specify
849-
a query between MONDO:0005015 (diabetes mellitus) and PUBCHEM.COMPOUND:3476 (glimepiride). Without subclassing,
850-
we would only expect 1 result. But with subclassing working, there should be more (check for at least 2).
851-
Note 7/19/2021: In previous versions of this test, used CHEMBL.COMPOUND:CHEMBL1481 for obj ID, but SRI Node Norm
852-
changed how it performed its mappings, and CHEMBL.COMPOUND:CHEMBL1481 no longer maps to MESH:C057619, which is what
853-
maps to OMOP standard concept. """
791+
a query between MONDO:0005015 (diabetes mellitus) and "PUBCHEM.COMPOUND:16136701" (insulin). Without subclassing,
792+
we would only expect 1 result. But with subclassing working, there should be more (check for at least 2). """
854793
print(f'\ntest_cohd_trapi::test_translator_query_qnode_subclasses: testing TRAPI query with multiple IDs in both '
855794
f'query nodes on {cr.server}..... ')
856795

@@ -864,7 +803,7 @@ def test_translator_query_qnode_subclasses():
864803
"ids": ["MONDO:0005015"]
865804
},
866805
"obj": {
867-
"ids": ["PUBCHEM.COMPOUND:3476"]
806+
"ids": ["PUBCHEM.COMPOUND:16136701"]
868807
}
869808
},
870809
"edges": {

0 commit comments

Comments
 (0)