aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2021-05-13 10:58:19 +0300
committerBonfaceKilz2021-05-13 11:18:57 +0300
commit7ab86429219a2ed5ad7b94f0ce9667dd4c38c56d (patch)
tree609854b13e95958ee56bf55b91582afe4f234e88
parent378d0fc7f4ff5df5e8e77617c37bcef2b26ddf02 (diff)
downloadgenenetwork3-7ab86429219a2ed5ad7b94f0ce9667dd4c38c56d.tar.gz
Add end-point for running an rQTL program
* gn3/api/general.py (run_r_qtl): New function. * gn3/settings.py: New variable.
-rw-r--r--gn3/api/general.py14
-rw-r--r--gn3/settings.py1
2 files changed, 15 insertions, 0 deletions
diff --git a/gn3/api/general.py b/gn3/api/general.py
index a9a8da2..cebb2e3 100644
--- a/gn3/api/general.py
+++ b/gn3/api/general.py
@@ -6,6 +6,7 @@ from flask import jsonify
from flask import request
from gn3.fs_helpers import extract_uploaded_file
+from gn3.commands import run_cmd
general = Blueprint("general", __name__)
@@ -50,3 +51,16 @@ TTL is set in the metadata file. If none is provided, the default is 1 week.
if results.get("status") > 0:
status = 500
return jsonify(results), status
+
+
+@general.route("/qtl/run/<geno_filestr>/<pheno_filestr>",
+ methods=["POST"],
+ strict_slashes=False)
+def run_r_qtl(geno_filestr, pheno_filestr):
+ """Run r_qtl command using the written rqtl_wrapper program
+
+ """
+ rqtl_wrapper = current_app.config["RQTL_WRAPPER"]
+ cmd = (f"Rscript {rqtl_wrapper} "
+ f"{geno_filestr} {pheno_filestr}")
+ return jsonify(run_cmd(cmd)), 201
diff --git a/gn3/settings.py b/gn3/settings.py
index 7b3ffb7..2057ce1 100644
--- a/gn3/settings.py
+++ b/gn3/settings.py
@@ -10,6 +10,7 @@ CACHEDIR = ""
REDIS_URI = "redis://localhost:6379/0"
REDIS_JOB_QUEUE = "GN3::job-queue"
TMPDIR = os.environ.get("TMPDIR", tempfile.gettempdir())
+RQTL_WRAPPER = "rqtl_wrapper.R"
# SQL confs
SQL_URI = os.environ.get("SQL_URI", "mysql://webqtlout:webqtlout@localhost/db_webqtl")