diff options
author | Frederick Muriuki Muriithi | 2024-02-05 12:11:43 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-02-05 12:11:43 +0300 |
commit | 949ea71eb721a3f5bdff3ba10f7dd7c70899d560 (patch) | |
tree | 5ea0674953489ce83ffa11c2b689d3c8e31ebede | |
parent | ab71b34b97f3f1eee52b5688f41644541535f281 (diff) | |
download | gn-uploader-949ea71eb721a3f5bdff3ba10f7dd7c70899d560.tar.gz |
Fix linting and type errors.
-rw-r--r-- | qc_app/upload/rqtl2.py | 1 | ||||
-rw-r--r-- | r_qtl/r_qtl2_qc.py | 16 | ||||
-rw-r--r-- | scripts/rqtl2/install_genotypes.py | 3 | ||||
-rw-r--r-- | scripts/rqtl2/install_phenos.py | 3 | ||||
-rw-r--r-- | tests/r_qtl/test_r_qtl2_qc.py | 3 |
5 files changed, 13 insertions, 13 deletions
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index 2d032f8..73d91ec 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -18,7 +18,6 @@ from flask import ( current_app as app) from r_qtl import r_qtl2 -from r_qtl import errors as rqe from r_qtl import r_qtl2_qc as rqc from r_qtl.errors import InvalidFormat diff --git a/r_qtl/r_qtl2_qc.py b/r_qtl/r_qtl2_qc.py index 261d300..853c34b 100644 --- a/r_qtl/r_qtl2_qc.py +++ b/r_qtl/r_qtl2_qc.py @@ -7,23 +7,23 @@ from r_qtl import errors as rqe from r_qtl import r_qtl2 as rqtl2 from r_qtl.r_qtl2 import __FILE_TYPES__ -def bundle_files_list(zfile, cdata: dict) -> tuple[str]: +def bundle_files_list(cdata: dict) -> tuple[str, ...]: """Retrieve files listed in control file.""" def __merge__(alist: tuple[str, ...], member: Union[str, Sequence[str]]) -> tuple[str, ...]: if isinstance(cdata[member], str): return alist + (cdata[member],) return alist + tuple(cdata[member]) - fileslist = tuple() - fileslist = reduce(__merge__, - (key for key in cdata.keys() if key in __FILE_TYPES__), - tuple()) + fileslist: tuple[str, ...] = reduce( + __merge__, + (key for key in cdata.keys() if key in __FILE_TYPES__), + tuple()) if "file" in cdata.get("sex", {}): sexfile = cdata["sex"]["file"] fileslist = fileslist + ( (sexfile,) if isinstance(sexfile, str) else tuple(sexfile)) - + if "file" in cdata.get("cross_info", {}): crossinfofile = cdata["cross_info"]["file"] fileslist = fileslist + ( @@ -32,7 +32,7 @@ def bundle_files_list(zfile, cdata: dict) -> tuple[str]: return fileslist -def missing_files(zfile: ZipFile) -> tuple[str]: +def missing_files(zfile: ZipFile) -> tuple[str, ...]: """ Retrieve a list of files listed in the control file that do not exist in the bundle. @@ -45,7 +45,7 @@ def missing_files(zfile: ZipFile) -> tuple[str]: return True return tuple(filter(__missing_p__, - bundle_files_list(zfile, rqtl2.control_data(zfile)))) + bundle_files_list(rqtl2.control_data(zfile)))) def validate_bundle(zfile: ZipFile): """Ensure the R/qtl2 bundle is valid.""" diff --git a/scripts/rqtl2/install_genotypes.py b/scripts/rqtl2/install_genotypes.py index bfe17b8..7f3f65a 100644 --- a/scripts/rqtl2/install_genotypes.py +++ b/scripts/rqtl2/install_genotypes.py @@ -11,6 +11,7 @@ import MySQLdb as mdb from MySQLdb.cursors import DictCursor from r_qtl import r_qtl2 as rqtl2 +from r_qtl import r_qtl2_qc as rqc from functional_tools import take @@ -166,7 +167,7 @@ def install_genotypes(#pylint: disable=[too-many-arguments, too-many-locals] with ZipFile(str(rqtl2bundle.absolute()), "r") as zfile: try: logger.info("Validating bundle") - rqtl2.validate_bundle(zfile) + rqc.validate_bundle(zfile) logger.info("Bundle validated successfully.") logger.info(("Loading genotypes. This could take a while. " "Please be patient.")) diff --git a/scripts/rqtl2/install_phenos.py b/scripts/rqtl2/install_phenos.py index a6cdacc..95745d7 100644 --- a/scripts/rqtl2/install_phenos.py +++ b/scripts/rqtl2/install_phenos.py @@ -14,6 +14,7 @@ from scripts.rqtl2.cli_parser import add_common_arguments from scripts.cli_parser import init_cli_parser, add_global_data_arguments from r_qtl import r_qtl2 as rqtl2 +from r_qtl import r_qtl2_qc as rqc from functional_tools import take @@ -102,7 +103,7 @@ def install_pheno_files(#pylint: disable=[too-many-arguments, too-many-locals] """Load data in `pheno` files and other related files into the database.""" with ZipFile(str(rqtl2bundle), "r") as zfile: try: - rqtl2.validate_bundle(zfile) + rqc.validate_bundle(zfile) logger.info("R/qtl2 bundle validated successfully.") cdata = rqtl2.control_data(zfile) diff --git a/tests/r_qtl/test_r_qtl2_qc.py b/tests/r_qtl/test_r_qtl2_qc.py index 5fcccf5..9b19ae2 100644 --- a/tests/r_qtl/test_r_qtl2_qc.py +++ b/tests/r_qtl/test_r_qtl2_qc.py @@ -47,8 +47,7 @@ def test_bundle_files_list(filepath, expected): THEN: verify that ALL files listed in the control file are returned. """ with ZipFile(Path(filepath).absolute(), "r") as zfile: - assert qc.bundle_files_list( - zfile, rqtl2.control_data(zfile)) == expected + assert qc.bundle_files_list(rqtl2.control_data(zfile)) == expected @pytest.mark.unit_test @pytest.mark.parametrize( |