From 8854e3070f32bed95cb489eb36e7f258c02ec46e Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Thu, 16 Sep 2021 09:32:42 +0300 Subject: add initial endpoint for wgcna --- gn3/api/wgcna.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 gn3/api/wgcna.py (limited to 'gn3/api') diff --git a/gn3/api/wgcna.py b/gn3/api/wgcna.py new file mode 100644 index 0000000..a3bacdd --- /dev/null +++ b/gn3/api/wgcna.py @@ -0,0 +1,13 @@ +"""endpoint to run wgcna analysis""" +from flask import Blueprint +from flask import request + +wgcna = Blueprint("wgcna", __name__) + + +@wgcna.route("/run_wgcna", methods=["POST"]) +def run_wgcna(): + + _wgcna_data = request.json + + return "success", 200 -- cgit v1.2.3 From f53a8a98206b4e8aedbf4b86e49f41ea140c9c6a Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Thu, 16 Sep 2021 14:02:13 +0300 Subject: pass user input to call script --- gn3/api/wgcna.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'gn3/api') diff --git a/gn3/api/wgcna.py b/gn3/api/wgcna.py index a3bacdd..5d49493 100644 --- a/gn3/api/wgcna.py +++ b/gn3/api/wgcna.py @@ -1,13 +1,21 @@ """endpoint to run wgcna analysis""" from flask import Blueprint from flask import request +from flask import current_app + +from gn3.computations.wgcna import call_wgcna_script wgcna = Blueprint("wgcna", __name__) @wgcna.route("/run_wgcna", methods=["POST"]) def run_wgcna(): + """run wgcna:output should be a json with a the data""" + + wgcna_data = request.json + + wgcna_script = current_app.config["WGCNA_RSCRIPT"] - _wgcna_data = request.json + results = call_wgcna_script(wgcna_script, wgcna_data) - return "success", 200 + return results, 200 -- cgit v1.2.3 From 6f7c60e6c438ada9a3b9032c8e4509351384e04f Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Wed, 22 Sep 2021 00:49:22 +0300 Subject: jsonify results --- gn3/api/wgcna.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gn3/api') diff --git a/gn3/api/wgcna.py b/gn3/api/wgcna.py index 5d49493..89784c4 100644 --- a/gn3/api/wgcna.py +++ b/gn3/api/wgcna.py @@ -2,6 +2,7 @@ from flask import Blueprint from flask import request from flask import current_app +from flask import jsonify from gn3.computations.wgcna import call_wgcna_script @@ -18,4 +19,4 @@ def run_wgcna(): results = call_wgcna_script(wgcna_script, wgcna_data) - return results, 200 + return jsonify(results), 200 -- cgit v1.2.3 From 62a5047be6cee5f692d44f97410cab11a01e3396 Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Thu, 23 Sep 2021 16:05:17 +0300 Subject: minor fixes for endpoint --- gn3/api/wgcna.py | 3 +++ gn3/computations/wgcna.py | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'gn3/api') diff --git a/gn3/api/wgcna.py b/gn3/api/wgcna.py index 89784c4..fa044cf 100644 --- a/gn3/api/wgcna.py +++ b/gn3/api/wgcna.py @@ -19,4 +19,7 @@ def run_wgcna(): results = call_wgcna_script(wgcna_script, wgcna_data) + if results.get("data") is None: + return jsonify(results), 401 + return jsonify(results), 200 diff --git a/gn3/computations/wgcna.py b/gn3/computations/wgcna.py index e9b76e8..436a888 100644 --- a/gn3/computations/wgcna.py +++ b/gn3/computations/wgcna.py @@ -44,6 +44,5 @@ def call_wgcna_script(rscript_path: str, request_data: dict): "data": json.load(outputfile), **run_cmd_results } - # return json.load(outputfile) except Exception as error: raise error -- cgit v1.2.3