mkt.databases.ncbi

Client for NCBI Entrez protein records.

Provides ProteinNCBI (and the ProteinEntrez helper) to retrieve protein sequence and metadata from NCBI Entrez.

Classes

ProteinEntrez(accession[, email])

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

ProteinNCBI(accession, url, annotation, ...)

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

class mkt.databases.ncbi.ProteinEntrez(accession: str, email: str | None = None)[source]

Bases: object

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

accession: str

Accession ID for the protein.

email: str | None = None

Email address for the user; may be necessary to prevent blocking of access in case of excessive usage.

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.

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.