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:
RESTAPIClientClass 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 URL for NCBI Protein API query.
process_fasta(str_fasta)Process downloaded FASTA file or string into headers and sequences.
Attributes
__dataclass_fields____dataclass_params____match_args____pydantic_config__FASTA_UNSPECIFIED ┃ FASTA_GENE ┃ FASTA_RNA ┃ FASTA_PROTEIN ┃ FASTA_GENE_FLANK ┃ FASTA_CDS ┃ FASTA_5P_UTR ┃ FASTA_3P_UTR.
from_cacheWhether the most recent response was served from requests-cache.
Header for the API request.
query_datetimeUTC datetime the underlying network query was made (cache creation time if served from cache).
FASTA string downloaded from NCBI.
URL for the NCBI Protein API.
Accession ID for the protein.
List of FASTA headers.
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
- 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.
- 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.