Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
0
52
# PMC Corpus Harvester Requirements
# ==================================
# pip install -r requirements.txt
# Core - Required
requests>=2.28.0
tqdm>=4.65.0
pyyaml>=6.0
# Optional - For advanced features
# pandas>=2.0.0 # Data analysis
# biopython>=1.81 # Extended PubMed utilities
# Optional - For RAG building (after harvesting)
# sentence-transformers>=2.2.0 # Embeddings
# chromadb>=0.4.0 # Vector store
# tiktoken>=0.5.0 # Token counting
# Optional - For LLM inference
# anthropic>=0.18.0 # Claude API
# openai>=1.0.0 # OpenAI API

🧬 PMC Corpus Harvester

Build a disease-specific literature corpus in one evening!

Gene-agnostic PubMed Central corpus builder for rare disease research. Downloads HTML + metadata from PMC for building RAG (Retrieval-Augmented Generation) systems.

Originally developed for STXBP1-ARIA and SNAP25-ARIA projects.

✨ Features

Feature Description
Gene-Agnostic Configure for any gene or disease with YAML/JSON
NCBI API Support 10 req/sec with API key (vs 3/sec without)
Multi-Format Downloads HTML (for multimodal) + XML + JSON metadata
Smart Filtering Relevance scoring with wrong-gene exclusion
Resume Capable Tracks progress, restart where you left off
Rate Limited Built-in exponential backoff, respects NCBI limits
Built-in Configs SNAP25, STXBP1 ready to use

πŸš€ Quick Start

# 1. Clone or download
git clone https://huggingface.co/datasets/SkyWhal3/PMC-Corpus-Harvester
cd PMC-Corpus-Harvester

# 2. Install dependencies
pip install -r requirements.txt

# 3. Set your NCBI API key (10x faster!)
export NCBI_API_KEY=your_key_here

# 4. Harvest!
python pmc_corpus_harvester.py --gene SNAP25

πŸ“‹ Usage

Using Built-in Gene Configs

# List available genes
python pmc_corpus_harvester.py --list-genes

# Harvest SNAP25 literature
python pmc_corpus_harvester.py --gene SNAP25

# Harvest STXBP1 literature
python pmc_corpus_harvester.py --gene STXBP1

# Custom output directory
python pmc_corpus_harvester.py --gene SNAP25 --output /path/to/corpus

Using Custom Gene Config

# Export a template config
python pmc_corpus_harvester.py --gene SNAP25 --export-config my_gene.yaml

# Edit my_gene.yaml for your gene of interest

# Run with custom config
python pmc_corpus_harvester.py --config my_gene.yaml

Environment Variables

Variable Description
NCBI_API_KEY Your NCBI API key (get one here)
NCBI_EMAIL Your email for NCBI API (recommended)

With API key: 10 requests/second
Without API key: 3 requests/second

πŸ“ Output Structure

corpus/
└── SNAP25/
    β”œβ”€β”€ html/           # Full HTML articles (for multimodal RAG)
    β”‚   β”œβ”€β”€ PMC1234567.html
    β”‚   └── ...
    β”œβ”€β”€ json/           # Parsed metadata + extracted text
    β”‚   β”œβ”€β”€ PMC1234567.json
    β”‚   └── ...
    β”œβ”€β”€ xml/            # Raw PMC XML (backup)
    β”‚   β”œβ”€β”€ PMC1234567.xml
    β”‚   └── ...
    └── logs/
        β”œβ”€β”€ progress.json    # Resume state
        └── harvest_*.log    # Download logs

JSON Article Format

Each JSON file contains:

{
  "pmc_id": "PMC1234567",
  "pmid": "12345678",
  "doi": "10.1234/example",
  "title": "Article Title",
  "abstract": "Full abstract text...",
  "keywords": ["keyword1", "keyword2"],
  "main_text": "Full article body text...",
  "figures": [
    {"label": "Figure 1", "caption": "Description...", "href": "fig1.jpg"}
  ],
  "tables": [
    {"label": "Table 1", "caption": "Data summary..."}
  ],
  "authors": ["Author One", "Author Two"],
  "metadata": {
    "journal": "Journal Name",
    "pub_date": "2024-01-15",
    "source": "pmc_eutils"
  },
  "relevance": {
    "score": 45,
    "reason": "primary:snap25(3),snare:5,disease:2"
  },
  "has_html": true
}

