-
Notifications
You must be signed in to change notification settings - Fork 1
Derek furst/get associated organs from dataset #254
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
Derek furst/get associated organs from dataset #254
Conversation
get_associated_organs_from_dataset(id). Added the associated method in app_neo4j_queries.py that implements the neo4j query.
individual organ. An organ will always be public if a dataset created from it is public.
| return jsonify(results) | ||
|
|
||
|
|
||
| @app.route('/datasets/<id>/organs', methods=['GET']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment block above this function like the rest with description, input parameters, and return?
src/app.py
Outdated
|
|
||
| # If a dataset is published/public, then the organs associated to it will by definition also be public. So no | ||
| # further validation is needed on the individual organs. | ||
| return jsonify(associated_organs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shirey do we just need to return a list of Sample organ uuids? If a list of normalized Sample dicts are supposed to be the result, @DerekFurstPitt should following the result handling in get_ancestor_organs(id).
src/app_neo4j_queries.py
Outdated
| """ | ||
| def get_associated_organs_from_dataset(neo4j_driver, dataset_uuid): | ||
| query = (f"MATCH (ds:Dataset {{uuid:'{dataset_uuid}'}})<-[*]-(organ:Sample {{specimen_type:'organ'}}) " | ||
| f"RETURN distinct organ.uuid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are multiple associated Sample organs found, then the Cypher query should return a Set (Collection with no duplicates). Either a set of uuids or nodes (need to be converted to dicts). And the return data is determined by the need of that API call -- either a list of uuids or normalized dicts of sample details. Probably dicts since there won't be too many organs associated with a given dataset.
src/app_neo4j_queries.py
Outdated
| query = (f"MATCH (ds:Dataset {{uuid:'{dataset_uuid}'}})<-[*]-(organ:Sample {{specimen_type:'organ'}}) " | ||
| f"RETURN distinct organ.uuid") | ||
|
|
||
| logger.debug("======get_associated_organs_from_sample() query======") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need use the same function name to be consistent.
…aks to app.py get_associated_organs accordingly. Also added comment block above that method.
|
Requested changes made |
|
@DerekFurstPitt there are still two things need to be addressed:
|
Applied normalization to response before returning in app.py get_associated_organs_from_dataset(id)
Implemented method get_asociated_organs_from_dataset(id) at endpoint /datasets//organs.
Takes an id for a dataset and runs a neo4j query to return every organ associated with this dataset. If no organ is found, given id is not to a dataset, user has bad token, or user has insufficient permissions, it fails.