aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-02-16 16:34:11 +0300
committerFrederick Muriuki Muriithi2024-02-16 16:48:40 +0300
commit7a3e0fdac498a9d22c6ea8789b42c5c882120e00 (patch)
tree6d88a28b98d08af115f0aa23d08717593fd0aa25
parent6e3d4c5cf0c9f4b6f468092730e4b6b22f7e5170 (diff)
downloadgn-uploader-7a3e0fdac498a9d22c6ea8789b42c5c882120e00.tar.gz
Convert missing value codes to None
-rw-r--r--r_qtl/r_qtl2.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py
index e4c1894..4f0ab2a 100644
--- a/r_qtl/r_qtl2.py
+++ b/r_qtl/r_qtl2.py
@@ -306,3 +306,10 @@ def raw_file_data(zipfilepath: Union[str, Path],
def strip_comments(rawdata: Iterator[str], commentchar) -> Iterator[str]:
"""Remove comments from raw text."""
return (line for line in rawdata if not line.startswith(commentchar))
+
+def missing_value_codes_to_none(value: str,
+ nastrings: tuple[str, ...]) -> Optional[str]:
+ """
+ If 'value' is a missing value code, return `None`, otherwise return 'value'.
+ """
+ return value if value not in nastrings else None