diff options
author | Munyoki Kilyungi | 2023-03-01 15:48:15 +0300 |
---|---|---|
committer | BonfaceKilz | 2023-03-01 22:03:39 +0300 |
commit | 32c144cdf41d2f109901d34930296f34fa51323e (patch) | |
tree | 09468c989fbef260f95fc0ede1f313756390d280 /gn3/api/sampledata.py | |
parent | e32dacc9648908a73855d99e7681cb4d7aa4f98e (diff) | |
download | genenetwork3-32c144cdf41d2f109901d34930296f34fa51323e.tar.gz |
Fetch sampledata
* gn3/api/sampledata.py (get_sampledata): New end-point.
* gn3/app.py: Register above end-point.
* gn3/settings.py: Add new conf variable for LMDB.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/api/sampledata.py')
-rw-r--r-- | gn3/api/sampledata.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gn3/api/sampledata.py b/gn3/api/sampledata.py new file mode 100644 index 0000000..5b09b52 --- /dev/null +++ b/gn3/api/sampledata.py @@ -0,0 +1,23 @@ +"""API for fetching sampledata from a given trait""" +import os +from flask import Blueprint +from flask import jsonify +from flask import current_app + +from gn3.db.matrix import get_current_matrix + + +sampledata = Blueprint("sampledata", __name__) + + +@sampledata.route("/dataset/<dataset_name>/trait/<trait_name>", methods=["GET"]) +def get_sampledata(dataset_name, trait_name): + """Fetch a trait's sampledata as a matrix.""" + return jsonify( + get_current_matrix( + os.path.join( + current_app.config.get("LMDB_PATH"), + dataset_name, trait_name + ) + ) + ) |