Skip to content

Conversation

@DerekFurstPitt
Copy link
Contributor

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.

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'])
Copy link
Member

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)
Copy link
Member

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).

"""
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")
Copy link
Member

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.

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======")
Copy link
Member

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.
@DerekFurstPitt
Copy link
Contributor Author

Requested changes made

@yuanzhou
Copy link
Member

@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)
@yuanzhou yuanzhou merged commit 5888700 into dev-integrate Oct 27, 2021
@yuanzhou yuanzhou deleted the Derek-Furst/get-associated-organs-from-dataset branch November 8, 2021 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants