mkt.databases.ncbi.ProteinNCBI

class mkt.databases.ncbi.ProteinNCBI(accession: str, url: str = 'https://api.ncbi.nlm.nih.gov/datasets/v2/protein/accession/<ACC>/download?', annotation: str | None = 'FASTA_PROTEIN', headers: str = "{'Accept': 'application/zip'}", str_fasta: str | None = None, list_headers: list[str | None] = <factory>, list_seq: list[str | None] = <factory>)[source]

Bases: RESTAPIClient

Class to interact with query NCBI Protein API; only FASTA download supported.

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

Methods

__eq__(other)

Return self==value.

__post_init__()

_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 NCBI Protein API query.

process_fasta(str_fasta)

Process downloaded FASTA file or string into headers and sequences.

query_api()

Attributes

__dataclass_fields__

__dataclass_params__

__match_args__

__pydantic_config__

annotation

FASTA_UNSPECIFIED ┃ FASTA_GENE ┃ FASTA_RNA ┃ FASTA_PROTEIN ┃ FASTA_GENE_FLANK ┃ FASTA_CDS ┃ FASTA_5P_UTR ┃ FASTA_3P_UTR.

from_cache

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

headers

Header for the API request.

query_datetime

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

str_fasta

FASTA string downloaded from NCBI.

url

URL for the NCBI Protein API.

accession

Accession ID for the protein.

list_headers

List of FASTA headers.

list_seq

List of FASTA sequences.

accession: str

Accession ID for the protein.

annotation: str | None = 'FASTA_PROTEIN'

FASTA_UNSPECIFIED ┃ FASTA_GENE ┃ FASTA_RNA ┃ FASTA_PROTEIN ┃ FASTA_GENE_FLANK ┃ FASTA_CDS ┃ FASTA_5P_UTR ┃ FASTA_3P_UTR.

Type:

Annotation type to include in the download

create_query_url()[source]

Create URL for NCBI Protein API query.

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

Header for the API request.

list_headers: list[str | None]

List of FASTA headers.

list_seq: list[str | None]

List of FASTA sequences.

static process_fasta(str_fasta: str) tuple[list[str], list[str]][source]

Process downloaded FASTA file or string into headers and sequences.

Parameters:

str_fastastr

FASTA string to process.

Returns:

tuple[list[str], list[str]]

Lists of FASTA headers and sequences.

query_api() dict[source]
str_fasta: str | None = None

FASTA string downloaded from NCBI.

url: str = 'https://api.ncbi.nlm.nih.gov/datasets/v2/protein/accession/<ACC>/download?'

URL for the NCBI Protein API.