aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kabui2022-02-01 00:27:05 +0300
committerBonfaceKilz2022-02-02 10:59:34 +0300
commit5a55015a98b12f16b44f758c3f08d26ffc286313 (patch)
tree664a60e962b449e71c4bd1e53d9b06a3d4ade5dd
parent0865b53a22a93dc834f77b0b621e99f6d7b33e87 (diff)
downloadgenenetwork3-5a55015a98b12f16b44f758c3f08d26ffc286313.tar.gz
refactor code for invoking ctl script
-rw-r--r--gn3/computations/ctl.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/gn3/computations/ctl.py b/gn3/computations/ctl.py
index a5c4565..238740f 100644
--- a/gn3/computations/ctl.py
+++ b/gn3/computations/ctl.py
@@ -15,22 +15,16 @@ def call_ctl_script(data):
temp_file_name = dump_wgcna_data(data)
cmd = compose_wgcna_cmd("ctl_analysis.R", temp_file_name)
- try:
- cmd_results = run_cmd(cmd)
- with open(temp_file_name, "r") as outputfile:
- if cmd_results["code"] != 0:
- return cmd_results
+ cmd_results = run_cmd(cmd)
+ with open(temp_file_name, "r") as outputfile:
+ if cmd_results["code"] != 0:
+ return (cmd_results, None)
+ output_file_data = 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["image_data"] = process_image(
- output_file_data["image_loc"]).decode("ascii")
-
- output_file_data["ctl_plots"] = [process_image(ctl_plot).decode("ascii") for
- ctl_plot in output_file_data["ctl_plots"]]
-
- return output_file_data
-
- except Exception as e:
- return str(e)
+ output_file_data["ctl_plots"] = [process_image(ctl_plot).decode("ascii") for
+ ctl_plot in output_file_data["ctl_plots"]]
+ return (cmd_results, output_file_data)