aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn3/computations/ctl.py4
-rw-r--r--gn3/computations/wgcna.py6
-rw-r--r--tests/unit/computations/test_wgcna.py10
3 files changed, 10 insertions, 10 deletions
diff --git a/gn3/computations/ctl.py b/gn3/computations/ctl.py
index f881410..af1c508 100644
--- a/gn3/computations/ctl.py
+++ b/gn3/computations/ctl.py
@@ -3,7 +3,7 @@ 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 compose_rscript_cmd
from gn3.computations.wgcna import process_image
from gn3.settings import TMPDIR
@@ -13,7 +13,7 @@ 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)
+ cmd = compose_rscript_cmd("ctl_analysis.R", temp_file_name)
cmd_results = run_cmd(cmd)
with open(temp_file_name, "r", encoding="utf-8") as outputfile:
diff --git a/gn3/computations/wgcna.py b/gn3/computations/wgcna.py
index c985491..01aaedb 100644
--- a/gn3/computations/wgcna.py
+++ b/gn3/computations/wgcna.py
@@ -55,17 +55,17 @@ def process_image(image_loc: str) -> bytes:
return b""
-def compose_wgcna_cmd(rscript_path: str, temp_file_path: str):
+def compose_rscript_cmd(rscript_path: str, temp_file_path: str):
"""function to componse wgcna cmd"""
# (todo):issue relative paths to abs paths
- cmd = f"Rscript ./scripts/{rscript_path} {temp_file_path}"
+ cmd = f'"Rscript ./scripts/{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_wgcna_cmd(rscript_path, generated_file)
+ cmd = compose_rscript_cmd(rscript_path, generated_file)
# stream_cmd_output(request_data, cmd) disable streaming of data
diff --git a/tests/unit/computations/test_wgcna.py b/tests/unit/computations/test_wgcna.py
index a9108b0..d6d2bf8 100644
--- a/tests/unit/computations/test_wgcna.py
+++ b/tests/unit/computations/test_wgcna.py
@@ -5,7 +5,7 @@ from unittest import mock
import pytest
from gn3.computations.wgcna import dump_wgcna_data
-from gn3.computations.wgcna import compose_wgcna_cmd
+from gn3.computations.wgcna import compose_rscript_cmd
from gn3.computations.wgcna import call_wgcna_script
@@ -15,7 +15,7 @@ class TestWgcna(TestCase):
@pytest.mark.unit_test
@mock.patch("gn3.computations.wgcna.process_image")
@mock.patch("gn3.computations.wgcna.run_cmd")
- @mock.patch("gn3.computations.wgcna.compose_wgcna_cmd")
+ @mock.patch("gn3.computations.wgcna.compose_rscript_cmd")
@mock.patch("gn3.computations.wgcna.dump_wgcna_data")
def test_call_wgcna_script(self,
mock_dumping_data,
@@ -100,7 +100,7 @@ class TestWgcna(TestCase):
@pytest.mark.unit_test
@mock.patch("gn3.computations.wgcna.run_cmd")
- @mock.patch("gn3.computations.wgcna.compose_wgcna_cmd")
+ @mock.patch("gn3.computations.wgcna.compose_rscript_cmd")
@mock.patch("gn3.computations.wgcna.dump_wgcna_data")
def test_call_wgcna_script_fails(self, mock_dumping_data, mock_compose_wgcna, mock_run_cmd):
"""test for calling wgcna script\
@@ -122,9 +122,9 @@ class TestWgcna(TestCase):
"input_file.R", ""), expected_error)
@pytest.mark.unit_test
- def test_compose_wgcna_cmd(self):
+ def test_compose_rscript_cmd(self):
"""test for composing wgcna cmd"""
- wgcna_cmd = compose_wgcna_cmd(
+ wgcna_cmd = compose_rscript_cmd(
"wgcna.r", "/tmp/wgcna.json")
self.assertEqual(
wgcna_cmd, "Rscript ./scripts/wgcna.r /tmp/wgcna.json")