mkt.databases.uniprot

UniProt clients for FASTA sequences and JSON records.

Provides UniProtFASTA and UniProtJSON clients (with RefSeq cross-reference support) and query_uniprotbulk_api() for bulk UniProt retrieval.

Module Attributes

DICT_UNIPROT_EVIDENCE

UniProt evidence codes mapped to descriptions.

DICT_PHOSPHO_EMPTY

Dictionary for empty phospho sites, evidence, and description.

Functions

query_uniprotbulk_api(input_ids[, term_in, ...])

Query UniProt bulk download API for list of RefSeq Protein identifiers and return DataFrame.

Classes

UniProt(uniprot_id[, url])

Class to interact with the UniProt API.

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

Class to interact UniProt API for FASTA download.

UniProtJSON(uniprot_id[, url, headers, ...])

Class to interact UniProt API for JSON download.

UniProtRefSeqProteinGET(identifier, term_in, ...)

Class to interact with UniProt API bulk download for list of RefSeqProtein identifiers via GET.

mkt.databases.uniprot.DICT_PHOSPHO_EMPTY = {'phospho_description': None, 'phospho_evidence': None, 'phospho_sites': None}

Dictionary for empty phospho sites, evidence, and description.

Type:

dict[str, None]

mkt.databases.uniprot.DICT_UNIPROT_EVIDENCE = {'ECO:0000250': 'Computational, ISS', 'ECO:0000255': 'Computational, ISM', 'ECO:0000269': 'Manual, experimental', 'ECO:0000305': 'Inferred by curator', 'ECO:0007744': 'Manual, combo'}

UniProt evidence codes mapped to descriptions.

Type:

dict[str, str]

class mkt.databases.uniprot.UniProt(uniprot_id: str, url: str = 'https://rest.uniprot.org/uniprotkb')[source]

Bases: object

Class to interact with the UniProt API.

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

UniProt ID.

url: str = 'https://rest.uniprot.org/uniprotkb'

URL for the UniProt API.

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

url_fasta: str | None = None

URL for the UniProt FASTA API including UniProt ID.

class mkt.databases.uniprot.UniProtJSON(uniprot_id: str, url: str = 'https://rest.uniprot.org/uniprotkb', headers: str = "{'Accept': 'application/json'}", _json: dict | None = None, dict_mod_res: dict | None = None)[source]

Bases: UniProt, RESTAPIClient

Class to interact UniProt API for JSON download.

__init__(uniprot_id: str, url: str = 'https://rest.uniprot.org/uniprotkb', headers: str = "{'Accept': 'application/json'}", _json: dict | None = None, dict_mod_res: dict | None = None) None
dict_mod_res: dict | None = None

Dictionary of modified residues.

extract_modified_residues()[source]

Extract modified residues from JSON.

Returns:

List of modified residues

Return type:

list[str]

headers: str = "{'Accept': 'application/json'}"

Header for the API request.

query_api() dict | None[source]

Get JSON for UniProt ID.

Returns:

JSON for UniProt ID; None if request fails

Return type:

dict | None

class mkt.databases.uniprot.UniProtRefSeqProteinGET(identifier: str, term_in: str | None, term_out: str | None, url_base: str, headers: str | None = None, polling_interval: int = 5, jobId: str | None = None)[source]

Bases: UniProtGET

Class to interact with UniProt API bulk download for list of RefSeqProtein identifiers via GET.

__init__(identifier: str, term_in: str | None, term_out: str | None, url_base: str, headers: str | None = None, polling_interval: int = 5, jobId: str | None = None) None
check_if_job_ready()[source]

Check if the job is ready and add json if so.

concatenate_json_batches()[source]

Concatenate json from batches and return as dictionary.

maybe_get_gene_names()[source]

Get list of gene names from UniProt ID and add as list_gene_names attr.

mkt.databases.uniprot.query_uniprotbulk_api(input_ids: str, term_in: str = 'RefSeq_Protein', term_out: str = 'UniProtKB', database: str = 'UniProtBULK') DataFrame[source]

Query UniProt bulk download API for list of RefSeq Protein identifiers and return DataFrame.

Parameters:

inputs_idsstr

Comma-separated string of RefSeq Protein identifiers to query UniProt API for.

term_instr

Term to query UniProt API for. Default is “RefSeq_Protein”.

term_outstr

Term to retrieve from UniProt API. Default is “UniProtKB”.

databasestr

Database to query UniProt API for. Default is “UniProtBULK”.

Returns:

pd.DataFrame

DataFrame with UniProt mapping results.