From 6ff9544df0d49540b65f6f9ee4a138f7f4284683 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 2 Feb 2024 15:09:34 +0300 Subject: List file types in a single place for easier reuse --- r_qtl/r_qtl2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py index 9127dce..c2828d2 100644 --- a/r_qtl/r_qtl2.py +++ b/r_qtl/r_qtl2.py @@ -12,6 +12,10 @@ from functional_tools import take, chain from r_qtl.errors import InvalidFormat +__FILE_TYPES__ = ( + "geno", "founder_geno", "pheno", "covar", "phenocovar", "gmap", "pmap", + "phenose") + def control_data(zfile: ZipFile) -> dict: """Retrieve the control file from the zip file info.""" files = tuple(filename @@ -29,9 +33,7 @@ def control_data(zfile: ZipFile) -> dict: "comment.char": "#", "sep": ",", **{ - f"{key}_transposed": False for key in ( - "geno", "founder_geno", "pheno", "covar", "phenocovar", "gmap", - "pmap", "phenose") + f"{key}_transposed": False for key in __FILE_TYPES__ }, **(json.loads(zfile.read(files[0])) if files[0].endswith(".json") @@ -297,9 +299,7 @@ def validate_bundle(zfile: ZipFile): zfile.getinfo(inner) try: - for member in (key for key in cdata.keys() if key in ( - "geno", "founder_geno", "pheno", "covar", "phenocovar", "gmap", - "pmap")): + for member in (key for key in cdata.keys() if key in __FILE_TYPES__): __member_exists_p__(zfile, cdata[member]) if "file" in cdata.get("sex", {}): -- cgit v1.2.3