freqsap.uniprot

Module for interacting with the UniProt API.

Classes

UniProt

Interface to the UniProt protein database API.

Module Contents

class freqsap.uniprot.UniProt(timeout: int = 3)[source]

Bases: freqsap.interfaces.ProteinVariantAPI

Interface to the UniProt protein database API.

Provides methods to query protein information and variations from UniProt.

_params[source]
_headers[source]
_timeout = 3[source]
get(accession: freqsap.accession.Accession) freqsap.protein.Protein[source]

Retrieve protein and its variations from UniProt.

Parameters:

accession (Accession) – The protein accession identifier.

Returns:

The protein object with its variations.

Return type:

Protein

query(accession: str) dict[source]

Query UniProt for protein data.

Parameters:

accession (str) – The protein accession identifier.

Returns:

JSON response from UniProt API.

Return type:

dict

Raises:

requests.HTTPError – If the request fails.

parse(feature: dict) freqsap.variation.Variation | None[source]

Parse a feature dictionary to extract variation information.

Parameters:

feature (dict) – Feature dictionary from UniProt response.

Returns:

Variation object if a valid dbSNP reference is found, None otherwise.

Return type:

Variation | None

request(url: str) requests.Response[source]

Make an HTTP GET request to UniProt.

Parameters:

url (str) – The URL to request.

Returns:

The HTTP response.

Return type:

requests.Response

is_dbsnp(xref: dict) bool[source]

Check if a cross-reference is a dbSNP reference.

Parameters:

xref (dict) – Cross-reference dictionary.

Returns:

True if the reference is from dbSNP and starts with ‘rs’, False otherwise.

Return type:

bool

available() bool[source]

Check if the UniProt API is available.

Returns:

True if the service is available, False otherwise.

Return type:

bool