# Bio Clinical Databases Dbsnp Queries

Query dbSNP for rsID lookups, variant annotations, and cross-references to other...

- Repository: https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills (3090 stars)
- Category: Engineering
- License: see repository
- Last updated: 2026-07-21
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-clinical-databases-dbsnp-queries -g -a claude-code -y`
Codex: `npx skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-clinical-databases-dbsnp-queries -g -a codex -y`
Cursor: `npx skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-clinical-databases-dbsnp-queries -g -a cursor -y`
Gemini CLI: `npx skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-clinical-databases-dbsnp-queries -g -a gemini-cli -y`

## Description

Query dbSNP for rsID lookups, variant annotations, and cross-references to other databases. Use when mapping between rsIDs and genomic coordinates or retrieving basic variant information.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

## Version Compatibility

Reference examples tested with: BioPython 1.83+, Entrez Direct 21.0+

Before using code patterns, verify installed versions match. If versions differ:
- Python: `pip show <package>` then `help(module.function)` to check signatures

If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.

# dbSNP Queries

**"Look up variant information by rsID"** → Retrieve variant annotations, genomic coordinates, and cross-references to ClinVar/gnomAD from dbSNP using REST API queries.
- Python: `myvariant.MyVariantInfo().getvariant('rs12345')`

## Query rsID via myvariant.info

**Goal:** Retrieve variant information including dbSNP, ClinVar, and gnomAD annotations by rsID.

**Approach:** Query myvariant.info with the rsID and request specific annotation fields.

```python
import myvariant

mv = myvariant.MyVariantInfo()

def get_rsid_info(rsid):
    '''Get variant info by rsID'''
    result = mv.getvariant(rsid, fields=['dbsnp', 'clinvar', 'gnomad_exome'])
    return result

result = get_rsid_info('rs121913527')
```

## Query via NCBI Entrez

**Goal:** Search and fetch dbSNP records directly from NCBI using Entrez E-utilities.

**Approach:** Use BioPython Entrez esearch to find SNP IDs, then efetch to retrieve full XML records.

```python
from Bio import Entrez
import xml.etree.ElementTree as ET

Entrez.email = 'your@email.com'

def search_dbsnp(rsid):
    '''Search dbSNP by rsID'''
    handle = Entrez.esearch(db='snp', term=rsid)
    record = Entrez.read(handle)
    handle.close()
    return record

def fetch_dbsnp(snp_id):
    '''Fetch dbSNP record by internal ID'''
    handle = Entrez.efetch(db='snp', id=snp_id, rettype='xml')
    xml_data = handle.read()
    handle.close()
    return xml_data
```

## Map Coordinates to rsID

**Goal:** Find the rsID corresponding to a genomic position and allele change.

The rest: https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills/blob/HEAD/skills/bio-clinical-databases-dbsnp-queries/SKILL.md
