$npx -y skills add QSong-github/DrugClaw --skill pharmgkbQuery ClinPGx (PharmGKB) and CPIC for pharmacogenomics data. Use whenever the user asks about gene-drug interactions, pharmacogenomics clinical annotations, drug-metabolizing enzymes, CPIC guidelines, or variant-level PGx evidence for any gene symbol, drug name, rsID, or ClinPGx
| 1 | # PharmGKB / ClinPGx Query Skill |
| 2 | |
| 3 | Queries two complementary APIs: |
| 4 | |
| 5 | - **ClinPGx API** (`api.clinpgx.org/v1`) — gene, chemical, variant detail |
| 6 | - **CPIC API** (`api.cpicpgx.org/v1`) — gene-drug pairs, CPIC guideline levels (PostgREST) |
| 7 | |
| 8 | Auto-detects input entity type by pattern: |
| 9 | |
| 10 | | Input Pattern | Detected As | Data Sources | |
| 11 | |---|---|---| |
| 12 | | `PA128` | ClinPGx accession | gene or chemical detail + CPIC pairs | |
| 13 | | `rs4244285` | dbSNP rsID | variant lookup | |
| 14 | | `CYP2D6` | gene symbol (uppercase, 2-15 chars) | gene detail + CPIC pairs | |
| 15 | | anything else | drug / free text | chemical detail + CPIC pairs | |
| 16 | |
| 17 | ## API |
| 18 | |
| 19 | | Function | Input | Returns | |
| 20 | |---|---|---| |
| 21 | | `search(entity)` | single entity string | dict with `genes`, `chemicals`, `variants`, `cpic_pairs`, `related` | |
| 22 | | `search_batch(entities)` | list of entity strings | dict[str → search result] | |
| 23 | | `summarize(result, entity)` | search result + label | compact text (one line per hit) | |
| 24 | | `to_json(result)` | search result | indented JSON string | |
| 25 | | `search_gene(symbol)` | gene symbol | list of gene dicts (ClinPGx) | |
| 26 | | `search_drug(name)` | drug name | list of chemical dicts (ClinPGx) | |
| 27 | | `search_variant(rsid)` | rsID string | list of variant dicts (ClinPGx) | |
| 28 | | `get_cpic_pairs_by_gene(symbol)` | gene symbol | list of pair dicts (CPIC `pair_view`) | |
| 29 | | `get_cpic_pairs_by_drug(name)` | drug name | list of pair dicts (CPIC `pair_view`) | |
| 30 | |
| 31 | ## Usage |
| 32 | |
| 33 | See `if __name__ == "__main__"` block in `49_PHARMGKB_CLINPGX.py` for runnable |
| 34 | examples covering: gene symbol, drug name, rsID, ClinPGx accession, batch |
| 35 | search, and JSON output. |
| 36 | |
| 37 | ## Key Fields |
| 38 | |
| 39 | **Gene** (ClinPGx): `id`, `symbol`, `name`, `hasCpicGuideline` |
| 40 | |
| 41 | **Chemical** (ClinPGx): `id`, `name`, `types` |
| 42 | |
| 43 | **Variant** (ClinPGx): `id`, `symbol`, `genes`, `location` |
| 44 | |
| 45 | **CPIC Pair** (`pair_view`): `genesymbol`, `drugname`, `cpiclevel` (A/B/C/D), |
| 46 | `clinpgxlevel` (evidence), `pgxtesting`, `guidelinename` |
| 47 | |
| 48 | ## Data Sources |
| 49 | |
| 50 | - **ClinPGx** (Stanford / NIH) — https://www.clinpgx.org/ — REST JSON, no key, ≤2 req/s, CC BY-SA 4.0 |
| 51 | - **CPIC API** — https://api.cpicpgx.org/ — PostgREST, no key — gene-drug guideline pairs |
| 52 | - **Note**: PharmGKB was subsumed by ClinPGx (July 2025). CPIC API remains at `api.cpicpgx.org`. |