mkt.databases.protvar.ProtvarScoreQuery

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

Class 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 ProtvarVariant objects exposed via variants:

  • mut supplied -> a single variant keyed by that residue.

  • mut is 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).

__init__(*args: Any, **kwargs: Any) None

Methods

__eq__(other)

Return self==value.

__post_init__()

_build_variants()

Parse the flat score list into per-variant ProtvarVariant objects.

_stamp_from_response(res)

Record query datetime + cache provenance from a requests-cache response.

_stamp_now()

Record current UTC datetime; cache provenance unknown.

check_response(res)

Check the response status code for errors.

create_query_url()

Create URL for Protvar score API query.

get_scores()

Return all raw score dicts retained from the query.

get_variant([mt])

Return a single variant by mutant residue.

query_api()

Query the ProtVar score API and parse the response into variants.

Attributes

__dataclass_fields__

__dataclass_params__

__match_args__

__pydantic_config__

from_cache

Whether the most recent response was served from requests-cache.

mut

Mutant residue (1 or 3 letter code); optional.

query_datetime

UTC datetime the underlying network query was made (cache creation time if served from cache).

url

URL for Protvar score API query.

uniprot_id

Uniprot ID.

pos

Position in the protein where mutation resides.

header

Header for the API request.

_build_variants() None[source]

Parse the flat score list into per-variant ProtvarVariant objects.

create_query_url()[source]

Create URL for Protvar score API query.

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.

query_api() None[source]

Query the ProtVar score API and parse the response into variants.

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.