aboutsummaryrefslogtreecommitdiff
path: root/gn3/computations
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-27 16:20:18 -0500
committerFrederick Muriuki Muriithi2024-09-27 16:21:21 -0500
commit6e86be5910d01b8d682e217c0e53e49cf709a237 (patch)
tree2c7cfcb6a3443223b148245a9696b5a1a34aa0e2 /gn3/computations
parente2883e55b47f062b2d3d6ae50d6fe533ba8d841d (diff)
downloadgenenetwork3-6e86be5910d01b8d682e217c0e53e49cf709a237.tar.gz
Bug: Use absolute paths in place of relative paths.
Similar issue to commit 11d543eeca08fe0df4bf2be7222234fadb516a51
Diffstat (limited to 'gn3/computations')
-rw-r--r--gn3/computations/ctl.py2
-rw-r--r--gn3/computations/wgcna.py9
2 files changed, 7 insertions, 4 deletions
diff --git a/gn3/computations/ctl.py b/gn3/computations/ctl.py
index eb34656..f881410 100644
--- a/gn3/computations/ctl.py
+++ b/gn3/computations/ctl.py
@@ -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("scripts/ctl_analysis.R", temp_file_name)
+ cmd = compose_wgcna_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 a86c9ab..d1f7b32 100644
--- a/gn3/computations/wgcna.py
+++ b/gn3/computations/wgcna.py
@@ -1,10 +1,10 @@
"""module contains code to preprocess and call wgcna script"""
-
import os
import json
import uuid
-import subprocess
import base64
+import subprocess
+from pathlib import Path
from gn3.settings import TMPDIR
@@ -58,7 +58,10 @@ def process_image(image_loc: str) -> bytes:
def compose_wgcna_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}"
+ abs_rscript_path = str(
+ Path(__file__).absolute().parent.parent.parent.joinpath(
+ f"scripts/{rscript_path}"))
+ cmd = f"Rscript {abs_rscript_path} {temp_file_path}"
return cmd