clinpgx-database

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ClinPGx Database

ClinPGx数据库

Overview

概述

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.
ClinPGx(临床药物基因组学数据库)是临床药物基因组学信息的综合资源,是PharmGKB的继任者。它整合了来自PharmGKB、CPIC和PharmCAT的数据,提供经过整理的、关于遗传变异如何影响药物反应的信息。可访问基因-药物配对、临床指南、等位基因功能和药物标签,以用于精准医疗应用。

When to Use This Skill

何时使用该工具

This skill should be used when:
  • Gene-drug interactions: Querying how genetic variants affect drug metabolism, efficacy, or toxicity
  • CPIC guidelines: Accessing evidence-based clinical practice guidelines for pharmacogenetics
  • Allele information: Retrieving allele function, frequency, and phenotype data
  • Drug labels: Exploring FDA and other regulatory pharmacogenomic drug labeling
  • Pharmacogenomic annotations: Accessing curated literature on gene-drug-disease relationships
  • Clinical decision support: Using PharmDOG tool for phenoconversion and custom genotype interpretation
  • Precision medicine: Implementing pharmacogenomic testing in clinical practice
  • Drug metabolism: Understanding CYP450 and other pharmacogene functions
  • Personalized dosing: Finding genotype-guided dosing recommendations
  • Adverse drug reactions: Identifying genetic risk factors for drug toxicity
该工具适用于以下场景:
  • 基因-药物相互作用:查询遗传变异如何影响药物代谢、疗效或毒性
  • CPIC指南:获取基于循证的药物基因组学临床实践指南
  • 等位基因信息:检索等位基因功能、频率和表型数据
  • 药物标签:查看FDA及其他监管机构的药物基因组学药物标签
  • 药物基因组学注释:获取经过整理的基因-药物-疾病关系相关文献
  • 临床决策支持:使用PharmDOG工具进行表型转换和自定义基因型解读
  • 精准医疗:在临床实践中实施药物基因组学检测
  • 药物代谢:了解CYP450及其他药物基因的功能
  • 个性化用药:获取基于基因型的用药剂量建议
  • 药物不良反应:识别药物毒性的遗传风险因素

Installation and Setup

安装与设置

Python API Access

Python API访问

The ClinPGx REST API provides programmatic access to all database resources. Basic setup:
bash
uv pip install requests
ClinPGx REST API提供对所有数据库资源的程序化访问。基础设置:
bash
uv pip install requests

API Endpoint

API端点

python
BASE_URL = "https://api.clinpgx.org/v1/"
Rate Limits:
  • 2 requests per second maximum
  • Excessive requests will result in HTTP 429 (Too Many Requests) response
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
python
BASE_URL = "https://api.clinpgx.org/v1/"
速率限制:
  • 最大每秒2次请求
  • 请求过多将返回HTTP 429(请求过多)响应
身份验证:基础访问无需身份验证
数据许可:知识共享署名-相同方式共享4.0国际许可协议
若大量使用API,请发送邮件至api@clinpgx.org通知ClinPGx团队

Core Capabilities

核心功能

1. Gene Queries

1. 基因查询

Retrieve gene information including function, clinical annotations, and pharmacogenomic significance:
python
import requests
检索基因信息,包括功能、临床注释和药物基因组学意义:
python
import requests

Get gene details

获取基因详情

response = requests.get("https://api.clinpgx.org/v1/gene/CYP2D6") gene_data = response.json()
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**:
- **CYP450 enzymes**: CYP2D6, CYP2C19, CYP2C9, CYP3A4, CYP3A5
- **Transporters**: SLCO1B1, ABCB1, ABCG2
- **Other metabolizers**: TPMT, DPYD, NUDT15, UGT1A1
- **Receptors**: OPRM1, HTR2A, ADRB1
- **HLA genes**: HLA-B, HLA-A
response = requests.get("https://api.clinpgx.org/v1/gene", params={"q": "CYP"}) genes = response.json()

**关键药物基因**:
- **CYP450酶**:CYP2D6、CYP2C19、CYP2C9、CYP3A4、CYP3A5
- **转运体**:SLCO1B1、ABCB1、ABCG2
- **其他代谢酶**:TPMT、DPYD、NUDT15、UGT1A1
- **受体**:OPRM1、HTR2A、ADRB1
- **HLA基因**:HLA-B、HLA-A

