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: Exception

Base class for all FinaleToolkit-specific errors.

exception finaletoolkit.exceptions.InvalidInputError[source]

Bases: FinaleToolkitError, ValueError

Raised when user-supplied input is malformed or inconsistent.

Subclasses ValueError for backwards compatibility.

exception finaletoolkit.exceptions.UnsupportedFormatError[source]

Bases: InvalidInputError

Raised when an input file is in a format the toolkit cannot read.

exception finaletoolkit.exceptions.MissingReferenceError[source]

Bases: InvalidInputError

Raised when a reference genome is required but not provided.

For example, CRAM input requires a FASTA reference.

exception finaletoolkit.exceptions.MissingIndexError[source]

Bases: FinaleToolkitError, FileNotFoundError

Raised when a required index (.bai/.crai/.tbi/.fai) is missing. Subclasses FileNotFoundError.

exception finaletoolkit.exceptions.ContigNotFoundError[source]

Bases: InvalidInputError

Raised when a requested contig is absent from a reference or alignment.

exception finaletoolkit.exceptions.ContigMismatchError[source]

Bases: InvalidInputError

Raised when contigs (names or sizes) of two files are incompatible.

exception finaletoolkit.exceptions.OutOfBoundsError[source]

Bases: InvalidInputError, IndexError

Raised when a queried interval falls outside chromosome bounds.

Subclasses both ValueError (via InvalidInputError) and IndexError so that either handler catches it.