blob: eb3465609c021bf880003e0a55a1cd0a3ea0f450 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
"""module contains code to process ctl analysis data"""
import json
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("scripts/ctl_analysis.R", temp_file_name)
cmd_results = run_cmd(cmd)
with open(temp_file_name, "r", encoding="utf-8") as outputfile:
if cmd_results["code"] != 0:
return (cmd_results, None)
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
ctl_plot in output_file_data["ctl_plots"]]
return (cmd_results, output_file_data)
|