2. Drug and Chemical Queries

2. 药物与化学物质查询

Retrieve drug information including pharmacogenomic annotations and mechanisms:
python
undefined
检索药物信息,包括药物基因组学注释和作用机制:
python
undefined

Get drug details

获取药物详情

response = requests.get("https://api.clinpgx.org/v1/chemical/PA448515") # Warfarin drug_data = response.json()
response = requests.get("https://api.clinpgx.org/v1/chemical/PA448515") # 华法林 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**:
- Anticoagulants (warfarin, clopidogrel)
- Antidepressants (SSRIs, TCAs)
- Immunosuppressants (tacrolimus, azathioprine)
- Oncology drugs (5-fluorouracil, irinotecan, tamoxifen)
- Cardiovascular drugs (statins, beta-blockers)
- Pain medications (codeine, tramadol)
- Antivirals (abacavir)
response = requests.get("https://api.clinpgx.org/v1/chemical", params={"name": "warfarin"}) drugs = response.json()

**具有药物基因组学意义的药物类别**:
- 抗凝药(华法林、氯吡格雷)
- 抗抑郁药(SSRIs、TCAs)
- 免疫抑制剂(他克莫司、硫唑嘌呤)
- 肿瘤药物(5-氟尿嘧啶、伊立替康、他莫昔芬)
- 心血管药物(他汀类、β受体阻滞剂)
- 止痛药(可待因、曲马多)
- 抗病毒药(阿巴卡韦)

3. Gene-Drug Pair Queries

3. 基因-药物配对查询

Access curated gene-drug relationships with clinical annotations:
python
undefined
访问经过整理的基因-药物关系及临床注释:
python
undefined

Get gene-drug pair information

获取基因-药物配对信息

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": "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**:
- CPIC (Clinical Pharmacogenetics Implementation Consortium)
- DPWG (Dutch Pharmacogenetics Working Group)
- FDA (Food and Drug Administration) labels
- Peer-reviewed literature summary annotations
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair", params={"gene": "CYP2C19"}) all_pairs = response.json()

**临床注释来源**:
- CPIC(临床药物基因组学实施联盟)
- DPWG(荷兰药物基因组学工作组)
- FDA(美国食品药品监督管理局)标签
- 经过整理的同行评议文献注释

4. CPIC Guidelines

4. CPIC指南

Access evidence-based clinical practice guidelines:
python
undefined
访问基于循证的临床实践指南:
python
undefined

Get CPIC guideline

获取CPIC指南

response = requests.get("https://api.clinpgx.org/v1/guideline/PA166104939") guideline = response.json()
response = requests.get("https://api.clinpgx.org/v1/guideline/PA166104939") guideline = response.json()

List all CPIC guidelines

列出所有CPIC指南

response = requests.get("https://api.clinpgx.org/v1/guideline", params={"source": "CPIC"}) guidelines = response.json()

**CPIC guideline components**:
- Gene-drug pairs covered
- Clinical recommendations by phenotype
- Evidence levels and strength ratings
- Supporting literature
- Downloadable PDFs and supplementary materials
- Implementation considerations

**Example guidelines**:
- CYP2D6-codeine (avoid in ultra-rapid metabolizers)
- CYP2C19-clopidogrel (alternative therapy for poor metabolizers)
- TPMT-azathioprine (dose reduction for intermediate/poor metabolizers)
- DPYD-fluoropyrimidines (dose adjustment based on activity)
- HLA-B*57:01-abacavir (avoid if positive)
response = requests.get("https://api.clinpgx.org/v1/guideline", params={"source": "CPIC"}) guidelines = response.json()

**CPIC指南组成部分**:
- 涵盖的基因-药物配对
- 按表型分类的临床建议
- 证据等级和强度评级
- 支持文献
- 可下载的PDF及补充材料
- 实施注意事项

