aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
Diffstat (limited to 'gn3')
-rw-r--r--gn3/api/rqtl.py2
-rw-r--r--gn3/computations/gemma.py11
-rw-r--r--gn3/fs_helpers.py17
3 files changed, 7 insertions, 23 deletions
diff --git a/gn3/api/rqtl.py b/gn3/api/rqtl.py
index 0a380a4..36bc3da 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.computations.gemma import assert_paths_exist
+from gn3.fs_helpers import assert_paths_exist
rqtl = Blueprint("rqtl", __name__)
diff --git a/gn3/computations/gemma.py b/gn3/computations/gemma.py
index f97fa6d..2c367ff 100644
--- a/gn3/computations/gemma.py
+++ b/gn3/computations/gemma.py
@@ -41,17 +41,6 @@ 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,
diff --git a/gn3/fs_helpers.py b/gn3/fs_helpers.py
index 845c48b..c2c240c 100644
--- a/gn3/fs_helpers.py
+++ b/gn3/fs_helpers.py
@@ -13,19 +13,14 @@ from typing import List
from typing import ValuesView
from werkzeug.utils import secure_filename
-def assert_path_exists(path: str, throw_error: bool = True) -> bool:
- """Throw error if any of them do not exist."""
- if not os.path.isfile(path):
- if throw_error:
- raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
- else:
- return False
- return True
-
-def assert_paths_exist(paths: ValuesView, throw_error: bool = True) -> bool:
+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:
- assert_path_exists(path,throw_error)
+ if not os.path.isfile(path):
+ if throw_error:
+ raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
+ else:
+ return False
return True
def get_hash_of_files(files: List[str]) -> str: