Access ClinPGx pharmacogenomics data (successor to PharmGKB). Query gene-drug interactions, CPIC guidelines, allele functions, for precision medicine and genotype-guided dosing decisions.
76
66%
Does it follow best practices?
Impact
99%
1.70xAverage score across 3 eval scenarios
Passed
No known issues
Optimize this skill with Tessl
npx tessl skill review --optimize ./scientific-skills/clinpgx-database/SKILL.mdClinPGx (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 requestsBASE_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/PMCheck 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 citationsimport 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 guidanceScreen 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 positive71add64
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.