diff options
author | Frederick Muriuki Muriithi | 2021-09-20 06:36:00 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2021-09-20 06:36:00 +0300 |
commit | b7fb10586b956a8b0389e7925e4c0cff28cde82f (patch) | |
tree | 42fd08f811e7fdc36a4b3c6decf0f649dd552211 /gn3/api | |
parent | 1e2357049adc72808fbf8eaac3da9411d3c78c66 (diff) | |
download | genenetwork3-b7fb10586b956a8b0389e7925e4c0cff28cde82f.tar.gz |
Return only the data
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi
* gn3/api/heatmaps.py: Parse incoming data to build up correct trait names and
respond with only the computed heatmap data.
* gn3/heatmaps.py: Return only the computed data for heatmaps and clustering.
Since GN3 is supposed to handle only the data, and db-access, this commit
ensures that GN3 responds to the client with only the computed heatmap data,
and does not try to generate the heatmaps themselves.
The generation of the heatmaps will be delegated to the UI clients, such as
GeneNetwork2.
Diffstat (limited to 'gn3/api')
-rw-r--r-- | gn3/api/heatmaps.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/gn3/api/heatmaps.py b/gn3/api/heatmaps.py index f053241..eea3ebe 100644 --- a/gn3/api/heatmaps.py +++ b/gn3/api/heatmaps.py @@ -15,15 +15,9 @@ def clustered_heatmaps(): "message": "You need to provide at least one trait name." }), 400 conn, _cursor = database_connector() - _heatmap_file, heatmap_fig = build_heatmap(traits_names, conn) - - # stream the heatmap data somehow here. - # Can plotly actually stream the figure data in a way that can be used on - # remote end to display the image without necessarily being html? - # return jsonify( - # { - # "query": heatmap_request, - # "output_png": heatmap_fig.to_image(format="png"), - # "output_svg": heatmap_fig.to_image(format="svg") - # }), 200 - return jsonify({"output_filename": _heatmap_file}), 200 + def setup_trait_fullname(trait): + name_parts = trait.split(":") + return "{dataset_name}::{trait_name}".format( + dataset_name=trait[1], trait_name=trait[0]) + traits_fullnames = [parse_trait_fullname(trait) for trait in traits_names] + return jsonify(build_heatmap(traits_fullnames, conn)), 200 |