Agent Skillsmaziyarpanahi/openmed › mining-pubmed-literature

mining-pubmed-literature

GitHub

通过NCBI E-utilities检索PubMed和PMC文献,支持MeSH搜索、摘要获取及构建生物医学语料库。常与OpenMed配合进行NER分析或证据挖掘。

skills/mining-pubmed-literature/SKILL.md maziyarpanahi/openmed

Trigger Scenarios

需要特定疾病或药物的文献引用 获取摘要用于总结或生物医学NER分析 基于MeSH标签的可复现文献检索 用户提及PubMed, PMC, NCBI, MeSH, PMID等关键词

Install

npx skills add maziyarpanahi/openmed --skill mining-pubmed-literature -g -y
More Options

Use without installing

npx skills use maziyarpanahi/openmed@mining-pubmed-literature

指定 Agent (Claude Code)

npx skills add maziyarpanahi/openmed --skill mining-pubmed-literature -a claude-code -g -y

安装 repo 全部 skill

npx skills add maziyarpanahi/openmed --all -g -y

预览 repo 内 skill

npx skills add maziyarpanahi/openmed --list

SKILL.md

Frontmatter
{
    "name": "mining-pubmed-literature",
    "license": "Apache-2.0",
    "metadata": {
        "pairs": "adjacent",
        "project": "OpenMed",
        "version": "1.0",
        "category": "research-genomics"
    },
    "description": "Searches and fetches PubMed and PMC via NCBI E-utilities (ESearch then EFetch\/ESummary) to gather biomedical evidence and build text corpora. Use when the user wants citations for a condition or drug, abstracts to summarize, MeSH-based searches, or a corpus of literature to run NER over. Trigger keywords: PubMed, PMC, NCBI, E-utilities, ESearch, EFetch, ESummary, MeSH, PMID, literature search, abstracts, evidence. Pairs adjacent to OpenMed: fetched abstracts feed openmed.analyze_text for biomedical NER, and OpenMed-extracted diagnoses\/drugs\/genes become the search terms. E-utilities are public; an optional free API key raises rate limits from 3 to 10 requests\/second."
}

Mining PubMed & PMC literature (NCBI E-utilities)

Search PubMed (citations/abstracts) and PMC (full text) programmatically with NCBI E-utilities — the stable HTTP interface to Entrez. The core pattern is two steps: ESearch returns matching record IDs (PMIDs), then EFetch (or ESummary) downloads the records. The Entrez History server (usehistory=y) lets you chain the two without re-sending thousands of IDs.

E-utilities are public. No key is required, but a free API key raises your limit from 3 to 10 requests/second and is strongly recommended for batch work.

When to use

  • OpenMed extracted a diagnosis, drug, or gene and you want supporting literature.
  • You need abstracts to summarize or to assemble a corpus for biomedical NER.
  • You want MeSH-anchored, reproducible searches (date ranges, article types).

For ClinicalTrials.gov use searching-clinicaltrials; this skill is for the published literature.

Quick start (real E-utilities calls)

Base URL: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/. JSON for ESearch/ ESummary via retmode=json; EFetch returns text or XML (no JSON for PubMed).

import requests, time

BASE = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils"
API_KEY = None   # set to your free NCBI key to get 10 req/s instead of 3

def _params(**kw):
    if API_KEY:
        kw["api_key"] = API_KEY
    return kw

def esearch(term: str, retmax: int = 50) -> dict:
    """Find PMIDs; usehistory=y stores them on the Entrez History server."""
    r = requests.get(f"{BASE}/esearch.fcgi", params=_params(
        db="pubmed", term=term, retmax=retmax,
        usehistory="y", retmode="json"), timeout=30)
    r.raise_for_status()
    res = r.json()["esearchresult"]
    return {"count": int(res["count"]), "ids": res["idlist"],
            "webenv": res["webenv"], "query_key": res["querykey"]}

def efetch_abstracts(webenv: str, query_key: str, retmax: int = 50) -> str:
    """Pull abstracts by reference to the stored result set (no ID list needed)."""
    r = requests.get(f"{BASE}/efetch.fcgi", params=_params(
        db="pubmed", WebEnv=webenv, query_key=query_key,
        retmax=retmax, rettype="abstract", retmode="text"), timeout=60)
    r.raise_for_status()
    return r.text

hits = esearch('("type 2 diabetes"[MeSH]) AND metformin AND 2023:2025[pdat]')
print(hits["count"], "papers")
abstracts = efetch_abstracts(hits["webenv"], hits["query_key"])

