Exceptions¶
FinaleToolkit raises informative, typed exceptions. Each one also subclasses the
built-in exception it replaces (ValueError, FileNotFoundError, or
IndexError), so existing except ValueError: / except FileNotFoundError:
handlers continue to catch them.
Informative exception hierarchy for FinaleToolkit.
Every exception below subclasses a built-in exception type (ValueError,
FileNotFoundError, IndexError …) in addition to
FinaleToolkitError. This keeps the library a strict drop-in for the
original package: existing except ValueError/except FileNotFoundError
handlers continue to catch these errors, while new code can catch the more
specific FinaleToolkitError subclasses or test for them by type.
Examples
>>> from finaletoolkit.exceptions import UnsupportedFormatError
>>> try:
... raise UnsupportedFormatError("not a bam")
... except ValueError: # still works -- UnsupportedFormatError is a ValueError
... print("caught")
caught
- exception finaletoolkit.exceptions.FinaleToolkitError[source]¶
Bases:
ExceptionBase class for all FinaleToolkit-specific errors.
- exception finaletoolkit.exceptions.InvalidInputError[source]¶
Bases:
FinaleToolkitError,ValueErrorRaised when user-supplied input is malformed or inconsistent.
Subclasses
ValueErrorfor backwards compatibility.
- exception finaletoolkit.exceptions.UnsupportedFormatError[source]¶
Bases:
InvalidInputErrorRaised when an input file is in a format the toolkit cannot read.
- exception finaletoolkit.exceptions.MissingReferenceError[source]¶
Bases:
InvalidInputErrorRaised when a reference genome is required but not provided.
For example, CRAM input requires a FASTA reference.
- exception finaletoolkit.exceptions.MissingIndexError[source]¶
Bases:
FinaleToolkitError,FileNotFoundErrorRaised when a required index (
.bai/.crai/.tbi/.fai) is missing. SubclassesFileNotFoundError.
- exception finaletoolkit.exceptions.ContigNotFoundError[source]¶
Bases:
InvalidInputErrorRaised when a requested contig is absent from a reference or alignment.
- exception finaletoolkit.exceptions.ContigMismatchError[source]¶
Bases:
InvalidInputErrorRaised when contigs (names or sizes) of two files are incompatible.
- exception finaletoolkit.exceptions.OutOfBoundsError[source]¶
Bases:
InvalidInputError,IndexErrorRaised when a queried interval falls outside chromosome bounds.
Subclasses both
ValueError(viaInvalidInputError) andIndexErrorso that either handler catches it.