βš™οΈ Custom Gene Configuration

Create a YAML config for your gene of interest:

# my_gene_config.yaml
gene_symbol: SCN1A
gene_name: "Sodium Voltage-Gated Channel Alpha Subunit 1"
aliases:
  - Nav1.1
  - sodium channel

primary_queries:
  - '"SCN1A"[Title/Abstract]'
  - '"Nav1.1"[Title/Abstract]'
  - 'SCN1A[Gene]'
  - '"SCN1A encephalopathy"'
  - '"Dravet syndrome"[Title/Abstract]'

secondary_queries:
  - '"sodium channel"[Title/Abstract] AND epilepsy'
  - '"voltage-gated sodium"[Title/Abstract] AND mutation'

primary_keywords:
  - scn1a
  - nav1.1
  - dravet syndrome
  - dravet

related_keywords:
  - sodium channel
  - voltage-gated
  - channelopathy

disease_keywords:
  - epileptic encephalopathy
  - febrile seizure
  - intractable epilepsy

therapy_keywords:
  - gene therapy
  - antisense oligonucleotide
  - sodium channel blocker

exclude_terms:
  - scn2a
  - scn8a
  - scn9a

relevance_threshold: 15

Then run:

python pmc_corpus_harvester.py --config my_gene_config.yaml

πŸ“Š Search Strategy

Primary Queries (High Specificity)

  • Direct gene name searches ("SNAP25"[Title/Abstract])
  • Gene symbol searches (SNAP25[Gene])
  • Disease associations ("SNAP25 encephalopathy")
  • Variant mentions ("SNAP25 mutation")

Secondary Queries (Related Concepts)

  • Protein family/pathway searches
  • Partner protein interactions
  • Therapeutic approaches
  • Related diseases

Relevance Scoring

Category Points Examples
Primary keywords +20 each Gene name, direct disease
Related keywords +5 each Protein family, pathway
Disease keywords +3 each Epilepsy, encephalopathy
Therapy keywords +3 each Gene therapy, CRISPR
Exclusion terms -10 each Wrong gene family members

Threshold: 15 points (configurable)

🎯 Built-in Gene Configs

SNAP25

  • Full name: Synaptosomal-Associated Protein 25
  • Disease: SNAP25-DEE (Developmental Epileptic Encephalopathy)
  • Expected corpus: ~2,000-5,000 papers
  • Key papers: KlΓΆckner 2020, Rohena 2013, Bhumbra 2024

STXBP1

  • Full name: Syntaxin Binding Protein 1 (Munc18-1)
  • Disease: STXBP1-DEE, Ohtahara syndrome
  • Expected corpus: ~15,000-20,000 papers
  • Key papers: Stamberger 2016, KovačeviΔ‡ 2018

πŸ”§ Requirements

requests>=2.28.0
tqdm>=4.65.0
pyyaml>=6.0

Optional for RAG building:

sentence-transformers>=2.2.0
chromadb>=0.4.0

πŸ“ˆ Performance

Metric With API Key Without API Key
Request rate 10/sec 3/sec
1000 papers ~2 min ~6 min
10000 papers ~20 min ~60 min

πŸ”— Related Projects

πŸ—οΈ Next Steps After Harvesting

  1. Build RAG Index: Use embeddings (Nemotron-1B recommended)
  2. Deploy to HuggingFace: Share your corpus
  3. Create Eval Benchmark: Build domain-specific test questions
  4. Connect with Foundations: Share with patient communities

πŸ“œ License

MIT License - Use freely for research and clinical applications.

πŸ™ Acknowledgments

  • NCBI/NLM for PubMed Central API
  • STXBP1 Foundation for inspiration
  • SNAP25 Foundation for collaboration

πŸ“¬ Contact

  • Author: Adam Freygang
  • Project: NeuroSenpai / ARIA
  • HuggingFace: @SkyWhal3

Built with ❀️ for the rare disease research community

"Let's freak people out by building this in one evening!"

Downloads last month
17

Collections including SkyWhal3/PMC-Corpus-Harvester