Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cohd/cohd_flask.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DEPLOYMENT_ENV = 'ITRB-CI' # Expected values: ITRB-CI, ITRB-TEST, or ITRB-PROD
DEBUG = False
CACHE_TYPE = 'filesystem'
CACHE_TYPE = 'FileSystemCache'
CACHE_DEFAULT_TIMEOUT = 3600
CACHE_DIR = 'flask_cache'
CACHE_THRESHOLD = 100000
Expand Down
12 changes: 11 additions & 1 deletion cohd/cohd_oas3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ info:
[OMOP Common Data Model](https://github.com/OHDSI/CommonDataModel/wiki)
[Athena](http://athena.ohdsi.org) (OMOP vocabularies, search, concept relationships, concept hierarchy)
[Atlas](http://www.ohdsi.org/web/atlas/) (OMOP vocabularies, search, concept relationships, concept hierarchy, concept sets)
version: 5.0.0
version: 5.1.0
title: Columbia Open Health Data (COHD) API
contact:
name: Casey Ta
Expand Down Expand Up @@ -669,10 +669,15 @@ paths:
example: "SNOMED"
/omop/xrefToOMOP:
get:
deprecated: true
tags:
- OMOP
summary: Cross-reference from an ontology to OMOP standard concepts using the Ontology Xref Service
description: >-
This endpoint has been deprecated. COHD is now using Translator SRI services to map from OMOP to Biolink model.
Also, the OxO API has been producing internal server errors in some circumstances for several months. This
endpoint is currently still available but may not function correctly.

Attempts to map a concept from an external ontology to an OMOP standard concept ID using the EMBL-EBI Ontology Xref Service (OxO): https://www.ebi.ac.uk/spot/oxo/index. This method attempts to use OxO to map from the original ontology to an intermediate ontology that is included in OMOP (ICD9CM, ICD10CM, SNOMEDCT, and MeSH), then uses the OMOP mappings to the standard concepts. Multiple mappings may be returned. Results are sorted by total_distance (OxO distance + OMOP distance) in ascending order.
parameters:
- name: curie
Expand Down Expand Up @@ -754,10 +759,15 @@ paths:
example: 2
/omop/xrefFromOMOP:
get:
deprecated: true
tags:
- OMOP
summary: Cross-reference from an ontology to OMOP standard concepts using the Ontology Xref Service
description: >-
This endpoint has been deprecated. COHD is now using Translator SRI services to map from OMOP to Biolink model.
Also, the OxO API has been producing internal server errors in some circumstances for several months. This
endpoint is currently still available but may not function correctly.

Attempts to map a concept from an external ontology to an OMOP standard concept ID using the EMBL-EBI Ontology Xref Service (OxO): https://www.ebi.ac.uk/spot/oxo/index. This method maps from the OMOP standard concept to an intermediate vocabulary included is OxO (ICD9CM, ICD10CM, SNOMEDCT, and MeSH), then uses the OxO API to map to other ontologies. Multiple mappings may be returned. Results are sorted by total_distance (OxO distance + OMOP distance) in ascending order.
parameters:
- name: concept_id
Expand Down
156 changes: 78 additions & 78 deletions cohd/test_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,84 +272,84 @@ def test_omop_vocab_to_oxo_prefix():
omop_xref.omop_vocab_to_oxo_prefix('MeSH') == 'MeSH'


def test_oxo_search():
""" Tests omop_xref.oxo_search
Uses oxo_search to make multiple requests to OxO and checks that the results have the expected formats, expected
number of search results (i.e., one search result for each CURIE queried), and checks how the number of mappings
compare across different calls with different parameter settings (i.e., more mappings when larger distances are
used).

Returns
-------
No return value. Asserts will be triggered upon failure.
"""
oxo_response_keys = ['_links', '_embedded', 'page']

# Check oxo_search with a known CURIE that should produce matches
json = omop_xref.oxo_search(['DOID:8398'], distance=2)
# Check the general response format
assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# Searched for 1 CURIE, expect searchResults with length 1
assert len(json['_embedded']['searchResults']) == 1
# Check that the query produced a response, but don't verify the mappings themselves
assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= 0
# Keep track of the number of results for comparison against following queries
comparison_length = len(json['_embedded']['searchResults'][0]['mappingResponseList'])

# Sleep for 2 seconds so we don't overload OxO
sleep(2)

# Check oxo_search with a known CURIE with a shorter distance and check that there are fewer results
json = omop_xref.oxo_search(['DOID:8398'], distance=1)
# Check the general response format
assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# Searched for 1 CURIE, expect searchResults with length 1
assert len(json['_embedded']['searchResults']) == 1
# Check that the query produced a response, but don't verify the mappings themselves
assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= 0
# Keep track of the number of results for comparison against following queries
assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) <= comparison_length

# Sleep for 2 seconds so we don't overload OxO
sleep(2)

# Check oxo_search with a known CURIE with a longer distance and check that there are fewer results
json = omop_xref.oxo_search(['DOID:8398'], distance=3)
# Check the general response format
assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# Searched for 1 CURIE, expect searchResults with length 1
assert len(json['_embedded']['searchResults']) == 1
# Check that the query produced a response, but don't verify the mappings themselves
assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= 0
# Keep track of the number of results for comparison against following queries
assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= comparison_length

# Sleep for 2 seconds so we don't overload OxO
sleep(2)

# Check oxo_search with a known CURIE with a restricted mapping targets and check that there are fewer results
json = omop_xref.oxo_search(['DOID:8398'], mapping_targets=['ICD10CM'], distance=2)
# Check the general response format
assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# Searched for 1 CURIE, expect searchResults with length 1
assert len(json['_embedded']['searchResults']) == 1
# Check that the query produced a response, but don't verify the mappings themselves
assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= 0
# Keep track of the number of results for comparison against following queries
assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) <= comparison_length

# Sleep for 2 seconds so we don't overload OxO
sleep(2)

# Check oxo_search with one valid CURIE and one fake CURIE
json = omop_xref.oxo_search(['DOID:8398', 'DOID:83980000'], distance=1)
# Check the general response format
assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# Searched for 2 CURIEs, expect searchResults with length 2
assert len(json['_embedded']['searchResults']) == 2
# Check that the first query produced mappings and the second query produced no mappings
assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) > 0 and \
len(json['_embedded']['searchResults'][1]['mappingResponseList']) == 0
# def test_oxo_search():
# """ Tests omop_xref.oxo_search
# Uses oxo_search to make multiple requests to OxO and checks that the results have the expected formats, expected
# number of search results (i.e., one search result for each CURIE queried), and checks how the number of mappings
# compare across different calls with different parameter settings (i.e., more mappings when larger distances are
# used).
#
# Returns
# -------
# No return value. Asserts will be triggered upon failure.
# """
# oxo_response_keys = ['_links', '_embedded', 'page']
#
# # Check oxo_search with a known CURIE that should produce matches
# json = omop_xref.oxo_search(['DOID:8398'], distance=2)
# # Check the general response format
# assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# # Searched for 1 CURIE, expect searchResults with length 1
# assert len(json['_embedded']['searchResults']) == 1
# # Check that the query produced a response, but don't verify the mappings themselves
# assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= 0
# # Keep track of the number of results for comparison against following queries
# comparison_length = len(json['_embedded']['searchResults'][0]['mappingResponseList'])
#
# # Sleep for 2 seconds so we don't overload OxO
# sleep(2)
#
# # Check oxo_search with a known CURIE with a shorter distance and check that there are fewer results
# json = omop_xref.oxo_search(['DOID:8398'], distance=1)
# # Check the general response format
# assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# # Searched for 1 CURIE, expect searchResults with length 1
# assert len(json['_embedded']['searchResults']) == 1
# # Check that the query produced a response, but don't verify the mappings themselves
# assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= 0
# # Keep track of the number of results for comparison against following queries
# assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) <= comparison_length
#
# # Sleep for 2 seconds so we don't overload OxO
# sleep(2)
#
# # Check oxo_search with a known CURIE with a longer distance and check that there are fewer results
# json = omop_xref.oxo_search(['DOID:8398'], distance=3)
# # Check the general response format
# assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# # Searched for 1 CURIE, expect searchResults with length 1
# assert len(json['_embedded']['searchResults']) == 1
# # Check that the query produced a response, but don't verify the mappings themselves
# assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= 0
# # Keep track of the number of results for comparison against following queries
# assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= comparison_length
#
# # Sleep for 2 seconds so we don't overload OxO
# sleep(2)
#
# # Check oxo_search with a known CURIE with a restricted mapping targets and check that there are fewer results
# json = omop_xref.oxo_search(['DOID:8398'], mapping_targets=['ICD10CM'], distance=2)
# # Check the general response format
# assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# # Searched for 1 CURIE, expect searchResults with length 1
# assert len(json['_embedded']['searchResults']) == 1
# # Check that the query produced a response, but don't verify the mappings themselves
# assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) >= 0
# # Keep track of the number of results for comparison against following queries
# assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) <= comparison_length
#
# # Sleep for 2 seconds so we don't overload OxO
# sleep(2)
#
# # Check oxo_search with one valid CURIE and one fake CURIE
# json = omop_xref.oxo_search(['DOID:8398', 'DOID:83980000'], distance=1)
# # Check the general response format
# assert json is not None and isinstance(json, dict) and all(k in json for k in oxo_response_keys)
# # Searched for 2 CURIEs, expect searchResults with length 2
# assert len(json['_embedded']['searchResults']) == 2
# # Check that the first query produced mappings and the second query produced no mappings
# assert len(json['_embedded']['searchResults'][0]['mappingResponseList']) > 0 and \
# len(json['_embedded']['searchResults'][1]['mappingResponseList']) == 0


def test_xref_best_from():
Expand Down
Loading