diff --git a/hs-ontology-api-spec.yaml b/hs-ontology-api-spec.yaml index 7ad54e0..deb5b46 100644 --- a/hs-ontology-api-spec.yaml +++ b/hs-ontology-api-spec.yaml @@ -201,102 +201,6 @@ paths: description: No dataset types matching parameters '5XX': description: Unknown error - /assayname: # CPK MAR 2023 - replacement for search-api endpoint of the same name - post: - operationId: assayname_post - summary: Replacement for assayname endpoint in the search-api - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/AssayNameRequest" - responses: - '200': - description: A JSON array of the assaytype with the specified name. - content: - application/json: - schema: - $ref: '#/components/schemas/AssayTypePropertyInfo' - '400': - description: Invalid request - missing request body; missing key *name* in request body; value for key *name* incorrectly specified - '404': - description: No assay type found corresponding to the value of the *name* key in the request body - '5XX': - description: Unknown error - /assaytype: - get: - operationId: assaytype_get - summary: Replacement for endpoint in search-api. The primary parameter filters by assay type (primary, not primary); if no value provided, all assay types are returned. - parameters: - - name: primary - in: query - required: false - description: Determines if records are all, primary, or not primary. - schema: - type: string - example: true - - name: application_context - in: query - required: false - description: Filter to indicate application context - schema: - type: string - default: HUBMAP - enum: - - HUBMAP - - SENNET - - hubmap - - sennet - - HuBMAP - - SenNet - responses: - '200': - description: A JSON array of the assay type name - content: - application/json: - schema: - $ref: '#/components/schemas/AssayTypePropertyInfo' - /assaytype/{name}: # CPK MAR 2023 - replacement for search-src endpoint of the same name - get: - operationId: assaytype_name_get - summary: Replacement for the same endpoint in search-api with the addition of application_context - parameters: - - name: name - in: path - required: true - description: AssayType name - schema: - type: string - example: bulk-RNA - - name: application_context - in: query - required: false - description: Filter to indicate application context - schema: - type: string - default: HUBMAP - enum: - - HUBMAP - - SENNET - - hubmap - - sennet - - HuBMAP - - SenNet - responses: - '200': - description: A JSON array of the assay type name - content: - application/json: - schema: - $ref: '#/components/schemas/AssayTypePropertyInfo' - example: - name: bulk-RNA - primary: true - description: Bulk RNA-seq - vitessce-hints: ["pyramid","anndata"] - contains-pii: true - vis-only: true /organs: get: operationId: get_organ_types @@ -1028,36 +932,6 @@ paths: description: Unexpected error components: schemas: - AssayTypePropertyInfo: - type: object - description: Properties of a HuBMAP/SenNet assaytype - properties: - name: - type: string - description: assaytype hierarchy - example: bulk-RNA - primary: - type: boolean - description: Indicates whether the assay is primary (true) or derived (false) - example: true - description: - type: string - description: How datasets of the data type are named in the Data Portal. - example: Bulk RNA-seq - vitessce-hints: - type: array - description: Flags for Vitessce visualization - items: - type: string - example: ["pyramid","anndata"] - contains-pii: - type: string - description: DEPRECATED - example: deprecated - vis-only: - type: string - description: DEPRECATED - example: deprecated RuiCodeTerm: type: object description: Respoonse body for organs/by-code GET request @@ -1146,28 +1020,6 @@ components: term: type: string example: Microscopy - AssayNameRequest: # Schema name CPK MR 2023. - type: object - description: Request body for assaytype POST request - properties: - name: - anyOf: - - type: string - - type: array - items: - type: string - description: AssayType name which can be a string or an array of strings. This is an array for downward compatibility. - example: [AF] - application_context: - type: string - default: HUBMAP - enum: - - HUBMAP - - SENNET - - hubmap - - sennet - - HuBMAP - - SenNet GeneListResponse: type: object description: High-level information on a set of genes requested by the genes endpoint. diff --git a/src/hs_ontology_api/models/assay_type_property_info.py b/src/hs_ontology_api/models/assay_type_property_info.py deleted file mode 100644 index edeb049..0000000 --- a/src/hs_ontology_api/models/assay_type_property_info.py +++ /dev/null @@ -1,212 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import - -from typing import List - -from ubkg_api.models import util -from ubkg_api.models.base_model_ import Model - - -class AssayTypePropertyInfo(Model): - def __init__(self, name=None, primary=None, description=None, vitessce_hints=None, contains_pii=None, vis_only=None): - """AssayTypePropertyInfo - a model defined in OpenAPI - - :param name: The name of this AssayTypePropertyInfo. - :type name: str - :param primary: The primary of this AssayTypePropertyInfo. - :type primary: bool - :param description: The description of this AssayTypePropertyInfo. - :type description: str - :param vitessce_hints: The vitessce_hints of this AssayTypePropertyInfo. - :type vitessce_hints: List[str] - :param contains_pii: The contains_pii of this AssayTypePropertyInfo. - :type contains_pii: bool - :param vis_only: The vis_only of this AssayTypePropertyInfo. - :type vis_only: List[bool] - """ - self.openapi_types = { - 'name': str, - 'primary': bool, - 'description': str, - 'vitessce_hints': List[str], - 'contains_pii': bool, - 'vis_only': List[bool] - } - - self.attribute_map = { - 'name': 'name', - 'primary': 'primary', - 'description': 'description', - 'vitessce_hints': 'vitessce-hints', - 'contains_pii': 'contains-pii', - 'vis_only': 'vis-only' - } - - self._name = name - self._primary = primary - self._description = description - self._vitessce_hints = vitessce_hints - self._contains_pii = contains_pii - self._vis_only = vis_only - - def serialize(self): - - # JAS 11 DEC 2023 Replace underscores with dashes in return. - return { - "name": self._name, - "primary": self._primary, - "description": self._description, - "vitessce-hints": self._vitessce_hints, - "contains-pii": self._contains_pii, - "vis-only": self._vis_only - } - - @classmethod - def from_dict(cls, dikt) -> 'AssayTypePropertyInfo': - """Returns the dict as a model - - :param dikt: A dict. - :type: dict - :return: The AssayTypePropertyInfo of this AssayTypePropertyInfo. - :rtype: AssayTypePropertyInfo - """ - return util.deserialize_model(dikt, cls) - - @property - def name(self): - """Gets the name of this AssayTypePropertyInfo. - - AssayType name; used to characterize dataset entities in provenance hierarchy - - :return: The name of this AssayTypePropertyInfo. - :rtype: str - """ - return self._name - - @name.setter - def name(self, name): - """Sets the name of this AssayTypePropertyInfo. - - AssayType name; used to characterize dataset entities in provenance hierarchy - - :param name: The name of this AssayTypePropertyInfo. - :type name: str - """ - - self._name = name - - @property - def primary(self): - """Gets the primary of this AssayTypePropertyInfo. - - Indicates whether the assay is primary (true) or derived (false) - - :return: The primary of this AssayTypePropertyInfo. - :rtype: bool - """ - return self._primary - - @primary.setter - def primary(self, primary): - """Sets the primary of this AssayTypePropertyInfo. - - Indicates whether the assay is primary (true) or derived (false) - - :param primary: The primary of this AssayTypePropertyInfo. - :type primary: bool - """ - - self._primary = primary - - @property - def description(self): - """Gets the description of this AssayTypePropertyInfo. - - How datasets of the data type are named in the Data Portal. - - :return: The description of this AssayTypePropertyInfo. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """Sets the description of this AssayTypePropertyInfo. - - How datasets of the data type are named in the Data Portal. - - :param description: The description of this AssayTypePropertyInfo. - :type description: str - """ - - self._description = description - - @property - def vitessce_hints(self): - """Gets the vitessce_hints of this AssayTypePropertyInfo. - - Flags for Vitessce visualization - - :return: The vitessce_hints of this AssayTypePropertyInfo. - :rtype: List[str] - """ - return self._vitessce_hints - - @vitessce_hints.setter - def vitessce_hints(self, vitessce_hints): - """Sets the vitessce_hints of this AssayTypePropertyInfo. - - Flags for Vitessce visualization - - :param vitessce_hints: The vitessce_hints of this AssayTypePropertyInfo. - :type vitessce_hints: List[str] - """ - - self._vitessce_hints = vitessce_hints - - @property - def contains_pii(self): - """Gets the contains_pii of this AssayTypePropertyInfo. - - Whether the dataset contains Patient Identifying Information (PII) (true or false) - - :return: The contains_pii of this AssayTypePropertyInfo. - :rtype: bool - """ - return self._contains_pii - - @contains_pii.setter - def contains_pii(self, contains_pii): - """Sets the contains_pii of this AssayTypePropertyInfo. - - Whether the dataset contains Patient Identifying Information (PII) (true or false) - - :param contains_pii: The contains_pii of this AssayTypePropertyInfo. - :type contains_pii: bool - """ - - self._contains_pii = contains_pii - - @property - def vis_only(self): - """Gets the vis_only of this AssayTypePropertyInfo. - - Indicates whether for visualization only (true or false) - - :return: The vis_only of this AssayTypePropertyInfo. - :rtype: List[bool] - """ - return self._vis_only - - @vis_only.setter - def vis_only(self, vis_only): - """Sets the vis_only of this AssayTypePropertyInfo. - - Indicates whether for visualization only (true or false) - - :param vis_only: The vis_only of this AssayTypePropertyInfo. - :type vis_only: List[bool] - """ - - self._vis_only = vis_only diff --git a/src/hs_ontology_api/models/dataset_property_info.py b/src/hs_ontology_api/models/dataset_property_info.py deleted file mode 100644 index 814c57d..0000000 --- a/src/hs_ontology_api/models/dataset_property_info.py +++ /dev/null @@ -1,265 +0,0 @@ -from __future__ import absolute_import - -from typing import List - -from ubkg_api.models.base_model_ import Model - - -class DatasetPropertyInfo(Model): - def __init__(self, alt_names=None, contains_pii=None, data_type=None, dataset_provider=None, description=None, primary=None, vis_only=None, vitessce_hints=None): - """DatasetPropertyInfo - a model defined in OpenAPI - - :param alt_names: The alt_names of this DatasetPropertyInfo. - :type alt_names: List[str] - :param contains_pii: The contains_pii of this DatasetPropertyInfo. - :type contains_pii: str - :param data_type: The data_type of this DatasetPropertyInfo. - :type data_type: str - :param dataset_provider: The dataset_provider of this DatasetPropertyInfo. - :type dataset_provider: str - :param description: The description of this DatasetPropertyInfo. - :type description: str - :param primary: The primary of this DatasetPropertyInfo. - :type primary: str - :param vis_only: The vis_only of this DatasetPropertyInfo. - :type vis_only: List[str] - :param vitessce_hints: The vitessce_hints of this DatasetPropertyInfo. - :type vitessce_hints: List[str] - """ - self.openapi_types = { - 'alt_names': List[str], - 'contains_pii': str, - 'data_type': str, - 'dataset_provider': str, - 'description': str, - 'primary': str, - 'vis_only': List[str], - 'vitessce_hints': List[str] - } - - self.attribute_map = { - 'alt_names': 'alt-names', - 'contains_pii': 'contains-pii', - 'data_type': 'data_type', - 'dataset_provider': 'dataset_provider', - 'description': 'description', - 'primary': 'primary', - 'vis_only': 'vis-only', - 'vitessce_hints': 'vitessce-hints' - } - - self._alt_names = alt_names - self._contains_pii = contains_pii - self._data_type = data_type - self._dataset_provider = dataset_provider - self._description = description - self._primary = primary - self._vis_only = vis_only - self._vitessce_hints = vitessce_hints - - def serialize(self): - return { - "alt-names": self._alt_names, - "contains-pii": self._contains_pii, - "data_type": self._data_type, - "dataset_provider": self._dataset_provider, - "description": self._description, - "primary": self._primary, - "vis-only": self._vis_only, - "vitessce-hints": self._vitessce_hints - } - - @classmethod - def from_dict(cls, dikt) -> 'DatasetPropertyInfo': - """Returns the dict as a model - - :param dikt: A dict. - :type: dict - :return: The DatasetPropertyInfo of this DatasetPropertyInfo. - :rtype: DatasetPropertyInfo - """ - return util.deserialize_model(dikt, cls) - - @property - def alt_names(self): - """Gets the alt_names of this DatasetPropertyInfo. - - Alternative/deprecated synonyms of data_type that may still be associated with dataset entities - - :return: The alt_names of this DatasetPropertyInfo. - :rtype: List[str] - """ - return self._alt_names - - @alt_names.setter - def alt_names(self, alt_names): - """Sets the alt_names of this DatasetPropertyInfo. - - Alternative/deprecated synonyms of data_type that may still be associated with dataset entities - - :param alt_names: The alt_names of this DatasetPropertyInfo. - :type alt_names: List[str] - """ - - self._alt_names = alt_names - - @property - def contains_pii(self): - """Gets the contains_pii of this DatasetPropertyInfo. - - Whether the dataset contains Patient Identifying Information (PII) - - :return: The contains_pii of this DatasetPropertyInfo. - :rtype: str - """ - return self._contains_pii - - @contains_pii.setter - def contains_pii(self, contains_pii): - """Sets the contains_pii of this DatasetPropertyInfo. - - Whether the dataset contains Patient Identifying Information (PII) - - :param contains_pii: The contains_pii of this DatasetPropertyInfo. - :type contains_pii: str - """ - - self._contains_pii = contains_pii - - @property - def data_type(self): - """Gets the data_type of this DatasetPropertyInfo. - - Data type for the dataset; used to characterize dataset entities in provenance hierarchy - - :return: The data_type of this DatasetPropertyInfo. - :rtype: str - """ - return self._data_type - - @data_type.setter - def data_type(self, data_type): - """Sets the data_type of this DatasetPropertyInfo. - - Data type for the dataset; used to characterize dataset entities in provenance hierarchy - - :param data_type: The data_type of this DatasetPropertyInfo. - :type data_type: str - """ - - self._data_type = data_type - - @property - def dataset_provider(self): - """Gets the dataset_provider of this DatasetPropertyInfo. - - Identifies the provider of the dataset. 'External Provider' also referred to as 'lab-processed'. - - :return: The dataset_provider of this DatasetPropertyInfo. - :rtype: str - """ - return self._dataset_provider - - @dataset_provider.setter - def dataset_provider(self, dataset_provider): - """Sets the dataset_provider of this DatasetPropertyInfo. - - Identifies the provider of the dataset. 'External Provider' also referred to as 'lab-processed'. - - :param dataset_provider: The dataset_provider of this DatasetPropertyInfo. - :type dataset_provider: str - """ - - self._dataset_provider = dataset_provider - - @property - def description(self): - """Gets the description of this DatasetPropertyInfo. - - How datasets of the data type are named in the Data Portal. - - :return: The description of this DatasetPropertyInfo. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """Sets the description of this DatasetPropertyInfo. - - How datasets of the data type are named in the Data Portal. - - :param description: The description of this DatasetPropertyInfo. - :type description: str - """ - - self._description = description - - @property - def primary(self): - """Gets the primary of this DatasetPropertyInfo. - - Indicates whether the assay is primary (true) or derived (false) - - :return: The primary of this DatasetPropertyInfo. - :rtype: str - """ - return self._primary - - @primary.setter - def primary(self, primary): - """Sets the primary of this DatasetPropertyInfo. - - Indicates whether the assay is primary (true) or derived (false) - - :param primary: The primary of this DatasetPropertyInfo. - :type primary: str - """ - - self._primary = primary - - @property - def vis_only(self): - """Gets the vis_only of this DatasetPropertyInfo. - - Indicates whether for visualization only - - :return: The vis_only of this DatasetPropertyInfo. - :rtype: List[str] - """ - return self._vis_only - - @vis_only.setter - def vis_only(self, vis_only): - """Sets the vis_only of this DatasetPropertyInfo. - - Indicates whether for visualization only - - :param vis_only: The vis_only of this DatasetPropertyInfo. - :type vis_only: List[str] - """ - - self._vis_only = vis_only - - @property - def vitessce_hints(self): - """Gets the vitessce_hints of this DatasetPropertyInfo. - - Flags for Vitessce visualization - - :return: The vitessce_hints of this DatasetPropertyInfo. - :rtype: List[str] - """ - return self._vitessce_hints - - @vitessce_hints.setter - def vitessce_hints(self, vitessce_hints): - """Sets the vitessce_hints of this DatasetPropertyInfo. - - Flags for Vitessce visualization - - :param vitessce_hints: The vitessce_hints of this DatasetPropertyInfo. - :type vitessce_hints: List[str] - """ - - self._vitessce_hints = vitessce_hints diff --git a/src/hs_ontology_api/routes/assayname/__init__.py b/src/hs_ontology_api/routes/assayname/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/hs_ontology_api/routes/assayname/assayname_controller.py b/src/hs_ontology_api/routes/assayname/assayname_controller.py deleted file mode 100644 index ee34298..0000000 --- a/src/hs_ontology_api/routes/assayname/assayname_controller.py +++ /dev/null @@ -1,90 +0,0 @@ -# The assayname route replaces the equivalent legacy routes in the search-api. -# July 2024 - refactored to work with new UBKG assay class model. - -from flask import Blueprint, jsonify, current_app, request, make_response -from ubkg_api.utils.http_error_string import (get_404_error_string, validate_query_parameter_names, - validate_parameter_value_in_enum,validate_required_parameters) -from hs_ontology_api.utils.neo4j_logic import assayclasses_get_logic -from hs_ontology_api.utils.listdict import remove_duplicate_dicts_from_list - -assayname_blueprint = Blueprint('assayname', __name__, url_prefix='/assayname') - - -@assayname_blueprint.route('', methods=['POST']) -def assayname_post(): - """Get the assaytypes with name and alt-names as found in the request body with key 'name'. - This is a replacement for search-src endpoint of the same name. - - The 'application_context' is specified in the Request Data (see AssayNameRequest in ubkg-api-spec.yaml). - If it is not specified it will default to 'HUBMAP'. - - The 'name' is also specified in the Request Data (again see AssayNameRequest in ubkg-api-spec.yaml). - - """ - - if not request.is_json: - return make_response("A JSON request body with a 'Content-Type: application/json' header are required", 400) - - if 'name' not in request.json: - return make_response('Request body contains no "name" field', 400) - - application_context = "HUBMAP" - - if 'application_context' in request.json: - application_context = request.json['application_context'] - - # Check for valid application context. - val_enum = ['HUBMAP', 'SENNET'] - err = validate_parameter_value_in_enum(param_name='application_context', param_value=application_context, - enum_list=val_enum) - if err != 'ok': - return make_response(err, 400) - - # req_name = request.json['name'] - # The following is legacy code that attempted to handle composite and "alt-names", which have been deprecated. - # alt_names: list = None - # if type(req_name) == list and len(req_name) > 0: - # name = req_name[0] - # if len(req_name) > 1: - # alt_names = req_name[1:] - # elif type(req_name) == str: - # name = req_name - # else: - # return make_response("The 'name' field is incorrectly specified " - # "(see AssayNameRequest in ubkg-api-spec.yaml)", 400) - - # Assume that only a single assay name is provided. - name = request.json['name'][0] - neo4j_instance = current_app.neo4jConnectionHelper.instance() - - result = assayclasses_get_logic( - neo4j_instance, assaytype=name, context=application_context) - - if (result is None or result == []): - # Empty result - err = get_404_error_string(prompt_string=f"No results for " - f"specified parameters") - return make_response(err, 404) - - # Build the legacy response from the new response. - listresponse = [] - for r in result: - assaytype = {} - val = r.get('value') - assaytype['name'] = val.get('assaytype') - # July 2024 - Process states have changed from a simple binary for primary/derived to a categorical - # value of 'primary', 'derived', or 'epic'. The legacy model will observe the binary model. - assaytype['primary'] = val.get('process_state')=='primary' - assaytype['description'] = val.get('description') - assaytype['vitessce-hints'] = val.get('vitessce_hints') - # The vis-only and contains-pii properties have been deprecated. - assaytype['vis-only'] = 'deprecated' - assaytype['contains-pii'] = 'deprecated' - listresponse.append(assaytype) - - # Remove duplicates. There will likely be both "non-DCWG" and "DCWG" rules for the same assaytype, for which the - # subset used for assaytype response will contain duplicates. - listunique = remove_duplicate_dicts_from_list(listinput=listresponse, indexval='name') - - return jsonify(listunique[0]) - diff --git a/src/hs_ontology_api/routes/assaytype/__init__.py b/src/hs_ontology_api/routes/assaytype/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/hs_ontology_api/routes/assaytype/assaytype_controller.py b/src/hs_ontology_api/routes/assaytype/assaytype_controller.py deleted file mode 100644 index 33d472a..0000000 --- a/src/hs_ontology_api/routes/assaytype/assaytype_controller.py +++ /dev/null @@ -1,102 +0,0 @@ -# The assaytype routes replace the equivalent legacy routes in the search-api. -# July 2024 - refactored to work with new UBKG assay class model. - -from flask import Blueprint, jsonify, current_app, request, make_response - -from ubkg_api.utils.http_error_string import (get_404_error_string, validate_query_parameter_names, - validate_parameter_value_in_enum,validate_required_parameters) - -#from hs_ontology_api.utils.neo4j_logic import assaytype_get_logic, assaytype_name_get_logic -from hs_ontology_api.utils.neo4j_logic import assayclasses_get_logic -from hs_ontology_api.utils.listdict import remove_duplicate_dicts_from_list - -assaytype_blueprint = Blueprint('assaytype', __name__, url_prefix='/assaytype') - - -@assaytype_blueprint.route('', methods=['GET']) -def route_assaytype_get(): - return assaytype_get() - -@assaytype_blueprint.route('/', methods=['GET']) -def route_assaytype_name_get(name): - return assaytype_get(name) - -def assaytype_get(name=None): - """ - Returns information for the legacy assaytype and assaytype/{name} endpoints. - :param name: corresponds to the assaytype - """ - - # Validate parameters. - - # Check for invalid parameter names. - err = validate_query_parameter_names(parameter_name_list=['application_context', 'primary']) - if err != 'ok': - return make_response(err, 400) - - # Check for required parameters. - application_context = request.args.get('application_context') - # For assaytype, the default is HUBMAP. - if application_context is None: - application_context = 'HUBMAP' - - # Check for valid application context. - val_enum = ['HUBMAP', 'SENNET'] - err = validate_parameter_value_in_enum(param_name='application_context', param_value=application_context, - enum_list=val_enum) - if err != 'ok': - return make_response(err, 400) - - # Check for valid parameter values. - # Map the legacy is_primary parameter to new process_state parameter. - is_primary = request.args.get('primary') - if is_primary is not None: - is_primary = is_primary.lower() - val_enum = ['true', 'false'] - err = validate_parameter_value_in_enum(param_name='primary', param_value=is_primary, enum_list=val_enum) - if err != 'ok': - return make_response(err, 400) - if is_primary == 'true': - process_state = 'primary' - else: - process_state = 'derived' - else: - process_state = None - - neo4j_instance = current_app.neo4jConnectionHelper.instance() - result = assayclasses_get_logic( - neo4j_instance, assaytype=name, process_state=process_state, context=application_context) - - if (result is None or result == []): - # Empty result - err = get_404_error_string(prompt_string=f"No results for " - f"specified parameters") - return make_response(err, 404) - - # Build the legacy response from the new response. - listresponse=[] - for r in result: - assaytype = {} - val = r.get('value') - assaytype['name'] = val.get('assaytype') - # July 2024 - Process states have changed from a simple binary for primary/derived to a categorical - # value of 'primary', 'derived', or 'epic'. The legacy model will observe the binary model. - assaytype['primary'] = val.get('process_state') == 'primary' - #assaytype['primary'] = val.get('primary') - assaytype['description'] = val.get('description') - assaytype['vitessce-hints'] = val.get('vitessce_hints') - # The vis-only and contains-pii properties have been deprecated. - assaytype['vis-only'] = 'deprecated' - assaytype['contains-pii'] = 'deprecated' - listresponse.append(assaytype) - - # Remove duplicates. There will likely be both "non-DCWG" and "DCWG" rules for the same assaytype, for which the - # subset used for assaytype response will contain duplicates. - listunique = remove_duplicate_dicts_from_list(listinput=listresponse, indexval='name') - - # The assaytype endpoint returns a list of objects that is the value of a key named 'result'. - # The assaytype/{name} endpoint returns a single object. - if len(listunique) ==1: - return jsonify(listunique[0]) - else: - return jsonify({'result':listunique}) diff --git a/src/hs_ontology_api/routes/deprecated/__init__.py b/src/hs_ontology_api/routes/deprecated/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/hs_ontology_api/routes/deprecated/datasets/__init__.py b/src/hs_ontology_api/routes/deprecated/datasets/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/hs_ontology_api/routes/deprecated/datasets/datasets_controller.py b/src/hs_ontology_api/routes/deprecated/datasets/datasets_controller.py deleted file mode 100644 index 89dd201..0000000 --- a/src/hs_ontology_api/routes/deprecated/datasets/datasets_controller.py +++ /dev/null @@ -1,42 +0,0 @@ -from flask import Blueprint, jsonify, current_app, request - -from hs_ontology_api.utils.neo4j_logic import dataset_get_logic - -datasets_blueprint = Blueprint('datasets_hs', __name__, url_prefix='/datasets') - - -@datasets_blueprint.route('', methods=['GET']) -def dataset_get(): - """Returns information on a set of HuBMAP or SenNet dataset types, with options to filter the list to those with specific property values. Filters are additive (i.e., boolean AND) - - - :query application_context: Required filter to indicate application context. - :type application_context: str - :param data_type: Optional filter for data_type - :type data_type: str - :param description: Optional filter for display name. Use URL-encoding (space = %20). - :type description: str - :param alt_name: Optional filter for a single element in the alt-names list--i.e., return datasets for which alt-names includes a value that matches the parameter. Although the field is named 'alt-names', the parameter uses 'alt_name'. Use URL-encoding (space = %20) - :type alt_name: str - :param primary: Optional filter to filter to primary (true) or derived (false) assay. - :type primary: str - :param contains_pii: Optional filter for whether the dataset contains Patient Identifying Information (PII). Although the field is named 'contains-pii', use 'contains_pii' as an argument. - :type contains_pii: str - :param vis_only: Optional filter for whether datasets are visualization only (true). Although the field is named 'vis-only', use 'vis_only' as an argument. - :type vis_only: str - :param vitessce_hint: Optional filter for a single element in the vitessce_hint list--i.e., return datasets for which vitessce_hints includes a value that matches the parameter. Although the field is named 'vitessce-hints', use 'vitessce_hint' as an argument. - :type vitessce_hint: str - :param dataset_provider: Optional filter to identify the dataset provider - IEC (iec) or external (lab) - :type dataset_provider: str - - :rtype: Union[List[DatasetPropertyInfo], Tuple[List[DatasetPropertyInfo], int], Tuple[List[DatasetPropertyInfo], int, Dict[str, str]] - """ - application_context = validate_application_context() - neo4j_instance = current_app.neo4jConnectionHelper.instance() - return jsonify( - dataset_get_logic( - neo4j_instance, request.args.get('data_type'), request.args.get('description'), - request.args.get('alt_name'), request.args.get('primary'), request.args.get('contains_pii'), - request.args.get('vis_only'), request.args.get('vitessce_hint'), request.args.get('dataset_provider'), - application_context) - ) diff --git a/src/hs_ontology_api/utils/neo4j_logic.py b/src/hs_ontology_api/utils/neo4j_logic.py index d679baf..596600b 100644 --- a/src/hs_ontology_api/utils/neo4j_logic.py +++ b/src/hs_ontology_api/utils/neo4j_logic.py @@ -7,8 +7,7 @@ # from flask import current_app # Classes for JSON objects in response body -from hs_ontology_api.models.assay_type_property_info import AssayTypePropertyInfo -from hs_ontology_api.models.dataset_property_info import DatasetPropertyInfo + from hs_ontology_api.models.sab_code_term_rui_code import SabCodeTermRuiCode from hs_ontology_api.models.sab_code_term import SabCodeTerm # JAS Sept 2023 @@ -58,150 +57,6 @@ def loadquerystring(filename: str) -> str: f.close() return query - -def make_assaytype_property_info(record): - - # JAS 11 December 2023 Although the class AssayTypePropertyInfo uses underscores for - # properties such as contains_pii, the serialization converts the underscores to dashes. - - return AssayTypePropertyInfo( - record['data_type'], - record['primary'], - record['description'], - record['vitessce_hints'], - record['contains_pii'], - record['vis_only']) - - -def assaytype_get_logic(neo4j_instance, primary: bool, application_context: str = 'HUBMAP') \ - -> AssayTypePropertyInfo: - # Build the Cypher query that will return the table of data. - query = query_cypher_dataset_info(application_context) - - assaytypes: List[dict] = [] - # Execute Cypher query and return result. - with neo4j_instance.driver.session() as session: - recds: neo4j.Result = session.run(query) - for record in recds: - if primary is None: - assaytypes.append(make_assaytype_property_info(record).serialize()) - elif primary is True and record['primary'] is True: - assaytypes.append(make_assaytype_property_info(record).serialize()) - elif primary is False and record['primary'] is False: - assaytypes.append(make_assaytype_property_info(record).serialize()) - result: dict = {"result": assaytypes} - return result - - -def assaytype_name_get_logic(neo4j_instance, name: str, alt_names: list = None, application_context: str = 'HUBMAP') \ - -> AssayTypePropertyInfo: - """ - This is intended to be a drop in replacement for the same endpoint in search-src. - - The only difference is the optional application_contect to make it consistent with a HUBMAP or SENNET - environment. - """ - # Build the Cypher query that will return the table of data. - query = query_cypher_dataset_info(application_context) - - # Execute Cypher query and return result. - with neo4j_instance.driver.session() as session: - recds: neo4j.Result = session.run(query) - for record in recds: - if record.get('data_type') == name and (alt_names is None or record.get('alt_names') == alt_names): - # Accessing the record by .get('str') does not appear to work?! :-( - return make_assaytype_property_info(record).serialize() - return None - - -def dataset_get_logic(neo4j_instance, data_type: str = '', description: str = '', - alt_name: str = '', primary: str = '', contains_pii: str = '', vis_only: str = '', - vitessce_hint: str = '', dataset_provider: str = '', application_context: str = 'HUBMAP') \ - -> List[DatasetPropertyInfo]: - # JAS FEB 2023 - # Returns an array of objects corresponding to Dataset (type) nodes in the HubMAP - # or SenNet application ontology. - # The return replicates the content of the original assay_types.yaml file, and adds new - # dataset properties that were not originally in that file. - - # Arguments: - # application_context: HUBMAP or SENNET - # data_type...vitessce_hint: specific filtering values of properties - - # Notes: - # 1. The order of the optional arguments must match the order of parameters in the corresponding path in the - # spec.yaml file. - # 2. The field names in the response match the original keys in the original asset_types.yaml file. - # Unfortunately, some of these keys have names that use dashes (e.g., vis-only). Dashes are interpreted as - # subtraction operators in both the GET URL and in neo4j queries. This means that the parameters - # must use underscores instead of dashes--e.g., to filter on "vis-only", the parameter is "vis_only". - - datasets: [DatasetPropertyInfo] = [] - - # Build the Cypher query that will return the table of data. - query = query_cypher_dataset_info(application_context) - - # Execute Cypher query and return result. - with neo4j_instance.driver.session() as session: - recds: neo4j.Result = session.run(query) - - for record in recds: - # Because the Cypher query concatenates a set of subqueries, filtering by a parameter - # can only be done with the full return, except for the case of the initial subquery. - - # Filtering is additive--i.e., boolean AND. - - includerecord = True - if data_type is not None: - includerecord = includerecord and record.get('data_type') == data_type - - if description is not None: - includerecord = includerecord and record.get('description') == description - - if alt_name is not None: - includerecord = includerecord and alt_name in record.get('alt_names') - - if primary is not None: - primarybool = primary.lower() == "true" - includerecord = includerecord and record.get('primary') == primarybool - - if vis_only is not None: - visbool = vis_only.lower() == "true" - includerecord = includerecord and record.get('vis_only') == visbool - - if vitessce_hint is not None: - includerecord = includerecord and vitessce_hint in record.get('vitessce_hints') - - if dataset_provider is not None: - if dataset_provider.lower() == 'iec': - prov = application_context + ' IEC' - else: - prov = 'External Provider' - includerecord = includerecord and record.get('dataset_provider').lower() == prov.lower() - - if contains_pii is not None: - piibool = contains_pii.lower() == "true" - includerecord = includerecord and record.get('contains_pii') == piibool - - if includerecord: - try: - dataset: [DatasetPropertyInfo] = DatasetPropertyInfo(record.get('alt_names'), - record.get('contains_pii'), - record.get('data_type'), - record.get('dataset_provider'), - record.get('description'), - record.get('primary'), - record.get('vis_only'), - record.get('vitessce_hints') - ).serialize() - - datasets.append(dataset) - except KeyError: - pass - - return datasets - - def get_organ_types_logic(neo4j_instance, sab): """ Objectives: Provide crosswalk information between organs and RUI. diff --git a/src/main.py b/src/main.py index fee44b2..e8e240d 100755 --- a/src/main.py +++ b/src/main.py @@ -3,8 +3,10 @@ from pathlib import Path from ubkg_api.app import UbkgAPI, logger -from hs_ontology_api.routes.assaytype.assaytype_controller import assaytype_blueprint -from hs_ontology_api.routes.assayname.assayname_controller import assayname_blueprint +# October 2024 deprecated +# from src.hs_ontology_api.routes.deprecated.assaytype.assaytype_controller import assaytype_blueprint +# from src.hs_ontology_api.routes.deprecated.assayname import assayname_blueprint + # July 2024 deprecated datasets # from src.hs_ontology_api.routes.deprecated.datasets.datasets_controller import datasets_blueprint from hs_ontology_api.routes.organs.organs_controller import organs_blueprint @@ -46,8 +48,9 @@ def make_flask_config(): app = UbkgAPI(make_flask_config(), Path(__file__).absolute().parent.parent).app -app.register_blueprint(assaytype_blueprint) -app.register_blueprint(assayname_blueprint) +# October 2024 +# app.register_blueprint(assaytype_blueprint) +# app.register_blueprint(assayname_blueprint) # July 2024 - deprecating datasets #app.register_blueprint(datasets_blueprint) diff --git a/test/test_api.sh b/test/test_api.sh index dc5ae25..8f3a6eb 100755 --- a/test/test_api.sh +++ b/test/test_api.sh @@ -69,33 +69,6 @@ echo | tee -a test.out # $ (export UBKG_URL=http://127.0.0.1:5002; ./test_api.sh) # Using UBKG at: http://127.0.0.1:5002 -#-------------------------------------------- -echo "TESTS FOR: assayname POST" | tee -a test.out -echo "SIGNATURE: /assayname" | tee -a test.out -echo | tee -a test.out -echo | tee -a test.out - -echo "/assayname_POST with bulk-RNA => should return 200" | tee -a test.out -curl --request POST \ - --url "${UBKG_URL}/assayname" \ - --header "Content-Type: application/json" \ - --data '{"name": ["bulk-RNA"]}' |tee -a test.out -echo -echo | tee -a test.out -echo | tee -a test.out - -echo "TESTS FOR: assaytypes GET" | tee -a test.out -echo "SIGNATURE: /assaytypes?application_context=" | tee -a test.out -echo | tee -a test.out -echo | tee -a test.out -echo "/assaytype?application_context=HUBMAP GET => should return 200" | tee -a test.out -curl --request GET \ - --url "${UBKG_URL}/assaytype?application_context=HUBMAP" \ - --header "Accept: application/json"| cut -c1-60 | tee -a test.out -echo -echo | tee -a test.out -echo | tee -a test.out - echo "TESTS FOR: assayclasses GET" | tee -a test.out echo "SIGNATURE: /assayclasses?application_context=&process_state=" | tee -a test.out diff --git a/test/test_gateway.sh b/test/test_gateway.sh index b85a5a5..a6e9dd4 100755 --- a/test/test_gateway.sh +++ b/test/test_gateway.sh @@ -113,25 +113,6 @@ echo "Using UBKG at: ${UBKG_URL}" # $ (export UBKG_URL=http://127.0.0.1:5002; ./test_api.sh) # Using UBKG at: http://127.0.0.1:5002 -echo "assayname_POST..." -curl --request POST \ - --url "${UBKG_URL}/assayname" \ - --header "Content-Type: application/json" \ - --data '{"name": "bulk-RNA"}' -echo - -echo "assaytype GET" -curl --request GET \ - --url "${UBKG_URL}/assaytype?application_context=HUBMAP" \ - --header "Accept: application/json" |cut -c1-60 -echo - - -echo "assaytype/ GET" -curl --request GET \ - --url "${UBKG_URL}/assaytype/bulk-RNA?application_context=HUBMAP" \ - --header "Accept: application/json" |cut -c1-60 -echo # JAS update: datasets replaced with assayclasses echo "assayclasses GET"