mkt.databases.protvar
ProtVar API client for variant pathogenicity scores.
Provides ProtvarScoreQuery and the ProtvarVariant model for
retrieving variant pathogenicity scores, with a ScoreDatabase enumeration of
supported score sources.
Module Attributes
Key holding the numeric score within each database's score dict; databases absent from this mapping (e.g. popEVE) have no single scalar score. |
|
Key holding the categorical classification; only EVE and AlphaMissense have one. |
|
Variant-level databases (one score per substitution); Conservation is excluded as it is residue- rather than variant-level. |
Functions
|
Coerce a ScoreDatabase or its value (e.g. "AM") to a ScoreDatabase, or None. |
Classes
|
Class to interact with the ProtVar score API. |
|
Scores for a single variant (one mutant residue) at a position. |
|
Enum class to define the score databases returned by ProtVar. |
- mkt.databases.protvar.DICT_CLASS_KEY = {ScoreDatabase.AlphaMissense: 'amClass', ScoreDatabase.EVE: 'eveClass'}
Key holding the categorical classification; only EVE and AlphaMissense have one.
- Type:
dict[ScoreDatabase, str]
- mkt.databases.protvar.DICT_SCORE_KEY = {ScoreDatabase.AlphaMissense: 'amPathogenicity', ScoreDatabase.Conservation: 'score', ScoreDatabase.ESM1b: 'score', ScoreDatabase.EVE: 'score'}
Key holding the numeric score within each database’s score dict; databases absent from this mapping (e.g. popEVE) have no single scalar score.
- Type:
dict[ScoreDatabase, str]
- class mkt.databases.protvar.ProtvarScoreQuery(uniprot_id: str, pos: int, mut: str | None = None, url: str = 'https://www.ebi.ac.uk/ProtVar/api/score/<UNIPROT>/<POS>?mt=<MUT>', header: dict = <factory>)[source]
Bases:
RESTAPIClientClass to interact with the ProtVar score API.
A single query returns scores for every available database (Conservation, EVE, ESM1b, AlphaMissense, popEVE). The response is parsed into
ProtvarVariantobjects exposed viavariants:mutsupplied -> a single variant keyed by that residue.mutis None -> one variant per possible substitution (keyed by residue).
Residue identity for the variant-level databases is recovered from popEVE, the only database whose payload carries the mutant residue (
mt).- get_scores() list[dict] | None[source]
Return all raw score dicts retained from the query.
- Returns:
All score dicts returned by the api, or None if the query failed.
- Return type:
list[dict] | None
- get_variant(mt: str | None = None) ProtvarVariant | None[source]
Return a single variant by mutant residue.
- Parameters:
mt (str | None, optional) – Mutant residue to retrieve. If None and the query targeted a single variant, that sole variant is returned; otherwise None.
- Returns:
The requested variant, or None if absent.
- Return type:
ProtvarVariant | None
- header: dict
Header for the API request.
- mut: str | None = None
Mutant residue (1 or 3 letter code); optional. If None, scores for every possible substitution at this position are returned.
- pos: int
Position in the protein where mutation resides.
- uniprot_id: str
Uniprot ID.
- url: str = 'https://www.ebi.ac.uk/ProtVar/api/score/<UNIPROT>/<POS>?mt=<MUT>'
URL for Protvar score API query.
- class mkt.databases.protvar.ProtvarVariant(mt: str | None, scores: dict = <factory>)[source]
Bases:
objectScores for a single variant (one mutant residue) at a position.
Built by
ProtvarScoreQuery; holds the raw per-database score dict for this variant and exposes scalar accessors. Conservation, which is residue- rather than variant-level, is shared across all variants at the position.- get_classification(database: ScoreDatabase | str)[source]
Return the categorical classification for a database, or None.
- Parameters:
database (ScoreDatabase | str) – Database to retrieve, as a ScoreDatabase member or its value (e.g. “AM”).
- Returns:
The classification (“eveClass” for EVE, “amClass” for AlphaMissense); None for databases without one (Conservation, ESM1b, popEVE) or when the database is absent for this variant.
- Return type:
str | None
- get_popeve() dict | None[source]
Return the standalone popEVE payload for this variant, or None.
- Returns:
The full popEVE score dict (multiple keys, retained verbatim), or None if popEVE was not returned for this variant.
- Return type:
dict | None
- get_score(database: ScoreDatabase | str)[source]
Return the numeric score for a database, or None if not present.
- Parameters:
database (ScoreDatabase | str) – Database to retrieve, as a ScoreDatabase member or its value (e.g. “AM”).
- Returns:
The score (“score” for Conservation/EVE/ESM1b, “amPathogenicity” for AlphaMissense); None for popEVE (use
get_popeve()) or when the database is absent for this variant.- Return type:
float | None
- mt: str | None
Mutant residue (1-letter code) this variant represents; None if unknown.
- scores: dict
Mapping of ScoreDatabase to its raw score dict for this variant.
- class mkt.databases.protvar.ScoreDatabase(value)[source]
Bases:
str,EnumEnum class to define the score databases returned by ProtVar.
- AlphaMissense = 'AM'
- Conservation = 'CONSERV'
- ESM1b = 'ESM'
- EVE = 'EVE'
- popEVE = 'POPEVE'
- mkt.databases.protvar.TUPLE_VARIANT_DATABASES = (ScoreDatabase.EVE, ScoreDatabase.ESM1b, ScoreDatabase.AlphaMissense, ScoreDatabase.popEVE)
Variant-level databases (one score per substitution); Conservation is excluded as it is residue- rather than variant-level.
- Type:
tuple[ScoreDatabase, …]
- mkt.databases.protvar._coerce_database(database: ScoreDatabase | str | None) ScoreDatabase | None[source]
Coerce a ScoreDatabase or its value (e.g. “AM”) to a ScoreDatabase, or None.