diff options
Diffstat (limited to 'r_qtl')
-rw-r--r-- | r_qtl/r_qtl2.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py index 96776b7..93b8c8e 100644 --- a/r_qtl/r_qtl2.py +++ b/r_qtl/r_qtl2.py @@ -318,3 +318,19 @@ def missing_value_codes_to_none(value: str, def replace_genotype_codes(value: str, genocodes: dict): """Convert genotype codes into values specified in control file.""" return genocodes.get(value, value) + +def read_control_file(zipfilepath: Union[str, Path]) -> dict: + """Read control data.""" + with ZipFile(str(zipfilepath), "r") as zfile: + # move `control_data` code here and replace existing function. + cdata = control_data(zfile) + return { + **cdata, + **{ + ftype: ([cdata[ftype]] + if isinstance(cdata[ftype], str) + else cdata[ftype]) + for ftype in FILE_TYPES + if bool(cdata.get(ftype)) + } + } |