| name | gene-knowledge-integration |
| description | Given a gene symbol (e.g. TPMT), query 3 public databases (ClinGen CAR, PharmGKB, Monarch) to obtain gene registry info, FDA drug labels, clinical annotations, and gene-phenotype associations. Save all results into a JSON file. |
| license | MIT license |
| metadata | {"skill-author":"PJLab"} |
Gene Knowledge Integration
Usage
1. Tool Descriptions
This skill chains 3 public genomics/pharmacogenomics database APIs sequentially to build a comprehensive pharmacogenomics profile for a given gene.
Tool 1: ClinGen CAR — Gene Registry Info
Query ClinGen Allele Registry API to get gene registration information.
API: GET https://reg.genome.network/gene?HGNC.symbol={gene_symbol}
Args:
gene_symbol (str): HGNC gene symbol (e.g. "TPMT")
Return:
Gene record (dict): Contains @id (GN id), locus (genomic coordinates),
externalRecords (HGNC id/name/symbol, NCBI gene id, MANE transcripts).
Tool 2: PharmGKB (ClinPGx) — Gene Info, FDA Labels & Clinical Annotations
Query PharmGKB ClinPGx API to get pharmacogenomics information.
API (gene): GET https://api.clinpgx.org/v1/data/gene?symbol={gene_symbol}&view=base
API (labels): GET https://api.clinpgx.org/v1/data/label?source=fda&relatedGenes.symbol={gene_symbol}&view=base
API (clin): GET https://api.clinpgx.org/v1/data/clinicalAnnotation?location.genes.symbol={gene_symbol}&view=base
Args:
gene_symbol (str): HGNC gene symbol (e.g. "TPMT")
Return:
gene: PharmGKB gene record with accession id, alternate names, cross-references.
labels: FDA drug labels mentioning this gene (drug name, source, testing level).
clinicalAnnotations: Clinical annotations linking genotype to phenotype
(level of evidence, related chemicals, phenotype categories).
Tool 3: Monarch Initiative — Gene-Phenotype Associations
Query Monarch Initiative API to get gene-to-phenotype associations.
API: GET https://api-v3.monarchinitiative.org/v3/api/entity/{hgnc_id}/biolink:GeneToPhenotypicFeatureAssociation
Args:
hgnc_id (str): HGNC identifier (e.g. "HGNC:12014" for TPMT)
Return:
items (list): Each item contains subject (gene), object (phenotype HP term),
object_label (phenotype name), evidence_types, publications.
2. Gene Knowledge Integration
Query 3 databases (ClinGen CAR → PharmGKB → Monarch) for a given gene symbol, then save all results into a single JSON file {gene_symbol}_knowledge.json.
import requests
import json
from datetime import datetime
gene_symbol = "TPMT"
results = {"query_gene": gene_symbol, "timestamp": datetime.now().isoformat()}
car_url = f"https://reg.genome.network/gene?HGNC.symbol={gene_symbol}"
car_resp = requests.get(car_url, headers={"Accept": "application/json"}, timeout=30)
car = car_resp.json()
results["clingen_car"] = car
hgnc_id = car.get("externalRecords", {}).get("HGNC", {}).get("id", "")
print(f"[ClinGen CAR] 基因={gene_symbol}, GN_id={car.get('@id','')}, HGNC={hgnc_id}")
pgx_gene_url = f"https://api.clinpgx.org/v1/data/gene?symbol={gene_symbol}&view=base"
pgx_gene_resp = requests.get(pgx_gene_url, timeout=30)
pgx_gene = pgx_gene_resp.json()
results["pharmgkb_gene"] = pgx_gene
print(f"[PharmGKB] 基因信息获取成功")
pgx_label_url = (
f"https://api.clinpgx.org/v1/data/label"
f"?source=fda&relatedGenes.symbol={gene_symbol}&view=base"
)
pgx_labels_resp = requests.get(pgx_label_url, timeout=30)
pgx_labels = pgx_labels_resp.json()
results[] = pgx_labels
()
pgx_clin_url = (
)
pgx_clin_resp = requests.get(pgx_clin_url, timeout=)
pgx_clin = pgx_clin_resp.json()
results[] = pgx_clin
()
hgnc_id:
monarch_url = (
)
monarch_resp = requests.get(monarch_url, timeout=)
monarch = monarch_resp.json()
items = monarch.get(, [])
results[] = {
: (items),
: items
}
phenotypes = [i.get(, ) i items[:]]
()
:
results[] = {: }
()
output_file =
(output_file, , encoding=) f:
json.dump(results, f, indent=, ensure_ascii=)
()