**示例指南**:
- CYP2D6-可待因(超快代谢者避免使用)
- CYP2C19-氯吡格雷(弱代谢者使用替代疗法)
- TPMT-硫唑嘌呤(中/弱代谢者调整剂量)
- DPYD-氟嘧啶类药物(根据活性调整剂量)
- HLA-B*57:01-阿巴卡韦(阳性者避免使用)

5. Allele and Variant Information

5. 等位基因与变异信息

Query allele function and frequency data:
python
undefined
查询等位基因功能和频率数据:
python
undefined

Get allele information

获取等位基因信息

response = requests.get("https://api.clinpgx.org/v1/allele/CYP2D6*4") allele_data = response.json()
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**:
- Functional status (normal, decreased, no function, increased, uncertain)
- Population frequencies across ethnic groups
- Defining variants (SNPs, indels, CNVs)
- Phenotype assignment
- References to PharmVar and other nomenclature systems

**Phenotype categories**:
- **Ultra-rapid metabolizer** (UM): Increased enzyme activity
- **Normal metabolizer** (NM): Normal enzyme activity
- **Intermediate metabolizer** (IM): Reduced enzyme activity
- **Poor metabolizer** (PM): Little to no enzyme activity
response = requests.get("https://api.clinpgx.org/v1/allele", params={"gene": "CYP2D6"}) alleles = response.json()

**等位基因信息包括**:
- 功能状态(正常、降低、无功能、增强、不确定)
- 不同族群的人群频率
- 定义变异(SNP、插入缺失、拷贝数变异)
- 表型分配
- 与PharmVar及其他命名系统的关联参考

**表型类别**:
- **超快代谢者**(UM):酶活性增强
- **正常代谢者**(NM):酶活性正常
- **中间代谢者**(IM):酶活性降低
- **弱代谢者**(PM):酶活性极低或无

6. Variant Annotations

6. 变异注释

Access clinical annotations for specific genetic variants:
python
undefined
访问特定遗传变异的临床注释:
python
undefined

Get variant information

获取变异信息

response = requests.get("https://api.clinpgx.org/v1/variant/rs4244285") variant_data = response.json()
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**:
- rsID and genomic coordinates
- Gene and functional consequence
- Allele associations
- Clinical significance
- Population frequencies
- Literature references
response = requests.get("https://api.clinpgx.org/v1/variant", params={"chromosome": "10", "position": "94781859"}) variants = response.json()

**变异数据包括**:
- rsID和基因组坐标
- 基因和功能影响
- 等位基因关联
- 临床意义
- 人群频率
- 文献参考

7. Clinical Annotations

7. 临床注释

Retrieve curated literature annotations (formerly PharmGKB clinical annotations):
python
undefined
检索经过整理的文献注释(原PharmGKB临床注释):
python
undefined

Get clinical annotations

