From e7d8432c16b0ab63e49d3bfcd29fc8a8cad8462d Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Thu, 13 Jan 2022 19:07:22 +0300 Subject: process ctl plot data img --- gn3/computations/ctl.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'gn3/computations') diff --git a/gn3/computations/ctl.py b/gn3/computations/ctl.py index 8f20b65..0dec3c4 100644 --- a/gn3/computations/ctl.py +++ b/gn3/computations/ctl.py @@ -4,22 +4,32 @@ from gn3.commands import run_cmd from gn3.computations.wgcna import dump_wgcna_data from gn3.computations.wgcna import compose_wgcna_cmd +from gn3.computations.wgcna import process_image + +from gn3.settings import TMPDIR def call_ctl_script(data): """function to call ctl script""" - + data["imgDir"] = TMPDIR temp_file_name = dump_wgcna_data(data) cmd = compose_wgcna_cmd("ctl_analysis.R", temp_file_name) try: cmd_results = run_cmd(cmd) - print(cmd_results) - with open(temp_file_name,"r") as outputfile: + with open(temp_file_name, "r") as outputfile: if cmd_results["code"] != 0: return cmd_results - return json.load(outputfile) + output_file_data = json.load(outputfile) + + output_file_data["image_data"] = process_image( + output_file_data["image_loc"]).decode("ascii") + + output_file_data["ctl_plots"] = [process_image(ctl_plot).decode("ascii") for + clt_plot in output_file_data["ctl_plots"]] + + return output_file_data except Exception as e: return str(e) -- cgit v1.2.3