Skip to content

Commit

Permalink
Remove assay type references and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanzhou committed Nov 7, 2024
1 parent f8fb074 commit bc65fb6
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 140 deletions.
18 changes: 0 additions & 18 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3338,13 +3338,6 @@ def get_prov_info():
if user_in_hubmap_read_group(request):
published_only = False

# Parsing the organ types yaml has to be done here rather than calling schema.schema_triggers.get_organ_description
# because that would require using a urllib request for each dataset

# As above, we parse te assay type yaml here rather than calling the special method for it because this avoids
# having to access the resource for every dataset.
assay_types_dict = schema_manager.get_assay_types()

# Processing and validating query parameters
accepted_arguments = ['format', 'organ', 'has_rui_info', 'dataset_status', 'group_uuid']
return_json = False
Expand Down Expand Up @@ -3705,13 +3698,6 @@ def get_prov_info_for_dataset(id):
HEADER_PROCESSED_DATASET_STATUS, HEADER_PROCESSED_DATASET_PORTAL_URL, HEADER_DATASET_SAMPLES
]

# Parsing the organ types yaml has to be done here rather than calling schema.schema_triggers.get_organ_description
# because that would require using a urllib request for each dataset

# As above, we parse te assay type yaml here rather than calling the special method for it because this avoids
# having to access the resource for every dataset.
assay_types_dict = schema_manager.get_assay_types()

hubmap_ids = schema_manager.get_hubmap_ids(id)

# Get the target uuid if all good
Expand Down Expand Up @@ -3942,10 +3928,6 @@ def sankey_data():
# because that would require using a urllib request for each dataset
organ_types_dict = schema_manager.get_organ_types()

# As above, we parse te assay type yaml here rather than calling the special method for it because this avoids
# having to access the resource for every dataset.
assay_types_dict = schema_manager.get_assay_types()

# Instantiation of the list dataset_sankey_list
dataset_sankey_list = []

Expand Down
1 change: 0 additions & 1 deletion src/schema/schema_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ 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'

DOI_BASE_URL = 'https://doi.org/'
Expand Down
63 changes: 0 additions & 63 deletions src/schema/schema_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2248,69 +2248,6 @@ def get_organ_types():
return _organ_types


"""
Retrive the assay types from ontology-api
Returns
-------
dict
The available assay types by name in the following format:
{
"10x-multiome": {
"contains_pii": true,
"description": "10x Multiome",
"name": "10x-multiome",
"primary": true,
"vis_only": false,
"vitessce_hints": []
},
"AF": {
"contains_pii": false,
"description": "Autofluorescence Microscopy",
"name": "AF",
"primary": true,
"vis_only": false,
"vitessce_hints": []
},
...
}
"""
def get_assay_types():
global _ontology_api_url

target_url = _ontology_api_url + SchemaConstants.ONTOLOGY_API_ASSAY_TYPES_ENDPOINT

# Use Memcached to improve performance
response = make_request_get(target_url, internal_token_used = True)

# Invoke .raise_for_status(), an HTTPError will be raised with certain status codes
response.raise_for_status()

if response.status_code == 200:
assay_types_by_name = {}
result_dict = response.json()

# Due to the json envelop being used int the json result
assay_types_list = result_dict['result']
for assay_type_dict in assay_types_list:
assay_types_by_name[assay_type_dict['name']] = assay_type_dict

return assay_types_by_name
else:
# Log the full stack trace, prepend a line with our message
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)

logger.debug("======get_assay_types() response text from ontology-api======")
logger.debug(response.text)

# Also bubble up the error message from ontology-api
raise requests.exceptions.RequestException(response.text)


####################################################################################################
## Internal functions
####################################################################################################
Expand Down
58 changes: 0 additions & 58 deletions src/schema/schema_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2204,61 +2204,3 @@ def _delete_files(target_property_key, property_key, normalized_type, user_token

return generated_dict


"""
Get the assay type description based on the given assay type
Parameters
----------
assay_type : str
The assay type name
Returns
-------
str: The corresponding assay type description
"""
def _get_assay_type_description(assay_type):
assay_types_dict = schema_manager.get_assay_types()

if assay_type in assay_types_dict:
return assay_types_dict[assay_type]['description'].lower()


"""
Compose the assay type description based on the given assay types
Parameters
----------
data_types : list
A list of dataset data types
Returns
-------
str: The combined and formatted assay type description
"""
def _get_combined_assay_type_description(data_types):
assay_types = []
assay_type_desc = ''

for data_type in data_types:
assay_types.append(_get_assay_type_description(data_type))

# Formatting based on the number of items in the list
if assay_types:
if len(assay_types) == 1:
assay_type_desc = assay_types[0]
elif len(assay_types) == 2:
# <assay_type1> and <assay_type2>
assay_type_desc = ' and '.join(assay_types)
else:
# <assay_type1>, <assay_type2>, and <assay_type3>
assay_type_desc = f"{', '.join(assay_types[:-1])}, and {assay_types[-1]}"
else:
msg = "Empty list of assay_types"

logger.error(msg)

raise ValueError(msg)

return assay_type_desc

0 comments on commit bc65fb6

Please sign in to comment.