From a4313e2cc0f8548946186838a4ce67e358e46bbe Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 10 Jan 2024 08:00:25 +0300 Subject: Provide convenience functions to avoid subtle call errors --- r_qtl/r_qtl2.py | 5 +++++ scripts/rqtl2/install_genotypes.py | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py index d8231bb..b2a7acf 100644 --- a/r_qtl/r_qtl2.py +++ b/r_qtl/r_qtl2.py @@ -289,3 +289,8 @@ def validate_bundle(zfile: ZipFile): __member_exists_p__(zfile, cdata["cross_info"]["file"]) except KeyError as kerr: raise InvalidFormat(*kerr.args) from kerr + +def genotype_data(zfile: ZipFile): + """Convenience function to genotype data from R/qtl2 bundle.""" + cdata = control_data(zfile) + return file_data(zfile, "geno", cdata, *make_process_data_geno(cdata)) diff --git a/scripts/rqtl2/install_genotypes.py b/scripts/rqtl2/install_genotypes.py index a555d46..6ae3788 100644 --- a/scripts/rqtl2/install_genotypes.py +++ b/scripts/rqtl2/install_genotypes.py @@ -132,11 +132,7 @@ def install_genotypes(dbconn: mdb.Connection, logger.info(("Loading genotypes. This could take a while. " "Please be patient.")) - cdata = rqtl2.control_data(zfile) - genotypes = rqtl2.file_data(zfile, - "geno", - cdata, - rqtl2.make_process_data_geno(cdata)) + genotypes = rqtl2.genotype_data(zfile) while True: batch = tuple(take(genotypes, 5000)) if len(batch) == 0: -- cgit v1.2.3