clinpgx-term-lookup
Fuzzy term lookup for ClinPGx / PharmGKB: take a free-text drug or variant term and resolve it to its ClinPGx record.
It is API-only — no local data files to download. Lookups are served by the public PharmGKB and RxNorm APIs, so results stay current and the package stays small. An internet connection is required at lookup time.
Installation
pip install clinpgx-term-lookup
Usage
Drugs
from clinpgx_term_lookup import DrugLookup
results = DrugLookup().search("warfarin")
for r in results:
print(r.name, r.id, r.url, r.score, r.source)
The drug lookup:
- Tries an exact PharmGKB chemical name match.
- On a miss, fuzzy-matches the term with RxNorm's
approximateTermendpoint, resolves it to its ingredient (so brand names likeTylenolmap toacetaminophen), and re-queries PharmGKB by that name. - On a miss, returns the RxNorm result itself as a fallback (with
source="rxnorm").
So misspellings (warfarn) and trade names (tylenol) both resolve to the
right PharmGKB chemical.
Variants
from clinpgx_term_lookup import VariantLookup
VariantLookup().search("rs1234") # rsID -> variant endpoint
VariantLookup().search("CYP2C19*2") # star allele -> haplotype endpoint
Terms starting with rs are looked up as rsIDs; everything else is treated as
a star allele.
Result objects
Both lookups return a list of Pydantic models with these fields:
| Field | Description |
|---|---|
raw_input |
The original query string |
id |
PharmGKB accession ID (or RXN<rxcui>) |
name |
The matched name |
url |
Link to the ClinPGx (or RxNorm) record |
score |
0–1 fuzzy similarity to the query |
source |
"pharmgkb" or "rxnorm" |
Command line
clinpgx-term-lookup warfarin --type drug
clinpgx-term-lookup rs1234 --type variant
Output is JSON. Use --top-k and --threshold to tune results.
License
MIT. Note that lookups query the PharmGKB and RxNorm APIs; their data is subject to their respective terms of use.
Metadata
Release files for clinpgx-term-lookup 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clinpgx_term_lookup-0.1.0.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clinpgx_term_lookup-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.9 kB
Release files / clinpgx_term_lookup-0.1.0.tar.gz
| Download URL | clinpgx_term_lookup-0.1.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de90c9901ea3a332ee69c4a6da6f1b7764930e2dbdaf74767b78f5ca5b1187f7
|
|
BLAKE2b-256 checksum How to use checksums |
d78e497d87a60ba76560f3b462f2c75127605683d32d420bf11c8734312ba7db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / clinpgx_term_lookup-0.1.0-py3-none-any.whl
| Download URL | clinpgx_term_lookup-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0397a65bb57093634a9d734ea9f0de2af1bbb372fe79193dbe206fcf45a3a3b4
|
|
BLAKE2b-256 checksum How to use checksums |
f759e793a86eea0d48025b75f1f5f752961d43eff5a91146e0a37f1dff43881c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|