获取临床注释

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={"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):
- **Level 1A**: High-quality evidence, CPIC/FDA/DPWG guidelines
- **Level 1B**: High-quality evidence, not yet guideline
- **Level 2A**: Moderate evidence from well-designed studies
- **Level 2B**: Moderate evidence with some limitations
- **Level 3**: Limited or conflicting evidence
- **Level 4**: Case reports or weak evidence
response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation", params={"evidenceLevel": "1A"}) high_evidence = response.json()

**证据等级**(从高到低):
- **1A级**:高质量证据,来自CPIC/FDA/DPWG指南
- **1B级**:高质量证据,尚未纳入指南
- **2A级**:来自设计良好研究的中等质量证据
- **2B级**:中等质量证据,存在一定局限性
- **3级**:有限或相互矛盾的证据
- **4级**:病例报告或弱证据

8. Drug Labels

8. 药物标签

Access pharmacogenomic information from drug labels:
python
undefined
访问药物标签中的药物基因组学信息:
python
undefined

Get drug labels with PGx information

获取包含药物基因组学信息的药物标签

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={"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**:
- Testing recommendations
- Dosing guidance by genotype
- Warnings and precautions
- Biomarker information
- Regulatory source (FDA, EMA, PMDA, etc.)
response = requests.get("https://api.clinpgx.org/v1/drugLabel", params={"source": "FDA"}) fda_labels = response.json()

**标签信息包括**:
- 检测建议
- 基于基因型的用药剂量指导
- 警告与注意事项
- 生物标志物信息
- 监管来源(FDA、EMA、PMDA等)

9. Pathways

9. 通路

Explore pharmacokinetic and pharmacodynamic pathways:
python
undefined
探索药代动力学和药效动力学通路:
python
undefined

Get pathway information

获取通路信息

response = requests.get("https://api.clinpgx.org/v1/pathway/PA146123006") # Warfarin pathway pathway_data = response.json()
response = requests.get("https://api.clinpgx.org/v1/pathway/PA146123006") # 华法林通路 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:
- Drug metabolism steps
- Enzymes and transporters involved
- Gene variants affecting each step
- Downstream effects on efficacy/toxicity
- Interactions with other pathways
response = requests.get("https://api.clinpgx.org/v1/pathway", params={"drug": "warfarin"}) pathways = response.json()

**通路图展示**:
- 药物代谢步骤
- 涉及的酶和转运体
- 影响各步骤的基因变异
- 对疗效/毒性的下游影响
- 与其他通路的相互作用

Query Workflow

查询工作流

Workflow 1: Clinical Decision Support for Drug Prescription

工作流1:药物处方的临床决策支持

  1. Identify patient genotype for relevant pharmacogenes:
    python
    # Example: Patient is CYP2C19 *1/*2 (intermediate metabolizer)
    response = requests.get("https://api.clinpgx.org/v1/allele/CYP2C19*2")
    allele_function = response.json()
  2. Query gene-drug pairs for medication of interest:
    python
    response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
                           params={"gene": "CYP2C19", "drug": "clopidogrel"})
    pair_info = response.json()
  3. Retrieve CPIC guideline for dosing recommendations:
    python
    response = requests.get("https://api.clinpgx.org/v1/guideline",
                           params={"gene": "CYP2C19", "drug": "clopidogrel"})
    guideline = response.json()
    # Recommendation: Alternative antiplatelet therapy for IM/PM
  4. Check drug label for regulatory guidance:
    python
    response = requests.get("https://api.clinpgx.org/v1/drugLabel",
                           params={"drug": "clopidogrel"})
    label = response.json()
  1. 确定患者相关药物基因的基因型:
    python
    # 示例:患者为CYP2C19 *1/*2(中间代谢者)
    response = requests.get("https://api.clinpgx.org/v1/allele/CYP2C19*2")
    allele_function = response.json()
  2. 查询目标药物的基因-药物配对:
    python
    response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
                           params={"gene": "CYP2C19", "drug": "clopidogrel"})
    pair_info = response.json()
  3. 获取CPIC指南以获取用药剂量建议:
    python
    response = requests.get("https://api.clinpgx.org/v1/guideline",
                           params={"gene": "CYP2C19", "drug": "clopidogrel"})
    guideline = response.json()
    # 建议:中间/弱代谢者使用替代抗血小板疗法
  4. 查看药物标签获取监管指导:
    python
    response = requests.get("https://api.clinpgx.org/v1/drugLabel",
                           params={"drug": "clopidogrel"})
    label = response.json()

Workflow 2: Gene Panel Analysis

工作流2:基因 panel 分析

  1. Get list of pharmacogenes in clinical panel:
    python
    pgx_panel = ["CYP2C19", "CYP2D6", "CYP2C9", "TPMT", "DPYD", "SLCO1B1"]
  2. For each gene, retrieve all drug interactions:
    python
    all_interactions = {}
    for gene in pgx_panel:
        response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
                               params={"gene": gene})
        all_interactions[gene] = response.json()
  3. Filter for CPIC guideline-level evidence:
    python
    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']}")
  4. Generate patient report with actionable pharmacogenomic findings.
  1. 获取临床panel中的药物基因列表:
    python
    pgx_panel = ["CYP2C19", "CYP2D6", "CYP2C9", "TPMT", "DPYD", "SLCO1B1"]
  2. 为每个基因检索所有药物相互作用:
    python
    all_interactions = {}
    for gene in pgx_panel:
        response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
                               params={"gene": gene})
        all_interactions[gene] = response.json()
  3. 筛选CPIC指南级别的证据:
    python
    for gene, pairs in all_interactions.items():
        for pair in pairs:
            if pair.get('cpicLevel'):  # 存在CPIC指南
                print(f"{gene} - {pair['drug']}: {pair['cpicLevel']}")
  4. 生成包含可操作药物基因组学发现的患者报告.

