diff options
author | Alexander Kabui | 2021-09-16 08:54:01 +0300 |
---|---|---|
committer | Alexander Kabui | 2021-09-16 08:54:01 +0300 |
commit | 38cbc95f216548d4a2f46b8e25cd328ff8c52d62 (patch) | |
tree | faf532a5ff4d91cd61d73a24af52abeb29b823bf /gn3/computations/wgcna.py | |
parent | a3ef298678b32ee83cac7bd7462d3d92f8eaec26 (diff) | |
download | genenetwork3-38cbc95f216548d4a2f46b8e25cd328ff8c52d62.tar.gz |
add function to compose and run wgcna script
Diffstat (limited to 'gn3/computations/wgcna.py')
-rw-r--r-- | gn3/computations/wgcna.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gn3/computations/wgcna.py b/gn3/computations/wgcna.py index 3819b62..bcd3a0a 100644 --- a/gn3/computations/wgcna.py +++ b/gn3/computations/wgcna.py @@ -5,8 +5,10 @@ import json import uuid from gn3.settings import TMPDIR +from gn3.commands import run_cmd -def dump_wgcna_data(request_data): + +def dump_wgcna_data(request_data: dict): """function to dump request data to json file""" filename = f"{str(uuid.uuid4())}.json" @@ -16,3 +18,16 @@ def dump_wgcna_data(request_data): json.dump(request_data, output_file) return temp_file_path + + +def compose_wgcna_cmd(rscript_path: str, temp_file_path: str): + """function to componse wgcna cmd""" + cmd = f"Rscript {rscript_path} {temp_file_path}" + return cmd + + +def call_wgcna_script(rscript_path: str, request_data: dict): + """function to call wgcna script""" + generated_file = dump_wgcna_data(request_data) + cmd = compose_gemma_cmd(rscript_path, generated_file) + run_cmd(cmd=cmd) |