Skip to content

Commit

Permalink
Remove parsing on alt-names
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanzhou committed Nov 28, 2023
1 parent 5cd9a07 commit d63b25a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 36 deletions.
45 changes: 15 additions & 30 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2794,17 +2794,12 @@ def get_prov_info():
for item in dataset['data_types']:
try:
assay_description_list.append(assay_types_dict[item]['description'])
# Some data types aren't given by their code in the assay types yaml and are instead given as an alt name.
# In these cases, we have to search each assay type and see if the given code matches any alternate names.
except KeyError:
valid_key = False
for each in assay_types_dict:
if valid_key is False:
if item in assay_types_dict[each]['alt-names']:
assay_description_list.append(assay_types_dict[each]['description'])
valid_key = True
if valid_key is False:
assay_description_list.append(item)
logger.exception(f"Data type {item} not found in resulting assay types via ontology-api")

# Just use the data type value
assay_description_list.append(item)

dataset['data_types'] = assay_description_list
internal_dict[HEADER_DATASET_DATA_TYPES] = dataset['data_types']

Expand Down Expand Up @@ -3116,17 +3111,12 @@ def get_prov_info_for_dataset(id):
for item in dataset['data_types']:
try:
assay_description_list.append(assay_types_dict[item]['description'])
# Some data types aren't given by their code in the assay types yaml and are instead given as an alt name.
# In these cases, we have to search each assay type and see if the given code matches any alternate names.
except KeyError:
valid_key = False
for each in assay_types_dict:
if valid_key is False:
if item in assay_types_dict[each]['alt-names']:
assay_description_list.append(assay_types_dict[each]['description'])
valid_key = True
if valid_key is False:
assay_description_list.append(item)
logger.exception(f"Data type {item} not found in resulting assay types via ontology-api")

# Just use the data type value
assay_description_list.append(item)

dataset['data_types'] = assay_description_list
internal_dict[HEADER_DATASET_DATA_TYPES] = dataset['data_types']
if return_json is False:
Expand Down Expand Up @@ -3342,17 +3332,12 @@ def sankey_data():
assay_description = ""
try:
assay_description = assay_types_dict[dataset[HEADER_DATASET_DATA_TYPES]]['description']
# Some data types aren't given by their code in the assay types yaml and are instead given as an alt name.
# In these cases, we have to search each assay type and see if the given code matches any alternate names.
except KeyError:
valid_key = False
for each in assay_types_dict:
if valid_key is False:
if dataset[HEADER_DATASET_DATA_TYPES] in assay_types_dict[each]['alt-names']:
assay_description = assay_types_dict[each]['description']
valid_key = True
if valid_key is False:
assay_description = dataset[HEADER_DATASET_DATA_TYPES]
logger.exception(f"Data type {dataset[HEADER_DATASET_DATA_TYPES]} not found in resulting assay types via ontology-api")

# Just use the data type value
assay_description = dataset[HEADER_DATASET_DATA_TYPES]

internal_dict[HEADER_DATASET_DATA_TYPES] = assay_description

# Replace applicable Group Name and Data type with the value needed for the sankey via the mapping_dict
Expand Down
4 changes: 2 additions & 2 deletions src/schema/schema_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class SchemaConstants(object):
UUID_API_ID_ENDPOINT = '/uuid'
INGEST_API_FILE_COMMIT_ENDPOINT = '/file-commit'
INGEST_API_FILE_REMOVE_ENDPOINT = '/file-remove'
ONTOLOGY_API_ASSAY_TYPES_ENDPOINT = '/assaytype?application_context=HuBMAP'
ONTOLOGY_API_ORGAN_TYPES_ENDPOINT = '/organs/by-code?application_context=HuBMAP'
ONTOLOGY_API_ASSAY_TYPES_ENDPOINT = '/assaytype?application_context=HUBMAP'
ONTOLOGY_API_ORGAN_TYPES_ENDPOINT = '/organs/by-code?application_context=HUBMAP'

DOI_BASE_URL = 'https://doi.org/'

Expand Down
6 changes: 2 additions & 4 deletions src/schema/schema_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1804,9 +1804,8 @@ def get_organ_types():
if response.status_code == 200:
return response.json()
else:
msg = "Unable to make a request to query the organ types via ontology-api: {id}"
# Log the full stack trace, prepend a line with our message
logger.exception(msg)
logger.exception("Unable to make a request to query the organ types via ontology-api")

logger.debug("======get_organ_types() status code from ontology-api======")
logger.debug(response.status_code)
Expand Down Expand Up @@ -1868,9 +1867,8 @@ def get_assay_types():

return assay_types_by_name
else:
msg = "Unable to make a request to query the assay types via ontology-api"
# Log the full stack trace, prepend a line with our message
logger.exception(msg)
logger.exception("Unable to make a request to query the assay types via ontology-api")

logger.debug("======get_assay_types() status code from ontology-api======")
logger.debug(response.status_code)
Expand Down

0 comments on commit d63b25a

Please sign in to comment.