Workflow 3: Drug Safety Assessment

工作流3:药物安全性评估

  1. Query drug for PGx associations:
    python
    response = requests.get("https://api.clinpgx.org/v1/chemical",
                           params={"name": "abacavir"})
    drug_id = response.json()[0]['id']
  2. Get clinical annotations:
    python
    response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
                           params={"drug": drug_id})
    annotations = response.json()
  3. Check for HLA associations and toxicity risk:
    python
    for annotation in annotations:
        if 'HLA' in annotation.get('genes', []):
            print(f"Toxicity risk: {annotation['phenotype']}")
            print(f"Evidence level: {annotation['evidenceLevel']}")
  4. Retrieve screening recommendations from guidelines and labels.
  1. 查询药物的药物基因组学关联:
    python
    response = requests.get("https://api.clinpgx.org/v1/chemical",
                           params={"name": "abacavir"})
    drug_id = response.json()[0]['id']
  2. 获取临床注释:
    python
    response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
                           params={"drug": drug_id})
    annotations = response.json()
  3. 检查HLA关联和毒性风险:
    python
    for annotation in annotations:
        if 'HLA' in annotation.get('genes', []):
            print(f"毒性风险: {annotation['phenotype']}")
            print(f"证据等级: {annotation['evidenceLevel']}")
  4. 从指南和标签中获取筛查建议.

Workflow 4: Research Analysis - Population Pharmacogenomics

工作流4:研究分析 - 人群药物基因组学

  1. Get allele frequencies for population comparison:
    python
    response = requests.get("https://api.clinpgx.org/v1/allele",
                           params={"gene": "CYP2D6"})
    alleles = response.json()
  2. Extract population-specific frequencies:
    python
    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
        }
  3. Calculate phenotype distributions by population:
    python
    # Combine allele frequencies with function to predict phenotypes
    phenotype_dist = calculate_phenotype_frequencies(frequency_data)
  4. Analyze implications for drug dosing in diverse populations.
  1. 获取用于人群比较的等位基因频率:
    python
    response = requests.get("https://api.clinpgx.org/v1/allele",
                           params={"gene": "CYP2D6"})
    alleles = response.json()
  2. 提取特定人群的频率:
    python
    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
        }
  3. 计算不同人群的表型分布:
    python
    # 结合等位基因频率与功能预测表型
    phenotype_dist = calculate_phenotype_frequencies(frequency_data)
  4. 分析不同人群中药物剂量的意义.

Workflow 5: Literature Evidence Review

工作流5:文献证据回顾

  1. Search for gene-drug pair:
    python
    response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
                           params={"gene": "TPMT", "drug": "azathioprine"})
    pair = response.json()
  2. Retrieve all clinical annotations:
    python
    response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
                           params={"gene": "TPMT", "drug": "azathioprine"})
    annotations = response.json()
  3. Filter by evidence level and publication date:
    python
    high_quality = [a for a in annotations
                    if a['evidenceLevel'] in ['1A', '1B', '2A']]
  4. Extract PMIDs and retrieve full references:
    python
    pmids = [a['pmid'] for a in high_quality if 'pmid' in a]
    # Use PubMed skill to retrieve full citations
  1. 搜索基因-药物配对:
    python
    response = requests.get("https://api.clinpgx.org/v1/geneDrugPair",
                           params={"gene": "TPMT", "drug": "azathioprine"})
    pair = response.json()
  2. 检索所有临床注释:
    python
    response = requests.get("https://api.clinpgx.org/v1/clinicalAnnotation",
                           params={"gene": "TPMT", "drug": "azathioprine"})
    annotations = response.json()
  3. 按证据等级和发表日期筛选:
    python
    high_quality = [a for a in annotations
                    if a['evidenceLevel'] in ['1A', '1B', '2A']]
  4. 提取PMID并检索完整参考文献:
    python
    pmids = [a['pmid'] for a in high_quality if 'pmid' in a]
    # 使用PubMed工具检索完整引文

