mkt.databases.uniprot.UniProtFASTA

class mkt.databases.uniprot.UniProtFASTA(uniprot_id: str, url: str = 'https://rest.uniprot.org/uniprotkb', url_fasta: str | None = None, _header: str | None = None, _sequence: str | None = None)[source]

Bases: UniProt, RESTAPIClient

Class to interact UniProt API for FASTA download.

__init__(uniprot_id: str, url: str = 'https://rest.uniprot.org/uniprotkb', url_fasta: str | None = None, _header: str | None = None, _sequence: str | None = None) None

Methods

__eq__(other)

Return self==value.

__init__(uniprot_id[, url, url_fasta, ...])

__post_init__()

_convert_fasta2seq(str_fasta)

Convert FASTA sequence to string sequence (i.e., remove header line breaks).

_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.

query_api([bool_seq])

Get FASTA sequence for UniProt ID.

set_url()

Set URL for UniProt API; UniProtKB if SwissProt or Unisave if TrEMBL.

Attributes

__dataclass_fields__

__dataclass_params__

__match_args__

_header

FASTA header.

_sequence

FASTA sequence.

from_cache

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

query_datetime

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

url

URL for the UniProt API.

url_fasta

URL for the UniProt FASTA API including UniProt ID.

uniprot_id

UniProt ID.

__init__(uniprot_id: str, url: str = 'https://rest.uniprot.org/uniprotkb', url_fasta: str | None = None, _header: str | None = None, _sequence: str | None = None) None
static _convert_fasta2seq(str_fasta) tuple[str, str][source]

Convert FASTA sequence to string sequence (i.e., remove header line breaks).

Parameters:

str_fasta (str) – FASTA string (including header and line breaks)

Returns:

header, seq – FASTA header and sequence strings (excluding line breaks)

Return type:

tuple[str, str]

query_api(bool_seq: bool = True) str | None[source]

Get FASTA sequence for UniProt ID.

Parameters:

bool_seq (bool) – If True, return sequence string only (i.e., no header or line breaks); otherwise return full FASTA string

Returns:

FASTA sequences for UniProt ID; None if request fails

Return type:

str | None

set_url()[source]

Set URL for UniProt API; UniProtKB if SwissProt or Unisave if TrEMBL.

uniprot_id: str

UniProt ID.

url_fasta: str | None = None

URL for the UniProt FASTA API including UniProt ID.