dbsnp-database
Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
Use when you want to look up, map, and search for short genetic variants (SNPs, indels) in NCBI's dbSNP database. Resolves between rsIDs, genomic coordinates in VCF format, and HGVS strings. For an rsID, returns variant type, gene associations, clinical significance, allele frequencies, and genomic coordinates (GRCh38).
81installs
Added on
NPX Install
npx skill4agent add google-deepmind/science-skills dbsnp-databaseTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →dbSNP Database Integration
Prerequisites
-
: Read the
uvskill and follow its Setup instructions to ensureuvis installed and on PATH.uv -
User Notification: If LICENSE_NOTIFICATION.txt does not already exist in this skill directory then (1) prominently notify the user to check the terms at https://www.ncbi.nlm.nih.gov/snp/, then (2) create the file recording the notification text and timestamp.
-
file: Make sure the
.envfile exists in your home directory. Create one if it does not exist..env -
(optional): Raises the NCBI rate limit from 3 to 10 requests/second. The skill works without it, but a key is recommended if the user plans many queries or encounters a 429 error. The user can obtain one for free by registering at https://www.ncbi.nlm.nih.gov/account/settings/. If the variable is missing from
NCBI_API_KEY, do NOT ask the user to paste it into the chat (this would leak the key into the agent's context). Instead, give the user this command — substituting.envwith the resolved literal path to theENV_FILEfile:.envbashprintf "Enter NCBI API key (typing hidden): " && read -s key && echo && echo "NCBI_API_KEY=$key" >> "ENV_FILE" && echo "Saved."The scripts load credentials automatically via. NEVER read, print, or inspect thedotenvfile or its variables (e.g. no.env,cat,grep,echo, orprintenvon keys). Credentials must stay out of the agent's context. See the API Key section for more details.os.environ.get
Core Rules
- Use the Wrapper: ALWAYS execute the provided wrapper script
to query the database rather than constructing custom HTTP or curl requests. The script automatically handles rate limiting, retries, and JSON parsing.
scripts/dbsnp_cli.py - Command Choice: Do NOT use to find the rsID of a specific variant; use
search-regioninstead.resolve-variant - Output Size: Avoid using on
--fullunless specifically needed, as raw payloads can exceed 1 MB.get-variant - Shell Safety: Always wrap HGVS strings in single quotes to prevent shell expansion errors.
- Notification: If this skill is used, ensure this is mentioned in the output.
When to Use
Use this skill when you need to:
- Map a genomic variant to its canonical rsID (from VCF coordinates or HGVS notation).
- Retrieve summary data for an rsID: variant type, gene associations, clinical significance, and population allele frequencies.
- Convert an rsID back to genomic coordinates on a specific assembly.
- Find all known variants within a chromosomal region.
Do NOT use when you need to:
- Obtain clinical pathogenicity classifications with submitter rationales (use clinvar-database).
- Get precise population-level allele frequencies stratified by ancestry (use gnomad-database).
- Predict the functional effect of a novel mutation (use alphagenome-single-variant-analysis).
- View 3D protein structures affected by a variant (use alphafold-database-fetch-and-analyze / pdb-database).
Command Selection Guide
Pick the right command on the first try. Match the user's input to the
correct subcommand below — one command call is almost always sufficient.
- User gives you…: Run this command
- An rsID (e.g. ,
rs7412):rs268get-variant - Genomic coordinates: chrom pos ref alt (e.g. ):
8 19962213 C Tresolve-variant - An HGVS string (e.g. ):
NC_000008.11:g.19962213delresolve-hgvs - An rsID and they want coordinates back:
resolve-rsid - A chromosomal region (chrom start end):
search-region
[!CAUTION] Do NOT useto find the rsID of a specific variant. If the user provides a chromosome, position, reference allele, and alternate allele (four values), usesearch-region— it is a direct, single-API-call lookup.resolve-variantis only for surveying all variants within a positional range and returns hundreds/thousands of results.search-region
Quick Start
bash
# Look up variant rs7412: type, gene, clinical significance, MAF
uv run scripts/dbsnp_cli.py get-variant rs7412 --output /tmp/rs7412.json
# Find the rsID for a variant at chr8:19962213 C>T
uv run scripts/dbsnp_cli.py resolve-variant 8 19962213 C T \
--output /tmp/resolve.jsonAll subcommands write JSON to disk. Always save output in the directory.
The flag is required.
/tmp/--outputCommands
1. get-variant
— Fetch Variant Record
get-variantRetrieve the RefSNP record for one rsID. By default the output is abbreviated to
the most useful fields. Both and are accepted.
rs268268bash
uv run scripts/dbsnp_cli.py get-variant rs268 --output /tmp/rs268.json
uv run scripts/dbsnp_cli.py get-variant 268 --assembly GCF_000001405.40 \
--output /tmp/rs268.jsonArguments:
- (positional, required): The RefSNP identifier.
rsid - : RefSeq assembly accession (default:
--assembly= GRCh38).GCF_000001405.40 - : Return the complete raw JSON payload — see warning below.
--full - : Output file path (default:
--output)./tmp/dbsnp_output.json
Abbreviated output fields:
- : Numeric rsID
refsnp_id - : e.g.
variant_type,snv,ins,deldelins - : Sorted list of gene symbols (locus names)
genes - : List of clinical significance labels
clinical_significances - : Study name, allele count, total count
minor_allele_frequencies - : Genomic placements for the requested assembly
placements
[!WARNING] About: The raw RefSNP payload is typically 50–500 KB and can exceed 1 MB for clinically significant variants with many submissions. Only use--fullwhen you specifically need data absent from the abbreviated output — for example:--full
- The complete HGVS nomenclature across every transcript and protein isoform.
- Full submission history with individual submitter details and timestamps.
- Population-level allele frequency breakdowns by sub-population within a study (e.g. per-population gnomAD counts).
- The full set of genomic placements across multiple assemblies (GRCh37 and GRCh38 simultaneously).
- Merge history showing which older rsIDs were merged into this one.
2. resolve-variant
— Genomic Coordinates → rsID
resolve-variantDetermine the rsID(s) for a variant given its genomic coordinates (chromosome,
position, reference allele, alternate allele). This is the command to use when
the user provides a variant as space-separated coordinates like .
8 19962213 C Tbash
uv run scripts/dbsnp_cli.py resolve-variant 8 19962213 C T \
--output /tmp/resolve.jsonArguments:
- (positional): Chromosome number (e.g.
chrom) or RefSeq sequence accession (e.g.8). Chromosomes X and Y must be passed as their numeric equivalents:NC_000008.11for X and23for Y.24 - (positional): 1-based genomic position.
pos - (positional): Reference allele (e.g.
ref).C - (positional): Alternate allele(s), comma-separated (e.g.
alts).T - : RefSeq assembly accession (default:
--assembly).GCF_000001405.40 - : Output file path (default:
--output)./tmp/dbsnp_output.json
Output:
{"rsids": ["12345", "67890"]}3. resolve-rsid
— rsID → Genomic Coordinates
resolve-rsidGet the genomic placement (sequence ID and allele details) for a known rsID on a
specific assembly.
bash
uv run scripts/dbsnp_cli.py resolve-rsid rs7412 --output /tmp/coords.jsonArguments:
- (positional): The RefSNP identifier.
rsid - : RefSeq assembly accession (default:
--assembly).GCF_000001405.40 - : Output file path (default:
--output)./tmp/dbsnp_output.json
Output:
{"rsid": "7412", "assembly": "...", "placements": [...]}4. resolve-hgvs
— HGVS → rsID
resolve-hgvsFind the rsID(s) corresponding to an HGVS expression.
bash
uv run scripts/dbsnp_cli.py resolve-hgvs 'NC_000008.11:g.19962213del' \
--output /tmp/hgvs.jsonArguments:
- (positional): The HGVS string.
hgvs - : RefSeq assembly accession (default:
--assembly).GCF_000001405.40 - : Output file path (default:
--output)./tmp/dbsnp_output.json
Output:
{"rsids": ["12345"]}[!TIP] HGVS strings often contain characters that shells interpret (colons, greater-than signs). Always wrap them in single quotes to prevent shell expansion.
5. search-region
— Regional Variant Search
search-regionFind all rsIDs within a bounded chromosomal region.
bash
uv run scripts/dbsnp_cli.py search-region 7 117100000 117300000 \
--output /tmp/region.jsonArguments:
- (positional): Chromosome (e.g.
chrom). Use7for chromosome X and23for chromosome Y.24 - (positional): Start position.
start - (positional): End position.
end - : Maximum rsIDs to return (default: 500, ceiling: 5 000).
--retmax - : Output file path (default:
--output)./tmp/dbsnp_output.json
Output:
json
{
"rsids": ["12345", "67890", "..."],
"returned": 500,
"total_available": 1423,
"truncated": true,
"note": "Only 500 of 1423 variants returned. Increase --retmax ..."
}When exceeds the returned count, the output includes a
flag and a . Increase to retrieve more (up to 5
000).
total_availabletruncatednote--retmaxTypical Workflows
Identify a known variant from coordinates
bash
# Step 1: Map VCF coordinates to rsID
uv run scripts/dbsnp_cli.py resolve-variant 19 44908684 T C \
--output /tmp/step1.json
# Step 2: Get the full details for the resolved rsID
uv run scripts/dbsnp_cli.py get-variant <rsid_from_step1> \
--output /tmp/step2.jsonSurvey variants in a gene region
bash
# Step 1: Find all variants in a region spanning the CFTR gene
uv run scripts/dbsnp_cli.py search-region 7 117100000 117300000 \
--retmax 1000 --output /tmp/region.json
# Step 2: Retrieve details on individual rsIDs of interest
uv run scripts/dbsnp_cli.py get-variant <rsid> --output /tmp/detail.jsonTranslate HGVS notation to genomic coordinates
bash
# Step 1: Get the rsID for an HGVS expression
uv run scripts/dbsnp_cli.py resolve-hgvs 'NC_000019.10:g.44908684T>C' \
--output /tmp/hgvs.json
# Step 2: Resolve that rsID to VCF-style coordinates
uv run scripts/dbsnp_cli.py resolve-rsid <rsid> --output /tmp/coords.jsonAssembly Defaults and Automatic Fallback
The Variation Services endpoints (used by , ,
, ) expect a RefSeq assembly accession. The
RefSeq accession for GRCh38 is , and for GRCh37 it is
.
get-variantresolve-variantresolve-rsidresolve-hgvsGCF_000001405.40GCF_000001405.25The subcommand always searches GRCh38 positions.
search-region[!IMPORTANT] Automatic assembly fallback: Theandresolve-variantcommands automatically try GRCh38 first. If no rsIDs are found, they retry with GRCh37 before reporting failure. When a fallback occurs the output JSON includes aresolve-hgvsfield explaining which assembly succeeded. You do NOT need to manually retry with a different assembly — the script handles this transparently."note"
You only need to override when you specifically want to
restrict the lookup to one assembly (e.g. because the user's coordinates are
known to be GRCh37).
--assemblyNCBI API Key and Rate Limiting
Without an API key the script is limited to 3 requests per second. With a
key this increases to 10 requests per second.
bash
uv run scripts/dbsnp_cli.py get-variant rs268 --output out.jsonIf a is raised, pause execution and follow the prerequisite
instructions to help the user add to the file. See
for details.
RateLimitErrorNCBI_API_KEY.envreferences/api-notes.mdTroubleshooting HTTP 500 Errors
Reference Allele Mismatch
If you receive an HTTP 500 error with a message detailing that the asserted
reference allele is not equal to the reference sequence:
What it means: The coordinate position is likely valid, but the reference
allele () you provided does not match the base at that position in the
requested assembly.
refAction: 1. DO NOT RETRY the exact same query mechanically. 2. Check
the assembly: Coordinates are assembly-specific. 3. Switch assembly: If
you were querying GRCh37, try GRCh38 (using ), or
if querying GRCh38, try GRCh37 (using ).
--assembly GCF_000001405.40--assembly GCF_000001405.25Common Mistakes
-
Mistake: Forgetting to quote HGVS strings Fix: Wrap in single quotes:
'NC_000008.11:g.19962213del' -
Mistake: Passing a chromosome name toinstead of a sequence accession Fix: Use the numeric chromosome ID (e.g.
resolve-variant) or a RefSeq accession like8NC_000008.11 -
Mistake: Usingon
--fullwithout needing it Fix: The abbreviated output covers most use cases;get-variantreturns 50–500 KB+ of JSON--full -
Mistake: Expectingto return all results by default Fix: The default
search-regionis 500; check--retmaxin the output to see if results were truncatedtotal_available -
Mistake: Using GRCh37 coordinates withFix:
search-regionalways uses GRCh38 positions; lift over coordinates first if starting from GRCh37search-region -
Mistake: Manually retryingor
resolve-variantwith a differentresolve-hgvswhen the first call fails Fix: The script automatically tries GRCh38 then GRCh37; a single call is sufficient--assembly -
Mistake: Passingor
Xas the chromosome value Fix: Use the numeric equivalents:Yfor chromosome X and23for chromosome Y. The CLI treats chromosomes numerically by default.24