aboutsummaryrefslogtreecommitdiff
path: root/r_qtl
diff options
context:
space:
mode:
Diffstat (limited to 'r_qtl')
-rw-r--r--r_qtl/r_qtl2_qc.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/r_qtl/r_qtl2_qc.py b/r_qtl/r_qtl2_qc.py
index a41c442..f62f142 100644
--- a/r_qtl/r_qtl2_qc.py
+++ b/r_qtl/r_qtl2_qc.py
@@ -97,6 +97,22 @@ def pheno_errors(zfile: ZipFile) -> Iterator[Union[InvalidValue, MissingFile]]:
zfile, "pheno", (__min_3_decimal_places__,))
if error is not None)
+def phenose_errors(zfile: ZipFile) -> Iterator[Union[InvalidValue, MissingFile]]:
+ """Check for and retrieve phenose errors."""
+ def __min_6_decimal_places__(
+ lineno: int, field: str, value: str) -> Optional[InvalidValue]:
+ if not (re.search(r"^([0-9]+\.[0-9]{6,}|[0-9]+\.?0*)$", value)
+ or re.search(r"^0\.0+$", value)
+ or re.search("^0+$", value)):
+ return InvalidValue(lineno, field, value, (
+ f"Invalid value '{value}'. Expected numerical value "
+ "with at least 6 decimal places."))
+ return None
+ return (
+ error for error in retrieve_errors(
+ zfile, "phenose", (__min_6_decimal_places__,))
+ if error is not None)
+
def retrieve_errors(zfile: ZipFile, filetype: str, checkers: tuple[Callable]) -> Iterator[
Union[InvalidValue, MissingFile]]:
"""Check for and retrieve errors from files of type `filetype`."""