aboutsummaryrefslogtreecommitdiff
path: root/r_qtl
diff options
context:
space:
mode:
Diffstat (limited to 'r_qtl')
-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