Search NCBI databases with Biopython's Bio.Entrez (ESearch, EInfo, EGQuery, ESpell). The skill emphasizes the parts of the API that bite real users: the Entrez Query Translator rewriting unqualified queries, the 9,999 silent cap on non-history responses, history-server semantics (8-hour TTL, idle eviction, QueryKey chaining), [Organism] taxonomy walks, and the weekly index lag that breaks 'I just submitted my data' expectations.
pip install biopython
Set the required Entrez identifiers globally:
from Bio import Entrez
Entrez.email = 'researcher@institution.edu'
Entrez.api_key = 'optional_api_key' # raises rate from 3 to 10 req/sec
Get an API key at https://www.ncbi.nlm.nih.gov/account/settings/. Without it, the 3 req/sec ceiling makes any non-trivial workflow painful.
"Search PubMed for 2024 papers on tumor-mutational-burden in non-small-cell lung cancer. Print the QueryTranslation so I can lock the exact field-qualified rewrite into my code, then return the count and first 100 PMIDs."
"Find every RefSeq mRNA for Homo sapiens. The total is large -- use the history server (usehistory='y') so downstream EFetch can pull in chunks without re-sending IDs."
"I have the gene symbol DDX3X. Use EGQuery to show which NCBI databases contain records mentioning it, then drill into the gene database with a field-qualified search to get the canonical Gene UID."
"Find PubMed records about 'BRCA1 AND breast cancer', then on the same WebEnv search 'review[PT] AND 2024[PDAT]'. Intersect QueryKey #1 AND #2 to get 2024 reviews about BRCA1 in breast cancer."
"My esearch for 'MARCH1 AND human' returned no hits. Print the QueryTranslation, then re-run with the proper field-qualified form using the HGNC-permanent symbol MARCHF1."
Entrez.email and (if available) Entrez.api_key before any call.retmax=0 first to get the count, then decide between direct retrieval and the history server based on the count.QueryTranslation so the user can verify the EQT did the right thing.gene db lookup first and use the resulting GeneID downstream -- gene symbols are unstable.[Organism] defaults to a taxonomy walk; for a single species use a binomial like Homo sapiens[ORGN]; to disable the walk use [Organism:exp].pubmed pmc[sb] not a separate db; the underlying records are PubMed UIDs.