ClinVar Database (NCBI)
Overview
ClinVar is NCBI's archive of relationships between human genetic variants and phenotypes, with supporting evidence. In this project the agent exposes one compound download tool (download_ncbi_clinvar_variants) that searches by term, retrieves variant IDs, and saves results to JSON. For finer control, ncbi_operations.py also provides atomic ClinVar E-utilities download/query functions (esearch, esummary, efetch), and the low-level module ncbi_clinvar.py provides term builders and FTP helpers. All download/query functions return rich JSON {status, file_info/content, content_preview, biological_metadata, execution_context}.
When to Use This Skill
- Searching for variants by gene, condition, or clinical significance
- Interpreting clinical significance (pathogenic, benign, VUS); see
references/clinical_significance.md
- Accessing ClinVar via E-utilities (esearch, esummary, efetch) or FTP
- Understanding review status (star ratings) and conflicting interpretations
- Annotating variant call sets with clinical significance; see
references/data_formats.md for VCF/XML/tab formats
Quick Start
The skill provides:
- Project modules in
src/tools/database/ncbi/: ncbi_clinvar.py (atomic E-utilities, term builder, FTP), ncbi_operations.py (query/download operations); ClinVar download functions re-exported via package.
- References:
references/api_reference.md, references/clinical_significance.md, references/data_formats.md
Agent Tools (Download Only)
| Tool name |
Arguments |
Purpose |
download_ncbi_clinvar_variants |
term, out_path, retmax (optional, default 20) |
Search ClinVar variants by term and save results to JSON |
Also available as general NCBI tools (not ClinVar-specific but useful in ClinVar workflows):
| Tool name |
Arguments |
Purpose |
download_ncbi_sequence |
ncbi_id, out_path, db (optional) |
Download NCBI sequence by accession (FASTA) |
download_ncbi_metadata |
ncbi_id, out_path, db, rettype (optional) |
Download NCBI metadata (GenBank/XML) |
download_ncbi_blast |
sequence, out_path, program, database, etc. |
Submit BLAST search and download XML |
Project Modules (Programmatic Use)
| Capability |
Function |
Module |
Purpose |
| Build search term |
build_clinvar_term(gene, clinical_significance, condition, chr, variant_name, exclude_conflicting, raw_term) |
ncbi_clinvar.py |
Build E-utilities query string |
| High-level search |
query_clinvar(term, retmax, retstart, retmode, api_key) |
ncbi_clinvar.py |
Search ClinVar, return esearch response text |
| Get summaries |
get_clinvar_summary(variation_ids, retmode, api_key) |
ncbi_clinvar.py |
Get variant summaries by IDs |
| Full records |
fetch_clinvar_records(variation_ids, rettype, retmode, api_key) |
ncbi_clinvar.py |
Fetch full XML/VCV records |
| Parse IDs |
parse_esearch_ids(esearch_response_text) |
ncbi_clinvar.py |
Extract Variation IDs from esearch JSON |
| Parse count |
parse_esearch_count(esearch_response_text) |
ncbi_clinvar.py |
Extract total count from esearch JSON |
| FTP URL |
get_clinvar_ftp_url(key) |
ncbi_clinvar.py |
Get FTP URL by key (variant_summary, vcf_grch38, xml_latest, etc.) |
| FTP download |
download_clinvar_ftp(url_or_key, out_dir, filename) |
ncbi_clinvar.py |
Download file from ClinVar FTP |
| Atomic esearch |
clinvar_esearch(term, retmax, retstart, retmode, api_key, sort) |
ncbi_clinvar.py |
Raw esearch response text |
| Atomic esummary |
clinvar_esummary(id_list, retmode, api_key) |
ncbi_clinvar.py |
Raw esummary response text |
| Atomic efetch |
clinvar_efetch(id_list, rettype, retmode, api_key) |
ncbi_clinvar.py |
Raw efetch response text |
| Query: esearch |
query_ncbi_clinvar_esearch(term, retmax, retstart, retmode) |
ncbi_operations.py |
Returns rich JSON in memory |
| Query: esummary |
query_ncbi_clinvar_esummary(id_list, retmode) |
ncbi_operations.py |
Returns rich JSON in memory |
| Query: efetch |
query_ncbi_clinvar_efetch(id_list, rettype, retmode) |
ncbi_operations.py |
Returns rich JSON in memory |
| Query: variants |
query_ncbi_clinvar_variants(term, retmax) |
ncbi_operations.py |
Compound: esearch → returns rich JSON |
| Download: esearch |
download_ncbi_clinvar_esearch(term, out_path, retmax, retstart, retmode) |
ncbi_operations.py |
Save esearch results to file |
| Download: esummary |
download_ncbi_clinvar_esummary(id_list, out_path, retmode) |
ncbi_operations.py |
Save esummary results to file |
| Download: efetch |
download_ncbi_clinvar_efetch(id_list, out_path, rettype, retmode) |
ncbi_operations.py |
Save efetch results to file |
| Download: variants |
download_ncbi_clinvar_variants(term, out_path, retmax) |
ncbi_operations.py |
Compound: esearch → save to file |
Core Capabilities
1. Search ClinVar Variants (download)
from src.tools.database.ncbi import download_ncbi_clinvar_variants
# Simple gene search
result = download_ncbi_clinvar_variants("BRCA1[gene]", "output/clinvar_brca1.json", retmax=50)
# Pathogenic variants for a gene
result = download_ncbi_clinvar_variants(
"BRCA1[gene] AND pathogenic[CLNSIG]",
"output/clinvar_brca1_pathogenic.json",
retmax=100,
)
2. Build Search Terms (programmatic)
from src.tools.database.ncbi.ncbi_clinvar import build_clinvar_term
# Build term with filters
term = build_clinvar_term(
gene="BRCA1",
clinical_significance="pathogenic",
exclude_conflicting=True,
)
# → "BRCA1[gene] AND pathogenic[CLNSIG] NOT conflicting[RVSTAT]"
# Search by condition
term = build_clinvar_term(condition="breast cancer")
# → "breast cancer[disorder]"
3. Atomic E-utilities Workflow (programmatic)
from src.tools.database.ncbi.ncbi_clinvar import (
build_clinvar_term, query_clinvar, parse_esearch_ids,
get_clinvar_summary, fetch_clinvar_records,
)
# Step 1: Build term and search
term = build_clinvar_term(gene="BRCA1", clinical_significance="pathogenic")
esearch_result = query_clinvar(term, retmax=100)
# Step 2: Parse IDs
variation_ids = parse_esearch_ids(esearch_result)
# Step 3: Get summaries or full records
summaries = get_clinvar_summary(variation_ids)
records = fetch_clinvar_records(variation_ids, rettype="vcv")
4. Download Atomic Results
from src.tools.database.ncbi import (
download_ncbi_clinvar_esearch,
download_ncbi_clinvar_esummary,
download_ncbi_clinvar_efetch,
)
# Save esearch results
download_ncbi_clinvar_esearch("BRCA1[gene]", "output/clinvar_esearch.json", retmax=50)
# Save summaries (need IDs from esearch first)
download_ncbi_clinvar_esummary(["12345", "67890"], "output/clinvar_esummary.json")
# Save full records
download_ncbi_clinvar_efetch(["12345", "67890"], "output/clinvar_efetch.xml")
5. FTP Bulk Downloads (programmatic)
from src.tools.database.ncbi.ncbi_clinvar import get_clinvar_ftp_url, download_clinvar_ftp
# Get FTP URL
url = get_clinvar_ftp_url("variant_summary") # Or: vcf_grch37, vcf_grch38, xml_latest, var_citations, cross_references
# Download
download_clinvar_ftp("variant_summary", "output/clinvar_ftp/")
download_clinvar_ftp("vcf_grch38", "output/clinvar_ftp/")
Key Concepts
- Search fields:
[gene], [CLNSIG], [disorder], [variant name], [chr], [RVSTAT] (e.g. exclude conflicts: NOT conflicting[RVSTAT])
- Variation ID (VCV): ClinVar variation accession; returned by esearch as UID and used in esummary/efetch
- rettype:
vcv (variant-centric) or rcv (variant–condition pair) for efetch
Important Notes
- ClinVar data is not for direct clinical diagnosis; involve a genetics professional
- Prefer high review status (e.g. expert panel, practice guideline) when interpreting classifications
- Use
exclude_conflicting=True in build_clinvar_term to filter out conflicting interpretations
- Rate limits: 3 req/s without API key, 10 with key; the module applies delays automatically
Reference Documentation
references/api_reference.md – E-utilities (esearch, esummary, efetch, elink), parameters, rate limits, Biopython example
references/clinical_significance.md – Germline/somatic classifications, ACMG/AMP terms, review status, conflict resolution
references/data_formats.md – FTP layout, XML (VCV/RCV), VCF, tab-delimited files, processing examples
1---2name: ncbi-clinvar3description: Query NCBI ClinVar for variant clinical significance. Search by gene/condition/CLNSIG, interpret pathogenicity, use E-utilities or FTP; annotate VCFs. Use project tools in src.tools.database.ncbi.4license: Unknown5---67# ClinVar Database (NCBI)89## Overview1011ClinVar is NCBI's archive of relationships between human genetic variants and phenotypes, with supporting evidence. **In this project the agent exposes one compound download tool** (`download_ncbi_clinvar_variants`) that searches by term, retrieves variant IDs, and saves results to JSON. For finer control, `ncbi_operations.py` also provides atomic ClinVar E-utilities download/query functions (esearch, esummary, efetch), and the low-level module `ncbi_clinvar.py` provides term builders and FTP helpers. All download/query functions return rich JSON `{status, file_info/content, content_preview, biological_metadata, execution_context}`.1213## When to Use This Skill1415- Searching for variants by gene, condition, or clinical significance16- Interpreting clinical significance (pathogenic, benign, VUS); see `references/clinical_significance.md`17- Accessing ClinVar via E-utilities (esearch, esummary, efetch) or FTP18- Understanding review status (star ratings) and conflicting interpretations19- Annotating variant call sets with clinical significance; see `references/data_formats.md` for VCF/XML/tab formats2021## Quick Start2223The skill provides:241. **Project modules** in `src/tools/database/ncbi/`: `ncbi_clinvar.py` (atomic E-utilities, term builder, FTP), `ncbi_operations.py` (query/download operations); ClinVar download functions re-exported via package.252. References: `references/api_reference.md`, `references/clinical_significance.md`, `references/data_formats.md`2627### Agent Tools (Download Only)2829| Tool name | Arguments | Purpose |30|-----------|-----------|---------|31| `download_ncbi_clinvar_variants` | `term`, `out_path`, `retmax` (optional, default 20) | Search ClinVar variants by term and save results to JSON |3233Also available as general NCBI tools (not ClinVar-specific but useful in ClinVar workflows):3435| Tool name | Arguments | Purpose |36|-----------|-----------|---------|37| `download_ncbi_sequence` | `ncbi_id`, `out_path`, `db` (optional) | Download NCBI sequence by accession (FASTA) |38| `download_ncbi_metadata` | `ncbi_id`, `out_path`, `db`, `rettype` (optional) | Download NCBI metadata (GenBank/XML) |39| `download_ncbi_blast` | `sequence`, `out_path`, `program`, `database`, etc. | Submit BLAST search and download XML |4041### Project Modules (Programmatic Use)4243| Capability | Function | Module | Purpose |44|------------|----------|--------|---------|45| Build search term | `build_clinvar_term(gene, clinical_significance, condition, chr, variant_name, exclude_conflicting, raw_term)` | ncbi_clinvar.py | Build E-utilities query string |46| High-level search | `query_clinvar(term, retmax, retstart, retmode, api_key)` | ncbi_clinvar.py | Search ClinVar, return esearch response text |47| Get summaries | `get_clinvar_summary(variation_ids, retmode, api_key)` | ncbi_clinvar.py | Get variant summaries by IDs |48| Full records | `fetch_clinvar_records(variation_ids, rettype, retmode, api_key)` | ncbi_clinvar.py | Fetch full XML/VCV records |49| Parse IDs | `parse_esearch_ids(esearch_response_text)` | ncbi_clinvar.py | Extract Variation IDs from esearch JSON |50| Parse count | `parse_esearch_count(esearch_response_text)` | ncbi_clinvar.py | Extract total count from esearch JSON |51| FTP URL | `get_clinvar_ftp_url(key)` | ncbi_clinvar.py | Get FTP URL by key (variant_summary, vcf_grch38, xml_latest, etc.) |52| FTP download | `download_clinvar_ftp(url_or_key, out_dir, filename)` | ncbi_clinvar.py | Download file from ClinVar FTP |53| Atomic esearch | `clinvar_esearch(term, retmax, retstart, retmode, api_key, sort)` | ncbi_clinvar.py | Raw esearch response text |54| Atomic esummary | `clinvar_esummary(id_list, retmode, api_key)` | ncbi_clinvar.py | Raw esummary response text |55| Atomic efetch | `clinvar_efetch(id_list, rettype, retmode, api_key)` | ncbi_clinvar.py | Raw efetch response text |56| Query: esearch | `query_ncbi_clinvar_esearch(term, retmax, retstart, retmode)` | ncbi_operations.py | Returns rich JSON in memory |57| Query: esummary | `query_ncbi_clinvar_esummary(id_list, retmode)` | ncbi_operations.py | Returns rich JSON in memory |58| Query: efetch | `query_ncbi_clinvar_efetch(id_list, rettype, retmode)` | ncbi_operations.py | Returns rich JSON in memory |59| Query: variants | `query_ncbi_clinvar_variants(term, retmax)` | ncbi_operations.py | Compound: esearch → returns rich JSON |60| Download: esearch | `download_ncbi_clinvar_esearch(term, out_path, retmax, retstart, retmode)` | ncbi_operations.py | Save esearch results to file |61| Download: esummary | `download_ncbi_clinvar_esummary(id_list, out_path, retmode)` | ncbi_operations.py | Save esummary results to file |62| Download: efetch | `download_ncbi_clinvar_efetch(id_list, out_path, rettype, retmode)` | ncbi_operations.py | Save efetch results to file |63| Download: variants | `download_ncbi_clinvar_variants(term, out_path, retmax)` | ncbi_operations.py | Compound: esearch → save to file |6465## Core Capabilities6667### 1. Search ClinVar Variants (download)6869```python70from src.tools.database.ncbi import download_ncbi_clinvar_variants7172# Simple gene search73result = download_ncbi_clinvar_variants("BRCA1[gene]", "output/clinvar_brca1.json", retmax=50)7475# Pathogenic variants for a gene76result = download_ncbi_clinvar_variants(77 "BRCA1[gene] AND pathogenic[CLNSIG]",78 "output/clinvar_brca1_pathogenic.json",79 retmax=100,80)81```8283### 2. Build Search Terms (programmatic)8485```python86from src.tools.database.ncbi.ncbi_clinvar import build_clinvar_term8788# Build term with filters89term = build_clinvar_term(90 gene="BRCA1",91 clinical_significance="pathogenic",92 exclude_conflicting=True,93)94# → "BRCA1[gene] AND pathogenic[CLNSIG] NOT conflicting[RVSTAT]"9596# Search by condition97term = build_clinvar_term(condition="breast cancer")98# → "breast cancer[disorder]"99```100101### 3. Atomic E-utilities Workflow (programmatic)102103```python104from src.tools.database.ncbi.ncbi_clinvar import (105 build_clinvar_term, query_clinvar, parse_esearch_ids,106 get_clinvar_summary, fetch_clinvar_records,107)108109# Step 1: Build term and search110term = build_clinvar_term(gene="BRCA1", clinical_significance="pathogenic")111esearch_result = query_clinvar(term, retmax=100)112113# Step 2: Parse IDs114variation_ids = parse_esearch_ids(esearch_result)115116# Step 3: Get summaries or full records117summaries = get_clinvar_summary(variation_ids)118records = fetch_clinvar_records(variation_ids, rettype="vcv")119```120121### 4. Download Atomic Results122123```python124from src.tools.database.ncbi import (125 download_ncbi_clinvar_esearch,126 download_ncbi_clinvar_esummary,127 download_ncbi_clinvar_efetch,128)129130# Save esearch results131download_ncbi_clinvar_esearch("BRCA1[gene]", "output/clinvar_esearch.json", retmax=50)132133# Save summaries (need IDs from esearch first)134download_ncbi_clinvar_esummary(["12345", "67890"], "output/clinvar_esummary.json")135136# Save full records137download_ncbi_clinvar_efetch(["12345", "67890"], "output/clinvar_efetch.xml")138```139140### 5. FTP Bulk Downloads (programmatic)141142```python143from src.tools.database.ncbi.ncbi_clinvar import get_clinvar_ftp_url, download_clinvar_ftp144145# Get FTP URL146url = get_clinvar_ftp_url("variant_summary") # Or: vcf_grch37, vcf_grch38, xml_latest, var_citations, cross_references147148# Download149download_clinvar_ftp("variant_summary", "output/clinvar_ftp/")150download_clinvar_ftp("vcf_grch38", "output/clinvar_ftp/")151```152153## Key Concepts154155- **Search fields:** `[gene]`, `[CLNSIG]`, `[disorder]`, `[variant name]`, `[chr]`, `[RVSTAT]` (e.g. exclude conflicts: `NOT conflicting[RVSTAT]`)156- **Variation ID (VCV):** ClinVar variation accession; returned by esearch as UID and used in esummary/efetch157- **rettype:** `vcv` (variant-centric) or `rcv` (variant–condition pair) for efetch158159## Important Notes160161- ClinVar data is not for direct clinical diagnosis; involve a genetics professional162- Prefer high review status (e.g. expert panel, practice guideline) when interpreting classifications163- Use `exclude_conflicting=True` in `build_clinvar_term` to filter out conflicting interpretations164- **Rate limits:** 3 req/s without API key, 10 with key; the module applies delays automatically165166## Reference Documentation167168- **`references/api_reference.md`** – E-utilities (esearch, esummary, efetch, elink), parameters, rate limits, Biopython example169- **`references/clinical_significance.md`** – Germline/somatic classifications, ACMG/AMP terms, review status, conflict resolution170- **`references/data_formats.md`** – FTP layout, XML (VCV/RCV), VCF, tab-delimited files, processing examples