about summary refs log tree commit diff
path: root/gn3/api/rqtl2.py
diff options
context:
space:
mode:
authorAlexander_Kabui2025-01-23 16:27:44 +0300
committerBonfaceKilz2025-02-06 12:43:15 +0300
commit8b357f7c5cdac8fcf342b27a7227cbc2a1a3a5f5 (patch)
tree3e1f854a8bcb17763b6e282e18d6da0aed491017 /gn3/api/rqtl2.py
parentca0f0bdda646de1b3862daf82c5cfb6889547f5f (diff)
downloadgenenetwork3-8b357f7c5cdac8fcf342b27a7227cbc2a1a3a5f5.tar.gz
refactor: Minor cleanup.
Diffstat (limited to 'gn3/api/rqtl2.py')
-rw-r--r--gn3/api/rqtl2.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/gn3/api/rqtl2.py b/gn3/api/rqtl2.py
index dbbb536..c1cd496 100644
--- a/gn3/api/rqtl2.py
+++ b/gn3/api/rqtl2.py
@@ -17,7 +17,6 @@ rqtl2 = Blueprint("rqtl2", __name__)
 def compute():
     """Endpoint for computing QTL analysis using R/QTL2"""
     data = request.json
-    # main requirements for creating the cross
     required_keys = ["crosstype", "geno_data","pheno_data", "geno_codes"]
     valid, error = validate_required_keys(required_keys,data)
     if not valid:
@@ -32,18 +31,14 @@ def compute():
      output_file, log_file) = prepare_files(current_app.config.get("TMPDIR"))
     # write the input file with data required for creating the cross
     write_input_file(input_file, workspace_dir, data)
-    # check if the rscript cmd command  exist
     rqtl_path =Path(__file__).absolute().parent.parent.parent.joinpath("scripts/rqtl2_wrapper.R")
     if not rqtl_path.is_file():
         return jsonify({"error" : f"The script {rqtl_path} does not exists"}), 400
     rqtl2_cmd = compose_rqtl2_cmd(rqtl_path, input_file,
                                   output_file, workspace_dir,
                                   data, current_app.config)
-    # run the rscript in as a subprocess which capture stdout in the log file
     process_output = run_process(rqtl2_cmd.split(),log_file, run_id)
+    shutil.rmtree(workspace_dir, ignore_errors=True, onerror=None)
     if process_output["code"]!=0:
         return jsonify(process_output), 400
-    # TODO: process the results and return results to gn2
-    # rm the workspace directory
-    shutil.rmtree(workspace_dir, ignore_errors=True, onerror=None)
-    return process_output
+    return jsonify(process_output)