clinpgx-database by davila7/claude-code-templates
npx skills add https://github.com/davila7/claude-code-templates --skill clinpgx-databaseClinPGx(临床药物基因组学数据库)是一个全面的临床药物基因组学信息资源,是 PharmGKB 的继任者。它整合了来自 PharmGKB、CPIC 和 PharmCAT 的数据,提供关于遗传变异如何影响药物反应的精选信息。可用于精准医疗应用,访问基因-药物对、临床指南、等位基因功能和药物标签。
此技能应在以下情况使用:
ClinPGx REST API 提供对所有数据库资源的编程访问。基本设置:
uv pip install requests
BASE_URL = "https://api.clinpgx.org/v1/"
:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
认证 :基本访问不需要认证
数据许可 :知识共享署名-相同方式共享 4.0 国际许可协议
对于大量使用 API 的情况,请通过 api@clinpgx.org 通知 ClinPGx 团队
检索基因信息,包括功能、临床注释和药物基因组学意义:
import requests
# 获取基因详情
response = requests.get("https://api.clinpgx.org/v1/gene/CYP2D6")
gene_data = response.json()
# 按名称搜索基因
response = requests.get("https://api.clinpgx.org/v1/gene",
params={"q": "CYP"})
genes = response.json()
关键药物基因 :
检索药物信息,包括药物基因组学注释和作用机制:
# 获取药物详情
response = requests.get("https://api.clinpgx.org/v1/chemical/PA448515") # 华法林
drug_data = response.json()
# 按名称搜索药物
response = requests.get("https://api.clinpgx.org/v1/chemical",
params={"name": "warfarin"})
drugs = response.json()
具有药物基因组学意义的药物类别 :
访问精选的基因-药物关系及其临床注释:
# 获取基因-药物对信息
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "CYP2D6", "drug": "codeine"})
pair_data = response.json()
# 获取某个基因的所有配对
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "CYP2C19"})
all_pairs = response.json()
临床注释来源 :
访问基于证据的临床实践指南 :
# 获取 CPIC 指南
response = requests.get("https://api.clinpgx.org/v1/guideline/PA166104939")
guideline = response.json()
# 列出所有 CPIC 指南
response = requests.get("https://api.clinpgx.org/v1/guideline",
params={"source": "CPIC"})
guidelines = response.json()
CPIC 指南组成部分 :
示例指南 :
查询等位基因功能和频率数据 :
# 获取等位基因信息
response = requests.get("https://api.clinpgx.org/v1/allele/CYP2D6*4")
allele_data = response.json()
# 获取某个基因的所有等位基因
response = requests.get("https://api.clinpgx.org/v1/allele",
params={"gene": "CYP2D6"})
alleles = response.json()
等位基因信息包括 :
表型类别 :
访问特定遗传变异的临床注释 :
# 获取变异信息
response = requests.get("https://api.clinpgx.org/v1/variant/rs4244285")
variant_data = response.json()
# 按位置搜索变异(如果支持)
response = requests.get("https://api.clinpgx.org/v1/variant",
params={"chromosome": "10", "position": "94781859"})
variants = response.json()
变异数据包括 :
检索精选的文献注释(原 PharmGKB 临床注释):
# 获取临床注释
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
params={"gene": "CYP2D6"})
annotations = response.json()
# 按证据级别筛选
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
params={"evidenceLevel": "1A"})
high_evidence = response.json()
证据级别(从高到低):
访问药物标签中的药物基因组学信息 :
# 获取带有 PGx 信息的药物标签
response = requests.get("https://api.clinpgx.org/v1/drugLabel",
params={"drug": "warfarin"})
labels = response.json()
# 按监管来源筛选
response = requests.get("https://api.clinpgx.org/v1/drugLabel",
params={"source": "FDA"})
fda_labels = response.json()
标签信息包括 :
探索药代动力学和药效学通路 :
# 获取通路信息
response = requests.get("https://api.clinpgx.org/v1/pathway/PA146123006") # 华法林通路
pathway_data = response.json()
# 按药物搜索通路
response = requests.get("https://api.clinpgx.org/v1/pathway",
params={"drug": "warfarin"})
pathways = response.json()
通路图显示 :
识别患者相关药物基因的基因型 :
# 示例:患者为 CYP2C19 *1/*2(中间代谢者)
response = requests.get("https://api.clinpgx.org/v1/allele/CYP2C19*2")
allele_function = response.json()
查询感兴趣药物的基因-药物对 :
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "CYP2C19", "drug": "clopidogrel"})
pair_info = response.json()
检索 CPIC 指南以获取给药建议:
response = requests.get("https://api.clinpgx.org/v1/guideline",
params={"gene": "CYP2C19", "drug": "clopidogrel"})
guideline = response.json()
# 建议:IM/PM 患者使用替代抗血小板疗法
检查药物标签以获取监管指导:
response = requests.get("https://api.clinpgx.org/v1/drugLabel",
params={"drug": "clopidogrel"})
label = response.json()
获取临床面板中的药物基因列表 :
pgx_panel = ["CYP2C19", "CYP2D6", "CYP2C9", "TPMT", "DPYD", "SLCO1B1"]
对于每个基因,检索所有药物相互作用 :
all_interactions = {}
for gene in pgx_panel:
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": gene})
all_interactions[gene] = response.json()
筛选出具有 CPIC 指南级别证据的 :
for gene, pairs in all_interactions.items():
for pair in pairs:
if pair.get('cpicLevel'): # 有 CPIC 指南
print(f"{gene} - {pair['drug']}: {pair['cpicLevel']}")
生成患者报告,包含可操作的药物基因组学发现。
查询药物的 PGx 关联 :
response = requests.get("https://api.clinpgx.org/v1/chemical",
params={"name": "abacavir"})
drug_id = response.json()[0]['id']
获取临床注释 :
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
params={"drug": drug_id})
annotations = response.json()
检查 HLA 关联和毒性风险:
for annotation in annotations:
if 'HLA' in annotation.get('genes', []):
print(f"毒性风险: {annotation['phenotype']}")
print(f"证据级别: {annotation['evidenceLevel']}")
从指南和标签中检索筛查建议。
获取等位基因频率用于人群比较:
response = requests.get("https://api.clinpgx.org/v1/allele",
params={"gene": "CYP2D6"})
alleles = response.json()
提取特定人群的频率 :
populations = ['European', 'African', 'East Asian', 'Latino']
frequency_data = {}
for allele in alleles:
allele_name = allele['name']
frequency_data[allele_name] = {
pop: allele.get(f'{pop}_frequency', 'N/A')
for pop in populations
}
按人群计算表型分布 :
# 结合等位基因频率和功能来预测表型
phenotype_dist = calculate_phenotype_frequencies(frequency_data)
分析对不同人群药物给药的影响。
搜索基因-药物对 :
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "TPMT", "drug": "azathioprine"})
pair = response.json()
检索所有临床注释 :
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
params={"gene": "TPMT", "drug": "azathioprine"})
annotations = response.json()
按证据级别和发表日期筛选 :
high_quality = [a for a in annotations
if a['evidenceLevel'] in ['1A', '1B', '2A']]
提取 PMID并检索完整参考文献:
pmids = [a['pmid'] for a in high_quality if 'pmid' in a]
# 使用 PubMed 技能检索完整引文
import time
def rate_limited_request(url, params=None, delay=0.5):
"""进行 API 请求并遵守速率限制(每秒最多 2 个请求)"""
response = requests.get(url, params=params)
time.sleep(delay) # 请求之间等待 0.5 秒
return response
# 在循环中使用
genes = ["CYP2D6", "CYP2C19", "CYP2C9"]
for gene in genes:
response = rate_limited_request(
"https://api.clinpgx.org/v1/gene/" + gene
)
data = response.json()
def safe_api_call(url, params=None, max_retries=3):
"""带有错误处理和重试机制的 API 调用"""
for attempt in range(max_retries):
try:
response = requests.get(url, params=params, timeout=10)
if response.status_code == 200:
return response.json()
elif response.status_code == 429:
# 超出速率限制
wait_time = 2 ** attempt # 指数退避
print(f"达到速率限制。等待 {wait_time}秒...")
time.sleep(wait_time)
else:
response.raise_for_status()
except requests.exceptions.RequestException as e:
print(f"尝试 {attempt + 1} 失败: {e}")
if attempt == max_retries - 1:
raise
time.sleep(1)
import json
from pathlib import Path
def cached_query(cache_file, api_func, *args, **kwargs):
"""缓存 API 结果以避免重复查询"""
cache_path = Path(cache_file)
if cache_path.exists():
with open(cache_path) as f:
return json.load(f)
result = api_func(*args, **kwargs)
with open(cache_path, 'w') as f:
json.dump(result, f, indent=2)
return result
# 用法
gene_data = cached_query(
'cyp2d6_cache.json',
rate_limited_request,
"https://api.clinpgx.org/v1/gene/CYP2D6"
)
PharmDOG(原 DDRx)是 ClinPGx 的临床决策支持工具,用于解读药物基因组学检测结果:
主要功能 :
使用场景 :
包含用于常见 ClinPGx 查询的即用型函数的 Python 脚本:
get_gene_info(gene_symbol) - 检索基因详情get_drug_info(drug_name) - 获取药物信息get_gene_drug_pairs(gene, drug) - 查询基因-药物相互作用get_cpic_guidelines(gene, drug) - 检索 CPIC 指南get_alleles(gene) - 获取某个基因的所有等位基因get_clinical_annotations(gene, drug, evidence_level) - 查询文献注释get_drug_labels(drug) - 检索药物基因组学药物标签search_variants(rsid) - 按变异 rsID 搜索export_to_dataframe(data) - 将结果转换为 pandas DataFrame请查阅此脚本以获取带有适当速率限制和错误处理的实现示例。
全面的 API 文档,包括:
当需要详细的 API 信息或构建复杂查询时,请参考此文档。
ClinPGx 整合了多个权威来源:
截至 2025 年 7 月,所有 PharmGKB URL 都重定向到相应的 ClinPGx 页面。
查询所有临床可操作的基因-药物对以指导面板选择:
# 获取所有 CPIC 指南对
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"cpicLevel": "A"}) # A 级建议
actionable_pairs = response.json()
根据已知基因型审查患者用药:
patient_genes = {"CYP2C19": "*1/*2", "CYP2D6": "*1/*1", "SLCO1B1": "*1/*5"}
medications = ["clopidogrel", "simvastatin", "escitalopram"]
for med in medications:
for gene in patient_genes:
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": gene, "drug": med})
# 检查相互作用和给药指导
筛查药物基因组学禁忌症:
# 在阿巴卡韦试验前检查 HLA-B*57:01
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "HLA-B", "drug": "abacavir"})
pair_info = response.json()
# CPIC:HLA-B*57:01 阳性者勿用
每周安装次数
125
代码仓库
GitHub 星标数
22.6K
首次出现
2026年1月21日
安全审计
安装于
claude-code107
opencode98
cursor94
gemini-cli93
antigravity88
codex83
ClinPGx (Clinical Pharmacogenomics Database) is a comprehensive resource for clinical pharmacogenomics information, successor to PharmGKB. It consolidates data from PharmGKB, CPIC, and PharmCAT, providing curated information on how genetic variation affects medication response. Access gene-drug pairs, clinical guidelines, allele functions, and drug labels for precision medicine applications.
This skill should be used when:
The ClinPGx REST API provides programmatic access to all database resources. Basic setup:
uv pip install requests
BASE_URL = "https://api.clinpgx.org/v1/"
Rate Limits :
Authentication : Not required for basic access
Data License : Creative Commons Attribution-ShareAlike 4.0 International License
For substantial API use, notify the ClinPGx team at api@clinpgx.org
Retrieve gene information including function, clinical annotations, and pharmacogenomic significance:
import requests
# Get gene details
response = requests.get("https://api.clinpgx.org/v1/gene/CYP2D6")
gene_data = response.json()
# Search for genes by name
response = requests.get("https://api.clinpgx.org/v1/gene",
params={"q": "CYP"})
genes = response.json()
Key pharmacogenes :
Retrieve drug information including pharmacogenomic annotations and mechanisms:
# Get drug details
response = requests.get("https://api.clinpgx.org/v1/chemical/PA448515") # Warfarin
drug_data = response.json()
# Search drugs by name
response = requests.get("https://api.clinpgx.org/v1/chemical",
params={"name": "warfarin"})
drugs = response.json()
Drug categories with pharmacogenomic significance :
Access curated gene-drug relationships with clinical annotations:
# Get gene-drug pair information
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "CYP2D6", "drug": "codeine"})
pair_data = response.json()
# Get all pairs for a gene
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "CYP2C19"})
all_pairs = response.json()
Clinical annotation sources :
Access evidence-based clinical practice guidelines :
# Get CPIC guideline
response = requests.get("https://api.clinpgx.org/v1/guideline/PA166104939")
guideline = response.json()
# List all CPIC guidelines
response = requests.get("https://api.clinpgx.org/v1/guideline",
params={"source": "CPIC"})
guidelines = response.json()
CPIC guideline components :
Example guidelines :
Query allele function and frequency data :
# Get allele information
response = requests.get("https://api.clinpgx.org/v1/allele/CYP2D6*4")
allele_data = response.json()
# Get all alleles for a gene
response = requests.get("https://api.clinpgx.org/v1/allele",
params={"gene": "CYP2D6"})
alleles = response.json()
Allele information includes :
Phenotype categories :
Access clinical annotations for specific genetic variants :
# Get variant information
response = requests.get("https://api.clinpgx.org/v1/variant/rs4244285")
variant_data = response.json()
# Search variants by position (if supported)
response = requests.get("https://api.clinpgx.org/v1/variant",
params={"chromosome": "10", "position": "94781859"})
variants = response.json()
Variant data includes :
Retrieve curated literature annotations (formerly PharmGKB clinical annotations):
# Get clinical annotations
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
params={"gene": "CYP2D6"})
annotations = response.json()
# Filter by evidence level
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
params={"evidenceLevel": "1A"})
high_evidence = response.json()
Evidence levels (from highest to lowest):
Access pharmacogenomic information from drug labels :
# Get drug labels with PGx information
response = requests.get("https://api.clinpgx.org/v1/drugLabel",
params={"drug": "warfarin"})
labels = response.json()
# Filter by regulatory source
response = requests.get("https://api.clinpgx.org/v1/drugLabel",
params={"source": "FDA"})
fda_labels = response.json()
Label information includes :
Explore pharmacokinetic and pharmacodynamic pathways :
# Get pathway information
response = requests.get("https://api.clinpgx.org/v1/pathway/PA146123006") # Warfarin pathway
pathway_data = response.json()
# Search pathways by drug
response = requests.get("https://api.clinpgx.org/v1/pathway",
params={"drug": "warfarin"})
pathways = response.json()
Pathway diagrams show:
Identify patient genotype for relevant pharmacogenes:
# Example: Patient is CYP2C19 *1/*2 (intermediate metabolizer)
response = requests.get("https://api.clinpgx.org/v1/allele/CYP2C19*2")
allele_function = response.json()
Query gene-drug pairs for medication of interest:
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "CYP2C19", "drug": "clopidogrel"})
pair_info = response.json()
Retrieve CPIC guideline for dosing recommendations:
response = requests.get("https://api.clinpgx.org/v1/guideline",
params={"gene": "CYP2C19", "drug": "clopidogrel"})
guideline = response.json()
# Recommendation: Alternative antiplatelet therapy for IM/PM
Check drug label for regulatory guidance:
response = requests.get("https://api.clinpgx.org/v1/drugLabel",
params={"drug": "clopidogrel"})
label = response.json()
Get list of pharmacogenes in clinical panel:
pgx_panel = ["CYP2C19", "CYP2D6", "CYP2C9", "TPMT", "DPYD", "SLCO1B1"]
For each gene, retrieve all drug interactions :
all_interactions = {}
for gene in pgx_panel:
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": gene})
all_interactions[gene] = response.json()
Filter for CPIC guideline-level evidence :
for gene, pairs in all_interactions.items():
for pair in pairs:
if pair.get('cpicLevel'): # Has CPIC guideline
print(f"{gene} - {pair['drug']}: {pair['cpicLevel']}")
Generate patient report with actionable pharmacogenomic findings.
Query drug for PGx associations :
response = requests.get("https://api.clinpgx.org/v1/chemical",
params={"name": "abacavir"})
drug_id = response.json()[0]['id']
Get clinical annotations :
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
params={"drug": drug_id})
annotations = response.json()
Check for HLA associations and toxicity risk:
for annotation in annotations:
if 'HLA' in annotation.get('genes', []):
print(f"Toxicity risk: {annotation['phenotype']}")
print(f"Evidence level: {annotation['evidenceLevel']}")
Retrieve screening recommendations from guidelines and labels.
Get allele frequencies for population comparison:
response = requests.get("https://api.clinpgx.org/v1/allele",
params={"gene": "CYP2D6"})
alleles = response.json()
Extract population-specific frequencies :
populations = ['European', 'African', 'East Asian', 'Latino']
frequency_data = {}
for allele in alleles:
allele_name = allele['name']
frequency_data[allele_name] = {
pop: allele.get(f'{pop}_frequency', 'N/A')
for pop in populations
}
Calculate phenotype distributions by population:
# Combine allele frequencies with function to predict phenotypes
phenotype_dist = calculate_phenotype_frequencies(frequency_data)
Analyze implications for drug dosing in diverse populations.
Search for gene-drug pair :
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "TPMT", "drug": "azathioprine"})
pair = response.json()
Retrieve all clinical annotations :
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
params={"gene": "TPMT", "drug": "azathioprine"})
annotations = response.json()
Filter by evidence level and publication date :
high_quality = [a for a in annotations
if a['evidenceLevel'] in ['1A', '1B', '2A']]
Extract PMIDs and retrieve full references:
pmids = [a['pmid'] for a in high_quality if 'pmid' in a]
# Use PubMed skill to retrieve full citations
import time
def rate_limited_request(url, params=None, delay=0.5):
"""Make API request with rate limiting (2 req/sec max)"""
response = requests.get(url, params=params)
time.sleep(delay) # Wait 0.5 seconds between requests
return response
# Use in loops
genes = ["CYP2D6", "CYP2C19", "CYP2C9"]
for gene in genes:
response = rate_limited_request(
"https://api.clinpgx.org/v1/gene/" + gene
)
data = response.json()
def safe_api_call(url, params=None, max_retries=3):
"""API call with error handling and retries"""
for attempt in range(max_retries):
try:
response = requests.get(url, params=params, timeout=10)
if response.status_code == 200:
return response.json()
elif response.status_code == 429:
# Rate limit exceeded
wait_time = 2 ** attempt # Exponential backoff
print(f"Rate limit hit. Waiting {wait_time}s...")
time.sleep(wait_time)
else:
response.raise_for_status()
except requests.exceptions.RequestException as e:
print(f"Attempt {attempt + 1} failed: {e}")
if attempt == max_retries - 1:
raise
time.sleep(1)
import json
from pathlib import Path
def cached_query(cache_file, api_func, *args, **kwargs):
"""Cache API results to avoid repeated queries"""
cache_path = Path(cache_file)
if cache_path.exists():
with open(cache_path) as f:
return json.load(f)
result = api_func(*args, **kwargs)
with open(cache_path, 'w') as f:
json.dump(result, f, indent=2)
return result
# Usage
gene_data = cached_query(
'cyp2d6_cache.json',
rate_limited_request,
"https://api.clinpgx.org/v1/gene/CYP2D6"
)
PharmDOG (formerly DDRx) is ClinPGx's clinical decision support tool for interpreting pharmacogenomic test results:
Key features :
Access : Available at https://www.clinpgx.org/pharmacogenomic-decision-support
Use cases :
Python script with ready-to-use functions for common ClinPGx queries:
get_gene_info(gene_symbol) - Retrieve gene detailsget_drug_info(drug_name) - Get drug informationget_gene_drug_pairs(gene, drug) - Query gene-drug interactionsget_cpic_guidelines(gene, drug) - Retrieve CPIC guidelinesget_alleles(gene) - Get all alleles for a geneget_clinical_annotations(gene, drug, evidence_level) - Query literature annotationsget_drug_labels(drug) - Retrieve pharmacogenomic drug labelssearch_variants(rsid) - Search by variant rsIDexport_to_dataframe(data) - Convert results to pandas DataFrameConsult this script for implementation examples with proper rate limiting and error handling.
Comprehensive API documentation including:
Refer to this document when detailed API information is needed or when constructing complex queries.
ClinPGx consolidates multiple authoritative sources:
As of July 2025, all PharmGKB URLs redirect to corresponding ClinPGx pages.
Query all clinically actionable gene-drug pairs to guide panel selection:
# Get all CPIC guideline pairs
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"cpicLevel": "A"}) # Level A recommendations
actionable_pairs = response.json()
Review patient medications against known genotypes:
patient_genes = {"CYP2C19": "*1/*2", "CYP2D6": "*1/*1", "SLCO1B1": "*1/*5"}
medications = ["clopidogrel", "simvastatin", "escitalopram"]
for med in medications:
for gene in patient_genes:
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": gene, "drug": med})
# Check for interactions and dosing guidance
Screen for pharmacogenomic contraindications:
# Check for HLA-B*57:01 before abacavir trial
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
params={"gene": "HLA-B", "drug": "abacavir"})
pair_info = response.json()
# CPIC: Do not use if HLA-B*57:01 positive
Weekly Installs
125
Repository
GitHub Stars
22.6K
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code107
opencode98
cursor94
gemini-cli93
antigravity88
codex83
lark-cli 共享规则:飞书资源操作指南与权限配置详解
39,000 周安装
社交媒体内容多平台适配器 - AI内容重制工具,一键优化Twitter/LinkedIn/Instagram/Facebook/TikTok
148 周安装
Rust Trait 探索器 - 快速查找 trait 实现与多态设计分析工具
232 周安装
阿里云轻量应用服务器SWAS-OPEN API管理指南:实例、磁盘、快照、镜像、防火墙
265 周安装
阿里云AIRec智能推荐管理技能 - 使用OpenAPI/SDK管理AI推荐引擎
265 周安装
阿里云文档API质量评审工具 - 自动化产品文档与OpenAPI评审报告生成
266 周安装
阿里云文档智能DocMind Node.js SDK使用教程:异步提取文档结构、文本和布局
266 周安装