Rate Limiting and Best Practices

速率限制与最佳实践

Rate Limit Compliance

速率限制合规

python
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
python
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

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()
undefined
genes = ["CYP2D6", "CYP2C19", "CYP2C9"] for gene in genes: response = rate_limited_request( "https://api.clinpgx.org/v1/gene/" + gene ) data = response.json()
undefined

Error Handling

错误处理

python
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)
python
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)

Caching Results

结果缓存

python
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
python
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

Usage

使用示例

gene_data = cached_query( 'cyp2d6_cache.json', rate_limited_request, "https://api.clinpgx.org/v1/gene/CYP2D6" )
undefined
gene_data = cached_query( 'cyp2d6_cache.json', rate_limited_request, "https://api.clinpgx.org/v1/gene/CYP2D6" )
undefined

PharmDOG Tool

PharmDOG工具

PharmDOG (formerly DDRx) is ClinPGx's clinical decision support tool for interpreting pharmacogenomic test results:
Key features:
  • Phenoconversion calculator: Adjusts phenotype predictions for drug-drug interactions affecting CYP2D6
  • Custom genotypes: Input patient genotypes to get phenotype predictions
  • QR code sharing: Generate shareable patient reports
  • Flexible guidance sources: Select which guidelines to apply (CPIC, DPWG, FDA)
  • Multi-drug analysis: Assess multiple medications simultaneously
Use cases:
  • Clinical interpretation of PGx panel results
  • Medication review for patients with known genotypes
  • Patient education materials
  • Point-of-care decision support
PharmDOG(原DDRx)是ClinPGx的临床决策支持工具,用于解读药物基因组学检测结果:
核心功能:
  • 表型转换计算器:调整受CYP2D6相关药物相互作用影响的表型预测
  • 自定义基因型:输入患者基因型以获取表型预测
  • 二维码分享:生成可分享的患者报告
  • 灵活的指导来源:选择要应用的指南(CPIC、DPWG、FDA)
  • 多药物分析:同时评估多种药物
使用场景:
  • 药物基因组学panel结果的临床解读
  • 已知基因型患者的用药审查
  • 患者教育材料
  • 床旁决策支持

Resources

资源

scripts/query_clinpgx.py

scripts/query_clinpgx.py

Python script with ready-to-use functions for common ClinPGx queries:
  • get_gene_info(gene_symbol)
    - Retrieve gene details
  • get_drug_info(drug_name)
    - Get drug information
  • get_gene_drug_pairs(gene, drug)
    - Query gene-drug interactions
  • get_cpic_guidelines(gene, drug)
    - Retrieve CPIC guidelines
  • get_alleles(gene)
    - Get all alleles for a gene
  • get_clinical_annotations(gene, drug, evidence_level)
    - Query literature annotations
  • get_drug_labels(drug)
    - Retrieve pharmacogenomic drug labels
  • search_variants(rsid)
    - Search by variant rsID
  • export_to_dataframe(data)
    - Convert results to pandas DataFrame
Consult this script for implementation examples with proper rate limiting and error handling.
包含常用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
如需包含正确速率限制和错误处理的实现示例,请参考该脚本。

references/api_reference.md

references/api_reference.md

Comprehensive API documentation including:
  • Complete endpoint listing with parameters
  • Request/response format specifications
  • Example queries for each endpoint
  • Filter operators and search patterns
  • Data schema definitions
  • Rate limiting details
  • Authentication requirements (if any)
  • Troubleshooting common errors
Refer to this document when detailed API information is needed or when constructing complex queries.
全面的API文档,包括:
  • 完整的端点列表及参数
  • 请求/响应格式规范
  • 每个端点的示例查询
  • 筛选操作符和搜索模式
  • 数据模式定义
  • 速率限制详情
  • 身份验证要求(若有)
  • 常见错误排查
当需要详细API信息或构建复杂查询时,请参考该文档。

Important Notes

重要说明

Data Sources and Integration

数据源与整合

ClinPGx consolidates multiple authoritative sources:
  • PharmGKB: Curated pharmacogenomics knowledge base (now part of ClinPGx)
  • CPIC: Evidence-based clinical implementation guidelines
  • PharmCAT: Allele calling and phenotype interpretation tool
  • DPWG: Dutch pharmacogenetics guidelines
  • FDA/EMA labels: Regulatory pharmacogenomic information
