aboutsummaryrefslogtreecommitdiff
path: root/r_qtl/r_qtl2_qc.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-02-12 10:44:35 +0300
committerFrederick Muriuki Muriithi2024-02-12 18:17:41 +0300
commitabb55d7e03bf207ebf00b4c71f1bbdd8f58a0ad3 (patch)
tree65d97370d93b7ef19c271ef51f97d6d94b18a695 /r_qtl/r_qtl2_qc.py
parent523bd6634539a2e646a7cd4215ad3ee7dbbeeb66 (diff)
downloadgn-uploader-abb55d7e03bf207ebf00b4c71f1bbdd8f58a0ad3.tar.gz
Check for errors in the 'phenose' file.
Diffstat (limited to 'r_qtl/r_qtl2_qc.py')
-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`."""