Equivalent cURL (search then fetch one PMID's abstract):

curl "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=metformin&retmode=json"
curl "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=38000000&rettype=abstract&retmode=text"

ESummary for structured metadata

When you need titles/authors/journal/date as JSON (not the full abstract), use ESummary — it returns one record per ID:

def esummary(ids: list[str]) -> dict:
    r = requests.get(f"{BASE}/esummary.fcgi", params=_params(
        db="pubmed", id=",".join(ids), retmode="json"), timeout=30)
    r.raise_for_status()
    return r.json()["result"]   # keyed by PMID: title, pubdate, source, authors…

For PMC full text, repeat with db=pmc and EFetch rettype=""/retmode=xml (JATS XML). Respect each article's license before redistributing full text.

Workflow

  1. Build the query. Combine OpenMed-extracted terms with MeSH tags and field filters: "<disease>"[MeSH] AND <drug>[tiab] AND 2020:2025[pdat]. Use [tiab] (title/abstract), [au] (author), [pdat] (publication date).
  2. ESearch with usehistory=y to capture WebEnv + query_key and the count.
  3. Batch-fetch with EFetch/ESummary in pages of ≤ ~200 IDs (or by history), sleeping to stay under your rate limit.
  4. Parse abstracts/metadata; store PMID, title, journal, date, abstract text.
  5. NER the abstracts with openmed.analyze_text to extract diseases, drugs, genes, and oncology entities for downstream synthesis.

Hand-off to / from OpenMed

  • OpenMed facts → query. openmed.analyze_text(note) yields Disease, Pharmaceutical, Genomics, and Oncology entities. Turn the top spans into the ESearch term (optionally grounded: ICD-10 label, RxNorm ingredient, gene symbol) to retrieve targeted evidence.
  • Abstracts → OpenMed. Feed fetched abstracts straight into openmed.analyze_text(abstract, model_name="disease_detection_superclinical") (or a Genomics/Oncology model) to structure the literature into entities for evidence tables or knowledge-graph edges.
  • Queries and abstracts are public literature, not PHI. Still run locally and never embed patient text in a search term.

Edge cases & gotchas

  • Rate limits. 3 req/s without a key, 10 with one — exceed it and NCBI returns HTTP 429. Add api_key, throttle, and retry with backoff. NCBI also requests a tool= and email= parameter identifying your application.
  • EFetch has no JSON for PubMed. Use retmode=text (human-readable) or retmode=xml (PubMedArticle XML) and parse XML for structured fields.
  • History expires. WebEnv/query_key are session-scoped — fetch promptly after searching, or re-run ESearch.
  • Large result sets. Page with retstart/retmax (or history) rather than pulling everything at once; cap total fetches.
  • MeSH lag. Very recent articles may not yet be MeSH-indexed — include [tiab] term variants so you do not miss them.
  • Full-text licensing. PMC full text carries per-article licenses; many are not redistributable. Store PMIDs/abstracts freely; check the license before republishing full text.

Standards & references

Version History

  • f213557 Current 2026-07-23 00:45

Same Skill Collection

skills/building-with-openmed/SKILL.md
skills/loading-openmed-models/SKILL.md
skills/annotating-variants/SKILL.md
skills/assembling-fhir-bundles/SKILL.md
skills/auditing-deid-leakage/SKILL.md
skills/auditing-deidentification-runs/SKILL.md
skills/auditing-part11-trails/SKILL.md
skills/auditing-safe-harbor-checklist/SKILL.md
skills/auditing-subgroup-fairness/SKILL.md
skills/authoring-model-cards/SKILL.md
skills/batch-processing-clinical-text/SKILL.md
skills/benchmarking-clinical-ner/SKILL.md
skills/bridging-presidio-and-spacy/SKILL.md
skills/building-gold-corpus/SKILL.md
skills/building-patient-timelines/SKILL.md
skills/checking-hipaa-compliance/SKILL.md
skills/choosing-openmed-models/SKILL.md
skills/coding-hcc-risk-adjustment/SKILL.md
skills/coding-icd10/SKILL.md
skills/computing-ecqms/SKILL.md
skills/configuring-privacy-policies/SKILL.md
skills/defining-cohort-phenotypes/SKILL.md
skills/deidentifying-clinical-text/SKILL.md
skills/deidentifying-multilingual-text/SKILL.md
skills/deploying-openmed-mcp/SKILL.md
skills/detecting-pv-signals/SKILL.md
skills/enforcing-nophi-logging/SKILL.md
skills/etl-to-omop-cdm/SKILL.md
skills/evaluating-with-leakage-gates/SKILL.md
skills/exporting-bulk-fhir/SKILL.md
skills/exporting-to-fhir/SKILL.md
skills/extracting-clinical-entities/SKILL.md
skills/extracting-dicom-metadata/SKILL.md
skills/extracting-lab-tables/SKILL.md
skills/extracting-pii-entities/SKILL.md
skills/extracting-sdoh/SKILL.md
skills/fetching-fhir-resources/SKILL.md
skills/gating-deid-leakage/SKILL.md
skills/generating-synthea-data/SKILL.md
skills/generating-synthetic-surrogates/SKILL.md
skills/ingesting-clinical-documents/SKILL.md
skills/linking-umls-concepts/SKILL.md
skills/mapping-loinc/SKILL.md
skills/mapping-to-snomed/SKILL.md
skills/normalizing-rxnorm/SKILL.md
skills/parsing-ccda-documents/SKILL.md
skills/parsing-hl7v2-messages/SKILL.md
skills/parsing-lab-values/SKILL.md
skills/parsing-trial-eligibility/SKILL.md

Metadata

Files
0
Version
f213557
Hash
eb93a724
Indexed
2026-07-23 00:45

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-30 00:49
浙ICP备14020137号-1 $Carte des visiteurs$