aboutsummaryrefslogtreecommitdiff
path: root/r_qtl/r_qtl2.py
diff options
context:
space:
mode:
Diffstat (limited to 'r_qtl/r_qtl2.py')
-rw-r--r--r_qtl/r_qtl2.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py
index 9da4081..d7d81d1 100644
--- a/r_qtl/r_qtl2.py
+++ b/r_qtl/r_qtl2.py
@@ -18,6 +18,10 @@ FILE_TYPES = (
"geno", "founder_geno", "pheno", "covar", "phenocovar", "gmap", "pmap",
"phenose")
+__CONTROL_FILE_ERROR_MESSAGE__ = (
+ "The zipped bundle that was provided does not contain a valid control file "
+ "in either JSON or YAML format.")
+
def __special_file__(filename):
"""
@@ -112,7 +116,7 @@ def __control_data_from_zipfile__(zfile: ZipFile) -> dict:
or filename.endswith(".json"))))
num_files = len(files)
if num_files == 0:
- raise InvalidFormat("Expected a json or yaml control file.")
+ raise InvalidFormat(__CONTROL_FILE_ERROR_MESSAGE__)
if num_files > 1:
raise InvalidFormat("Found more than one possible control file.")
@@ -129,7 +133,6 @@ def __control_data_from_zipfile__(zfile: ZipFile) -> dict:
else yaml.safe_load(zfile.read(files[0])))
}
-
def __control_data_from_dirpath__(dirpath: Path):
"""Load control data from a given directory path."""
files = tuple(path for path in dirpath.iterdir()
@@ -137,7 +140,7 @@ def __control_data_from_dirpath__(dirpath: Path):
and (path.suffix in (".yaml", ".json"))))
num_files = len(files)
if num_files == 0:
- raise InvalidFormat("Expected a json or yaml control file.")
+ raise InvalidFormat(__CONTROL_FILE_ERROR_MESSAGE__)
if num_files > 1:
raise InvalidFormat("Found more than one possible control file.")
@@ -200,8 +203,8 @@ def control_data(control_src: Union[Path, ZipFile]) -> dict:
if control_src.is_dir():
return __cleanup__(__control_data_from_dirpath__(control_src))
raise InvalidFormat(
- "Expects either a zipfile.ZipFile object or a pathlib.Path object "
- "pointing to a directory containing the R/qtl2 bundle.")
+ "Expects either a zipped bundle of files or a path-like object "
+ "pointing to the zipped R/qtl2 bundle.")
def replace_na_strings(cdata, val):