scientific-skills/Evidence Insights/biopython-entrez/SKILL.md
Use Bio.Entrez to access NCBI databases (e.g., PubMed/GenBank) for searching, fetching summaries, and downloading records when your workflow needs to call the NCBI E-utilities API over the network.
npx skillsauth add aipoch/medical-research-skills biopython-entrezInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Bio.Entrez: esearch, efetch, esummary, elink.config/task_config.json.python scripts/<task_name>.py.-- parameters; prefer config files.ensure_ascii=False for JSON output.biopython>=1.80The following example is a complete, runnable script that:
1) Create config/task_config.json:
{
"email": "[email protected]",
"api_key": "",
"db": "pubmed",
"term": "CRISPR Cas9 2020[PDAT]",
"retmax": 5,
"out_json": "outputs/pubmed_summaries.json"
}
2) Create scripts/pubmed_summaries.py:
import json
import os
import time
from typing import Any, Dict, List
from Bio import Entrez
def load_config(path: str) -> Dict[str, Any]:
with open(path, "r", encoding="utf-8") as f:
return json.load(f)
def ensure_parent_dir(path: str) -> None:
parent = os.path.dirname(path)
if parent:
os.makedirs(parent, exist_ok=True)
def main() -> None:
cfg = load_config("config/task_config.json")
Entrez.email = cfg["email"]
api_key = cfg.get("api_key") or ""
if api_key:
Entrez.api_key = api_key
db = cfg.get("db", "pubmed")
term = cfg["term"]
retmax = int(cfg.get("retmax", 20))
out_json = cfg.get("out_json", "outputs/pubmed_summaries.json")
# 1) ESearch: get IDs
with Entrez.esearch(db=db, term=term, retmax=retmax, usehistory="n") as handle:
search_result = Entrez.read(handle)
id_list: List[str] = search_result.get("IdList", [])
if not id_list:
ensure_parent_dir(out_json)
with open(out_json, "w", encoding="utf-8") as f:
json.dump({"query": term, "count": 0, "items": []}, f, ensure_ascii=False, indent=2)
return
# Be polite with NCBI: small delay (especially without API key)
time.sleep(0.34 if api_key else 0.5)
# 2) ESummary: get summaries for IDs
with Entrez.esummary(db=db, id=",".join(id_list), retmode="xml") as handle:
summary_result = Entrez.read(handle)
items = []
for docsum in summary_result:
items.append({
"id": str(docsum.get("Id", "")),
"title": str(docsum.get("Title", "")),
"pubdate": str(docsum.get("PubDate", "")),
"source": str(docsum.get("Source", "")),
"authors": [str(a.get("Name", "")) for a in docsum.get("AuthorList", [])],
})
payload = {
"query": term,
"count": len(items),
"items": items,
}
ensure_parent_dir(out_json)
with open(out_json, "w", encoding="utf-8") as f:
json.dump(payload, f, ensure_ascii=False, indent=2)
if __name__ == "__main__":
main()
3) Run:
python scripts/pubmed_summaries.py
Core E-utilities mapping
ESearch: builds a query against an NCBI database and returns matching IDs (and optionally WebEnv/QueryKey for history-based batching).ESummary: returns lightweight document summaries for a list of IDs.EFetch: downloads full records (e.g., GenBank/FASTA/XML) for IDs; choose rettype/retmode based on the target database.ELink: discovers cross-database relationships (e.g., PubMed → PMC, Gene → Protein).Batching strategy
ESearch to obtain IDs, then call ESummary/EFetch in chunks (e.g., 100–500 IDs per request depending on payload size).usehistory="y" in ESearch and then fetch via WebEnv/QueryKey to avoid very long ID lists.Rate limiting and API key
Parsing
Entrez.read(handle) for structured parsing of XML responses into Python objects.handle.read() and write to disk with encoding="utf-8" where applicable.Configuration and I/O conventions
config/task_config.json as an intermediate artifact.python scripts/<task_name>.py.encoding="utf-8" for file I/O and use ensure_ascii=False for JSON outputs.Reference
references/databases.md for database notes and selection guidance.tools
Generates complete conventional oncology bulk-transcriptome biomarker and hub-gene research designs from a user-provided cancer type and study direction. Always use this skill whenever a user wants to design, plan, or build a tumor bioinformatics study centered on differential expression, prognostic filtering or risk modeling, PPI-based hub-gene prioritization, diagnostic/prognostic evaluation, clinical association, immune infiltration context, methylation context, and optional tissue or cell validation. Covers five study patterns (signature-first prognostic workflow, hub-gene-first biomarker workflow, hybrid signature-to-hub workflow, immune-context biomarker workflow, translational validation workflow) and always outputs four workload configs (Lite / Standard / Advanced / Publication+) with recommended primary plan, step-by-step workflow, figure plan, validation strategy, minimal executable version, publication upgrade path...
development
Generates complete conventional non-oncology bioinformatics research designs from a user-provided disease context, process-related gene family or biological theme, and validation direction. Use when a study centers on multi-dataset bulk transcriptome integration, DEG analysis, process-gene intersection, enrichment analysis, GSEA, PPI hub-gene prioritization, TF/miRNA regulatory networks, ROC-based biomarker evaluation, and immune infiltration analysis. Covers five study patterns (process-DEG discovery, enrichment/GSEA interpretation, hub-gene prioritization, regulatory-network and immune interpretation, multi-layer public validation) and always outputs Lite / Standard / Advanced / Publication+ with a recommended primary plan, stepwise workflow, figure plan, validation hierarchy, minimal executable version, publication upgrade path, and strictly verified literature retrieval.
tools
Plans confounder control, variable adjustment logic, and bias mitigation strategies at the protocol stage for clinical, epidemiologic, translational, observational, and biomarker studies. Always use this skill when a user needs to identify major confounders, decide which variables should or should not be adjusted for, compare matching/stratification/weighting approaches, anticipate selection or measurement bias, or pressure-test a study design before execution. Focus on bias sensing, causal structure awareness, variable-role classification, and critical design review rather than generic statistical advice.
testing
Generates complete comparative network-toxicology research designs from a user-provided exposure pair, shared toxic phenotype, and validation direction. Use when a study centers on two related exposures under one outcome and needs target collection, shared-vs-specific target decomposition, enrichment, PPI hub prioritization, docking, optional transcriptomic cross-checks, and conservative mechanistic synthesis. Covers five study patterns and always outputs Lite / Standard / Advanced / Publication+ with a recommended primary plan, stepwise workflow, figure plan, validation hierarchy, minimal executable version, publication upgrade path, and strictly verified literature retrieval.