OpenParable
Skip to content
← Back to skills

Ncbi Clinvar

Research
ncbi_clinvar

Ncbi Clinvar is an Agent Skill for research published in the ai4protein/VenusFactory2 repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

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.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ai4protein/VenusFactory2/blob/HEAD/src/agent/skills/ncbi_clinvar/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/ncbi-clinvar, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

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:

  1. 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.
  2. References: references/api_reference.md, references/clinical_significance.md, references/data_formats.md

Agent Tools (Download Only)

Tool nameArgumentsPurpose
download_ncbi_clinvar_variantsterm, 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 nameArgumentsPurpose
download_ncbi_sequencencbi_id, out_path, db (optional)Download NCBI sequence by accession (FASTA)
download_ncbi_metadatancbi_id, out_path, db, rettype (optional)Download NCBI metadata (GenBank/XML)
download_ncbi_blastsequence, out_path, program, database, etc.Submit BLAST search and download XML

Project Modules (Programmatic Use)

CapabilityFunctionModulePurpose
Build search termbuild_clinvar_term(gene, clinical_significance, condition, chr, variant_name, exclude_conflicting, raw_term)ncbi_clinvar.pyBuild E-utilities query string
High-level searchquery_clinvar(term, retmax, retstart, retmode, api_key)ncbi_clinvar.pySearch ClinVar, return esearch response text
Get summariesget_clinvar_summary(variation_ids, retmode, api_key)ncbi_clinvar.pyGet variant summaries by IDs
Full recordsfetch_clinvar_records(variation_ids, rettype, retmode, api_key)ncbi_clinvar.pyFetch full XML/VCV records
Parse IDsparse_esearch_ids(esearch_response_text)ncbi_clinvar.pyExtract Variation IDs from esearch JSON
Parse countparse_esearch_count(esearch_response_text)ncbi_clinvar.pyExtract total count from esearch JSON
FTP URLget_clinvar_ftp_url(key)ncbi_clinvar.pyGet FTP URL by key (variant_summary, vcf_grch38, xml_latest, etc.)
FTP downloaddownload_clinvar_ftp(url_or_key, out_dir, filename)ncbi_clinvar.pyDownload file from ClinVar FTP
Atomic esearchclinvar_esearch(term, retmax, retstart, retmode, api_key, sort)ncbi_clinvar.pyRaw esearch response text
Atomic esummaryclinvar_esummary(id_list, retmode, api_key)ncbi_clinvar.pyRaw esummary response text
Atomic efetchclinvar_efetch(id_list, rettype, retmode, api_key)ncbi_clinvar.pyRaw efetch response text
Query: esearchquery_ncbi_clinvar_esearch(term, retmax, retstart, retmode)ncbi_operations.pyReturns rich JSON in memory
Query: esummaryquery_ncbi_clinvar_esummary(id_list, retmode)ncbi_operations.pyReturns rich JSON in memory
Query: efetchquery_ncbi_clinvar_efetch(id_list, rettype, retmode)ncbi_operations.pyReturns rich JSON in memory
Query: variantsquery_ncbi_clinvar_variants(term, retmax)ncbi_operations.pyCompound: esearch → returns rich JSON
Download: esearchdownload_ncbi_clinvar_esearch(term, out_path, retmax, retstart, retmode)ncbi_operations.pySave esearch results to file
Download: esummarydownload_ncbi_clinvar_esummary(id_list, out_path, retmode)ncbi_operations.pySave esummary results to file
Download: efetchdownload_ncbi_clinvar_efetch(id_list, out_path, rettype, retmode)ncbi_operations.pySave efetch results to file
Download: variantsdownload_ncbi_clinvar_variants(term, out_path, retmax)ncbi_operations.pyCompound: 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