variant-genomic-location
$
npx mdskill add InternScience/scp/variant-genomic-location```tex Step 1: Query NCBI dbSNP REST API to get variant position, ref/alt alleles, gene association. API: GET https://api.ncbi.nlm.nih.gov/variation/v0/refsnp/{rsid_number}
SKILL.md
.github/skills/variant-genomic-locationView on GitHub ↗
---
name: variant-genomic-location
description: "Query dbSNP + NCBI Gene to get variant genomic position (chromosome, coordinates, ref/alt alleles, mutation type) and associated gene coordinates."
license: MIT license
metadata:
skill-author: PJLab
---
# dbSNP Variant Query
## Usage
### Tool Description
```tex
Step 1: Query NCBI dbSNP REST API to get variant position, ref/alt alleles, gene association.
API: GET https://api.ncbi.nlm.nih.gov/variation/v0/refsnp/{rsid_number}
Step 2: Query NCBI Gene API to get the full coordinate range of the associated gene.
API: GET https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id={gene_id}&retmode=json
Args:
rs_id (str): dbSNP rsID (e.g. "rs7412")
Return:
染色体, 突变位置(0-based start/end), 突变类型(SNV/insertion/deletion),
ref/alt等位基因, 关联基因名称及其完整坐标范围.
```
### Query Example
```python
import requests
rs_id = "rs7412"
# ── Step 1: dbSNP 查询变异信息 ──
url = f"https://api.ncbi.nlm.nih.gov/variation/v0/refsnp/{rs_id.replace('rs','')}"
resp = requests.get(url, timeout=30).json()
snapshot = resp.get("primary_snapshot_data", {})
variant_type = snapshot.get("variant_type", "unknown") # snv, ins, del 等
# 提取 GRCh38 坐标
chrom, start, end, ref, alt, hgvs = "", 0, 0, "", "", ""
for p in snapshot.get("placements_with_allele", []):
for trait in p.get("placement_annot", {}).get("seq_id_traits_by_assembly", []):
if "GRCh38" in trait.get("assembly_name", ""):
for allele in p.get("alleles", []):
spdi = allele.get("allele", {}).get("spdi", {})
r = spdi.get("deleted_sequence", "")
a = spdi.get("inserted_sequence", "")
if r != a:
chrom = spdi.get("seq_id", "")
start = spdi.get("position", 0)
ref, alt = r, a
end = start + len(ref)
hgvs = allele.get("hgvs", "")
# 判断突变类型
if len(ref) == 1 and len(alt) == 1:
mut_type = f"SNV (替换: {ref}→{alt})"
elif len(ref) > len(alt):
mut_type = f"Deletion (缺失: 丢失{len(ref)-len(alt)}个碱基)"
elif len(ref) < len(alt):
mut_type = f"Insertion (插入: 增加{len(alt)-len(ref)}个碱基)"
else:
mut_type = f"MNV (多核苷酸替换: {ref}→{alt})"
print(f"[dbSNP] rsID: {rs_id}")
print(f"[dbSNP] 染色体: {chrom}")
print(f"[dbSNP] 突变位置: start={start}, end={end} (0-based)")
print(f"[dbSNP] 突变类型: {mut_type}")
print(f"[dbSNP] HGVS: {hgvs}")
# 提取关联基因 ID 和名称
gene_id, gene_name = None, ""
for ann in snapshot.get("allele_annotations", []):
for asm in ann.get("assembly_annotation", []):
for gene in asm.get("genes", []):
gene_id = gene.get("id")
gene_name = gene.get("locus", "")
print(f"[dbSNP] 关联基因: {gene_name} ({gene.get('name','')}), NCBI Gene ID: {gene_id}")
break
if gene_id:
break
# ── Step 2: NCBI Gene 查询基因完整坐标范围 ──
if gene_id:
gene_url = f"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id={gene_id}&retmode=json"
gene_resp = requests.get(gene_url, timeout=30).json()
gene_info = gene_resp.get("result", {}).get(str(gene_id), {})
for g in gene_info.get("genomicinfo", []):
g_chr = g.get("chraccver", "")
g_start = g.get("chrstart", 0)
g_stop = g.get("chrstop", 0)
exon_count = g.get("exoncount", 0)
print(f"[Gene] {gene_name} 完整坐标: {g_chr}:{g_start}-{g_stop} (0-based)")
print(f"[Gene] 基因长度: {abs(g_stop - g_start) + 1} bp, 外显子数: {exon_count}")
```
More from InternScience/scp
- admet_druglikeness_reportADMET & Drug-Likeness Report - Generate comprehensive ADMET and drug-likeness report: molecular properties, H-bond analysis, hydrophobicity, topology, and ADMET prediction. Use this skill for medicinal chemistry tasks involving calculate mol basic info calculate mol hbond calculate mol hydrophobicity calculate mol topology pred molecule admet. Combines 5 tools from 2 SCP server(s).
- affinity_maturationAffinity Maturation Pipeline - Affinity maturation: compute binding affinity, predict mutations, compute hydrophilicity, and predict drug-target interaction. Use this skill for antibody engineering tasks involving ComputeAffinityCalculator zero shot sequence prediction ComputeHydrophilicity PredictDrugTargetInteraction. Combines 4 tools from 3 SCP server(s).
- alanine_scanning_pipelineAlanine Scanning Mutagenesis Pipeline - Alanine scanning: design scan, compute properties for each mutant, predict interactions, and compare. Use this skill for protein biochemistry tasks involving AlanineScanningDesigner ComputeProtPara PredictDrugTargetInteraction calculate protein sequence properties. Combines 4 tools from 3 SCP server(s).
- aliphatic_ring_analysisRing System Analysis - Analyze ring systems: count aliphatic carbocycles, analyze aromaticity, compute topology, and structure complexity. Use this skill for organic chemistry tasks involving GetAliphaticCarbocyclesNum AromaticityAnalyzer calculate mol topology calculate mol structure complexity. Combines 4 tools from 3 SCP server(s).
- alphafold_structure_pipelineAlphaFold Structure Analysis Pipeline - AlphaFold pipeline: download predicted structure, predict pockets, extract sequence, and compute properties. Use this skill for computational biology tasks involving download alphafold structure run fpocket extract pdb sequence calculate pdb basic info. Combines 4 tools from 3 SCP server(s).
- antibody_drug_developmentAntibody Drug Development - Develop antibody drug: target protein analysis, biotherapeutic lookup, protein properties, and interaction prediction. Use this skill for biologics tasks involving get uniprotkb entry by accession get biotherapeutic by name ComputeProtPara ComputeHydrophilicity. Combines 4 tools from 3 SCP server(s).
- antibody_target_analysisAntibody-Target Analysis - Analyze an antibody target: UniProt protein info, InterPro domains, protein properties, and biotherapeutic data from ChEMBL. Use this skill for immunology tasks involving get uniprotkb entry by accession query interpro ComputeProtPara get biotherapeutic by name. Combines 4 tools from 4 SCP server(s).
- atc_drug_classificationATC Drug Classification Lookup - Look up drug in ATC classification: ChEMBL ATC class, FDA drug info, PubChem compound, and mechanism of action. Use this skill for pharmacology tasks involving get atc class by level5 get mechanism of action by drug name get compound by name get drug by name. Combines 4 tools from 3 SCP server(s).
- atmospheric-science-calculationsCalculate atmospheric parameters including Coriolis parameter, geostrophic wind, heat index, potential temperature, and dewpoint for meteorology and climate science.
- binding_site_characterizationBinding Site Characterization - Characterize binding sites: predict pockets with fpocket and P2Rank, get binding site info from ChEMBL, and visualize. Use this skill for structural biology tasks involving run fpocket pred pocket prank get binding site by id visualize protein. Combines 4 tools from 3 SCP server(s).