aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2024-03-24 09:36:33 +0100
committerFrederick Muriuki Muriithi2024-09-12 07:34:59 -0500
commitbbca8fe96bd2176f300cab8746dace6fd2323320 (patch)
tree0ce8bd8defb2a1904d8c64b2fb792a140d7c7619
parent644100ea2e5e407eb06ccb292d85dd20b104beee (diff)
downloadgenenetwork3-bbca8fe96bd2176f300cab8746dace6fd2323320.tar.gz
Change behavior of do_paths_exist to actually throw useful error
-rw-r--r--gn3/api/rqtl.py2
-rw-r--r--gn3/computations/gemma.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/gn3/api/rqtl.py b/gn3/api/rqtl.py
index 36bc3da..0a380a4 100644
--- a/gn3/api/rqtl.py
+++ b/gn3/api/rqtl.py
@@ -9,7 +9,7 @@ from flask import request
from gn3.debug import __pk__
from gn3.computations.rqtl import generate_rqtl_cmd, process_rqtl_mapping, \
process_rqtl_pairscan, process_perm_output
-from gn3.fs_helpers import assert_paths_exist
+from gn3.computations.gemma import assert_paths_exist
rqtl = Blueprint("rqtl", __name__)
diff --git a/gn3/computations/gemma.py b/gn3/computations/gemma.py
index 2c367ff..f97fa6d 100644
--- a/gn3/computations/gemma.py
+++ b/gn3/computations/gemma.py
@@ -41,6 +41,17 @@ def generate_pheno_txt_file(trait_filename: str,
return f"{tmpdir}/gn2/{trait_filename}"
+def assert_paths_exist(paths: ValuesView) -> bool:
+ """Given a list of PATHS, throw error if any of them do not exist."""
+ for path in paths:
+ if not os.path.isfile(path):
+ if throw_error:
+ raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
+ else:
+ return False
+ return True
+
+
# pylint: disable=R0913
def generate_gemma_cmd(gemma_cmd: str,
output_dir: str,