As of July 2025, all PharmGKB URLs redirect to corresponding ClinPGx pages.
ClinPGx整合了多个权威来源的数据:
  • PharmGKB:经过整理的药物基因组学知识库(现属于ClinPGx)
  • CPIC:基于循证的临床实施指南
  • PharmCAT:等位基因识别和表型解读工具
  • DPWG:荷兰药物基因组学指南
  • FDA/EMA标签:监管机构的药物基因组学信息
截至2025年7月,所有PharmGKB URL均重定向至对应的ClinPGx页面。

Clinical Implementation Considerations

临床实施注意事项

  • Evidence levels: Always check evidence strength before clinical application
  • Population differences: Allele frequencies vary significantly across populations
  • Phenoconversion: Consider drug-drug interactions that affect enzyme activity
  • Multi-gene effects: Some drugs affected by multiple pharmacogenes
  • Non-genetic factors: Age, organ function, drug interactions also affect response
  • Testing limitations: Not all clinically relevant alleles detected by all assays
  • 证据等级:临床应用前务必检查证据强度
  • 人群差异:等位基因频率在不同人群中差异显著
  • 表型转换:考虑影响酶活性的药物-药物相互作用
  • 多基因效应:部分药物受多个药物基因影响
  • 非遗传因素:年龄、器官功能、药物相互作用也会影响药物反应
  • 检测局限性:并非所有临床相关等位基因都能被所有检测方法识别

Data Updates

数据更新

  • ClinPGx continuously updates with new evidence and guidelines
  • Check publication dates for clinical annotations
  • Monitor ClinPGx Blog (https://blog.clinpgx.org/) for announcements
  • CPIC guidelines updated as new evidence emerges
  • PharmVar provides nomenclature updates for allele definitions
  • ClinPGx持续更新新证据和指南
  • 检查临床注释的发表日期
  • 关注ClinPGx博客(https://blog.clinpgx.org/)获取公告
  • CPIC指南会随新证据出现而更新
  • PharmVar提供等位基因定义的命名更新

API Stability

API稳定性

  • API endpoints are relatively stable but may change during development
  • Parameters and response formats subject to modification
  • Monitor API changelog and ClinPGx blog for updates
  • Consider version pinning for production applications
  • Test API changes in development before production deployment
  • API端点相对稳定,但开发过程中可能会有变化
  • 参数和响应格式可能会修改
  • 关注API变更日志和ClinPGx博客获取更新
  • 生产应用建议固定版本
  • 生产部署前在开发环境测试API变更

Common Use Cases

常见使用场景

Pre-emptive Pharmacogenomic Testing

预防性药物基因组学检测

Query all clinically actionable gene-drug pairs to guide panel selection:
python
undefined
查询所有具有临床可操作性的基因-药物配对以指导panel选择:
python
undefined

Get all CPIC guideline pairs

获取所有CPIC指南推荐的配对

response = requests.get("https://api.clinpgx.org/v1/geneDrugPair", params={"cpicLevel": "A"}) # Level A recommendations actionable_pairs = response.json()
undefined
response = requests.get("https://api.clinpgx.org/v1/geneDrugPair", params={"cpicLevel": "A"}) # A级推荐 actionable_pairs = response.json()
undefined

Medication Therapy Management

药物治疗管理

Review patient medications against known genotypes:
python
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
根据已知基因型审查患者用药:
python
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})
        # 检查相互作用和用药剂量指导

Clinical Trial Eligibility

临床试验资格

Screen for pharmacogenomic contraindications:
python
undefined
筛查药物基因组学禁忌证:
python
undefined

Check for HLA-B*57:01 before abacavir trial

阿巴卡韦临床试验前检查HLA-B*57:01

response = requests.get("https://api.clinpgx.org/v1/geneDrugPair", params={"gene": "HLA-B", "drug": "abacavir"}) pair_info = response.json()
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

CPIC建议:HLA-B*57:01阳性者禁用

undefined
undefined

Additional Resources

额外资源