SNAP25
Collection
5 items β’ Updated
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 |
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.
| 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 |
# 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
# 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
# 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
| 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
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
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
}
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
"SNAP25"[Title/Abstract])SNAP25[Gene])"SNAP25 encephalopathy")"SNAP25 mutation")| 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)
requests>=2.28.0
tqdm>=4.65.0
pyyaml>=6.0
Optional for RAG building:
sentence-transformers>=2.2.0
chromadb>=0.4.0
| 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 |
MIT License - Use freely for research and clinical applications.
Built with β€οΈ for the rare disease research community
"Let's freak people out by building this in one evening!"