Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map legacy is_primary boolean to categorical process_state in legacy assaytype and assayname endpoints #109

Merged
merged 3 commits into from
Jul 29, 2024
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
4 changes: 3 additions & 1 deletion src/hs_ontology_api/routes/assayname/assayname_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def assayname_post():
assaytype = {}
val = r.get('value')
assaytype['name'] = val.get('assaytype')
assaytype['primary'] = val.get('primary')
# 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.
Expand Down
20 changes: 15 additions & 5 deletions src/hs_ontology_api/routes/assaytype/assaytype_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def assaytype_get(name=None):
# Validate parameters.

# Check for invalid parameter names.
err = validate_query_parameter_names(parameter_name_list=['application_context', 'is_primary'])
err = validate_query_parameter_names(parameter_name_list=['application_context', 'primary'])
if err != 'ok':
return make_response(err, 400)

Expand All @@ -48,17 +48,24 @@ def assaytype_get(name=None):
return make_response(err, 400)

# Check for valid parameter values.
is_primary = request.args.get('is_primary')
# 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='is_primary', param_value=is_primary, enum_list=val_enum)
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, context=application_context)
neo4j_instance, assaytype=name, process_state=process_state, context=application_context)

if (result is None or result == []):
# Empty result
Expand All @@ -72,7 +79,10 @@ def assaytype_get(name=None):
assaytype = {}
val = r.get('value')
assaytype['name'] = val.get('assaytype')
assaytype['primary'] = val.get('primary')
# 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.
Expand Down
Loading