From 8b357f7c5cdac8fcf342b27a7227cbc2a1a3a5f5 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 23 Jan 2025 16:27:44 +0300 Subject: refactor: Minor cleanup. --- gn3/api/rqtl2.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'gn3/api/rqtl2.py') 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) -- cgit 1.4.1