From 321cb85283dc0a182e86d0ee509cae9ced4e39cd Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 9 Aug 2024 14:20:17 -0500 Subject: Rename module: Module contains exceptions classes. --- r_qtl/errors.py | 13 ------------- r_qtl/exceptions.py | 13 +++++++++++++ r_qtl/r_qtl2.py | 6 +++--- r_qtl/r_qtl2_qc.py | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 r_qtl/errors.py create mode 100644 r_qtl/exceptions.py (limited to 'r_qtl') diff --git a/r_qtl/errors.py b/r_qtl/errors.py deleted file mode 100644 index 417eb58..0000000 --- a/r_qtl/errors.py +++ /dev/null @@ -1,13 +0,0 @@ -"""R/qtl and R/qtl2 error types.""" - -class RQTLError(Exception): - """Base class for R/qtl and R/qtl2 errors.""" - -class InvalidFormat(RQTLError): - """Raised when the format of the file(s) is invalid.""" - -class MissingFileError(InvalidFormat): - """ - Raise when at least one file listed in the control file is missing from the - R/qtl2 bundle. - """ diff --git a/r_qtl/exceptions.py b/r_qtl/exceptions.py new file mode 100644 index 0000000..9620cf4 --- /dev/null +++ b/r_qtl/exceptions.py @@ -0,0 +1,13 @@ +"""R/qtl and R/qtl2 error types.""" + +class RQTLError(Exception): + """Base class for R/qtl and R/qtl2 errors.""" + +class InvalidFormat(RQTLError): + """Raised when the format of the file(s) is invalid.""" + +class MissingFileException(InvalidFormat): + """ + Raise when at least one file listed in the control file is missing from the + R/qtl2 bundle. + """ diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py index c2e1148..c6282c5 100644 --- a/r_qtl/r_qtl2.py +++ b/r_qtl/r_qtl2.py @@ -11,7 +11,7 @@ import yaml from functional_tools import take, chain -from r_qtl.errors import InvalidFormat, MissingFileError +from r_qtl.exceptions import InvalidFormat, MissingFileException FILE_TYPES = ( "geno", "founder_geno", "pheno", "covar", "phenocovar", "gmap", "pmap", @@ -157,7 +157,7 @@ def control_data(control_src: Union[Path, ZipFile]) -> dict: Raises ------ - r_qtl.errors.InvalidFormat + r_qtl.exceptions.InvalidFormat """ if isinstance(control_src, ZipFile): return __control_data_from_zipfile__(control_src) @@ -382,7 +382,7 @@ def file_data(zfile: ZipFile, zfile, member_key, cdata, process_transposed_value): yield row except KeyError as exc: - raise MissingFileError(*exc.args) from exc + raise MissingFileException(*exc.args) from exc def cross_information(zfile: ZipFile, cdata: dict) -> Iterator[dict]: """Load cross information where present.""" diff --git a/r_qtl/r_qtl2_qc.py b/r_qtl/r_qtl2_qc.py index be1eac4..7e93d23 100644 --- a/r_qtl/r_qtl2_qc.py +++ b/r_qtl/r_qtl2_qc.py @@ -3,8 +3,8 @@ from zipfile import ZipFile from functools import reduce, partial from typing import Union, Iterator, Optional, Callable -from r_qtl import errors as rqe from r_qtl import r_qtl2 as rqtl2 +from r_qtl import exceptions as rqe from r_qtl.r_qtl2 import FILE_TYPES from r_qtl.fileerrors import MissingFile @@ -59,7 +59,7 @@ def validate_bundle(zfile: ZipFile): """Ensure the R/qtl2 bundle is valid.""" missing = missing_files(zfile) if len(missing) > 0: - raise rqe.MissingFileError( + raise rqe.MissingFileException( "The following files do not exist in the bundle: " + ", ".join(mfile[1] for mfile in missing)) @@ -111,6 +111,6 @@ def retrieve_errors(zfile: ZipFile, filetype: str, checkers: tuple[Callable]) -> if value is not None: for checker in checkers: yield checker(lineno=lineno, field=field, value=value) - except rqe.MissingFileError: + except rqe.MissingFileException: fname = cdata.get(filetype) yield MissingFile(filetype, fname, f"Missing '{filetype}' file '{fname}'.") -- cgit v1.2.3