core.lib.pgsexceptions

This module defines a custom PGS exception hierarchy.

This module overrides sys.excepthook. Uncaught exceptions are intercepted, and sys.exit() is called with a custom code. This can be helpful to debug problems in other applications, because there are relatively few failure states.

The hierarchy:

  • BasePGSException

    • MatchError

      • DuplicateMatchError

      • MatchRateError

      • ZeroMatchesError

      • MatchValueError

    • CombineError

      • BuildError

      • ScoreFormatError

      • LiftoverError

    • CatalogError

      • ScoreDownloadError

      • ScoreChecksumError

      • QueryError

      • InvalidAccessionError

    • SamplesheetError

      • GenomesNotFound

      • SamplesheetFormatError

Exceptions

BasePGSException

The base class from which all PGS errors must inherit.

BuildError

Raised when there's a problem with a scoring file genome build.

CatalogError

The base class for errors when querying or downloading from the PGS Catalog

CombineError

The base class for errors that are raised when combining scorefiles

DuplicateMatchError

Raised when a matched variant has been duplicated, so that a variant with the same ID

EffectTypeError

Raised when non-supported effect types are present

GenomesNotFound

Raised when FileNotFound

InvalidAccessionError

Raised when an invalid term is used to query the Catalog

LiftoverError

Raised when liftover has failed to convert genomic coordinates well

MatchError

The base class for errors that are raised during variant matching

MatchRateError

Raised when match rate is below match threshold for one or more scoring files

MatchValueError

Raised when a match function receives inappropriate values.

QueryError

Raised when the Catalog API doesn't return a valid response

SamplesheetError

The base class for errors related to samplesheet parsing

SamplesheetFormatError

Raised when a samplesheet is badly formatted

ScoreChecksumError

Raised when a scoring file fails checksum validation

ScoreDownloadError

Raised when a scoring file can't be downloaded

ScoreFormatError

Raised when there's a problem with a scoring file.

ZeroMatchesError

Raised when zero matches are found for one or more scoring files.

Classes

ExceptionExitCodeMap

A read only map to get exit codes for custom exceptions

Functions

handle_uncaught_exception(→ None)

Intercept BasePGSExceptions and trigger sys.exit with a custom code

Module Contents

exception core.lib.pgsexceptions.BasePGSException(message: str)

The base class from which all PGS errors must inherit. The purpose of this class is to simplify finding PGS exceptions and exiting python with a matching custom exit code.

exception core.lib.pgsexceptions.BuildError(message: str)

Raised when there’s a problem with a scoring file genome build.

exception core.lib.pgsexceptions.CatalogError(message: str)

The base class for errors when querying or downloading from the PGS Catalog

exception core.lib.pgsexceptions.CombineError(message: str)

The base class for errors that are raised when combining scorefiles

exception core.lib.pgsexceptions.DuplicateMatchError(message: str)

Raised when a matched variant has been duplicated, so that a variant with the same ID would be split across two rows in an output scoring file.

exception core.lib.pgsexceptions.EffectTypeError(message: str)

Raised when non-supported effect types are present

exception core.lib.pgsexceptions.GenomesNotFound(message: str)

Raised when FileNotFound

exception core.lib.pgsexceptions.InvalidAccessionError(message: str)

Raised when an invalid term is used to query the Catalog

exception core.lib.pgsexceptions.LiftoverError(message: str)

Raised when liftover has failed to convert genomic coordinates well

exception core.lib.pgsexceptions.MatchError(message: str)

The base class for errors that are raised during variant matching

exception core.lib.pgsexceptions.MatchRateError(message: str)

Raised when match rate is below match threshold for one or more scoring files

exception core.lib.pgsexceptions.MatchValueError(message: str)

Raised when a match function receives inappropriate values.

e.g., Multiple chromosomes detected in variant data but data is split per-chromosome

exception core.lib.pgsexceptions.QueryError(message: str)

Raised when the Catalog API doesn’t return a valid response

exception core.lib.pgsexceptions.SamplesheetError(message: str)

The base class for errors related to samplesheet parsing

exception core.lib.pgsexceptions.SamplesheetFormatError(message: str)

Raised when a samplesheet is badly formatted

exception core.lib.pgsexceptions.ScoreChecksumError(message: str)

Raised when a scoring file fails checksum validation

exception core.lib.pgsexceptions.ScoreDownloadError(message: str)

Raised when a scoring file can’t be downloaded

exception core.lib.pgsexceptions.ScoreFormatError(message: str)

Raised when there’s a problem with a scoring file.

exception core.lib.pgsexceptions.ZeroMatchesError(message: str)

Raised when zero matches are found for one or more scoring files.

Distinct from MatchRateError because it’s very common, and caused by bad input data or parameters.

class core.lib.pgsexceptions.ExceptionExitCodeMap

A read only map to get exit codes for custom exceptions

code_map
core.lib.pgsexceptions.handle_uncaught_exception(exctype: type[BaseException], value: BaseException, trace: types.TracebackType | None) None

Intercept BasePGSExceptions and trigger sys.exit with a custom code