aboutsummaryrefslogtreecommitdiff
path: root/r_qtl/r_qtl2_qc.py
diff options
context:
space:
mode:
Diffstat (limited to 'r_qtl/r_qtl2_qc.py')
-rw-r--r--r_qtl/r_qtl2_qc.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/r_qtl/r_qtl2_qc.py b/r_qtl/r_qtl2_qc.py
index 43f7d94..be1eac4 100644
--- a/r_qtl/r_qtl2_qc.py
+++ b/r_qtl/r_qtl2_qc.py
@@ -63,12 +63,13 @@ def validate_bundle(zfile: ZipFile):
"The following files do not exist in the bundle: " +
", ".join(mfile[1] for mfile in missing))
-def make_genocode_checker(genocode: dict) -> Callable[[int, str, str], Optional[InvalidValue]]:
+def make_genocode_checker(genocode: dict, filename: str) -> Callable[
+ [int, str, str], Optional[InvalidValue]]:
"""Make a checker from the genotypes in the control data"""
def __checker__(lineno: int, field: str, value: str) -> Optional[InvalidValue]:
genotypes = tuple(genocode.keys())
if value not in genotypes:
- return InvalidValue(lineno, field, value, (
+ return InvalidValue(filename, lineno, field, value, (
f"Invalid value '{value}'. Expected one of {genotypes}."))
return None
return __checker__
@@ -78,14 +79,15 @@ def geno_errors(zfile: ZipFile) -> Iterator[Union[InvalidValue, MissingFile]]:
cdata = rqtl2.control_data(zfile)
return (
error for error in retrieve_errors(
- zfile, "geno", (make_genocode_checker(cdata.get("genotypes", {})),))
+ zfile, "geno", (make_genocode_checker(cdata.get("genotypes", {}), "geno"),))
if error is not None)
def pheno_errors(zfile: ZipFile) -> Iterator[Union[InvalidValue, MissingFile]]:
"""Check for and retrieve pheno errors."""
return (
error for error in retrieve_errors(
- zfile, "pheno", (partial(decimal_points_error, mini=3),))
+ zfile, "pheno", (partial(
+ decimal_points_error, mini=3, filename="pheno"),))
if error is not None)
def phenose_errors(zfile: ZipFile) -> Iterator[Union[InvalidValue, MissingFile]]:
@@ -108,7 +110,7 @@ def retrieve_errors(zfile: ZipFile, filetype: str, checkers: tuple[Callable]) ->
continue
if value is not None:
for checker in checkers:
- yield checker(lineno, field, value)
+ yield checker(lineno=lineno, field=field, value=value)
except rqe.MissingFileError:
fname = cdata.get(filetype)
yield MissingFile(filetype, fname, f"Missing '{filetype}' file '{fname}'.")