freqsap.ebi

Module for interacting with the EBI Proteins API.

Classes

EBI

Class to access the EBI protein API.

Functions

_get_dbsnp_id(→ str | None)

Parse dbSNP id from the xrefs entry. Private function.

_check_response(→ None)

Check the response for the accession for errors.

_get_variants(→ Generator[freqsap.variation.Variation])

Extract variations from EBI API response.

Module Contents

class freqsap.ebi.EBI(timeout: int = 3)[source]

Bases: freqsap.interfaces.ProteinVariantAPI

Class to access the EBI protein API.

_headers[source]
_timeout = 3[source]
_request(url: str) requests.Response[source]

Private function to submit requests.

Parameters:

url (str) – Base URL to query.

Returns:

Response returned by the server.

Return type:

requests.Response

available() bool[source]

Check whether the service is available.

Returns:

True if service is available, False otherwise.

Return type:

bool

get(accession: freqsap.accession.Accession) freqsap.protein.Protein[source]

Get the protein represented by the Accession.

Parameters:

accession (Accession) – Accession of the Protein.

Returns:

Protein specified by the accession.

Return type:

Protein

freqsap.ebi._get_dbsnp_id(xrefs: list[dict]) str | None[source]

Parse dbSNP id from the xrefs entry. Private function.

Parameters:

xrefs (list[dict]) – List of xrefs specified in the protein.

Returns:

dbSNP id, if found, otherwise None.

Return type:

str | None

freqsap.ebi._check_response(accession: freqsap.accession.Accession, response: requests.Response) None[source]

Check the response for the accession for errors.

Parameters:
  • accession (Accession) – Accession which was searched.

  • response (requests.Response) – Response obtained from the server.

Raises:
  • AccessionNotFound – Raises exception if the accession wasn’t found.

  • Raises all other exceptions raised by the requests module.

freqsap.ebi._get_variants(response: dict) Generator[freqsap.variation.Variation][source]

Extract variations from EBI API response.

Parameters:

response (dict) – JSON response from EBI API containing protein features.

Yields:

Variation – Each variation found with a valid dbSNP reference ID.