PGx: PharmVar genes (CYP1A2, CYP2A6, CYP2A13, CYP2C8, CYP3A4), CYP2A6 *4 from CN (PGX-001/006)
ci / test (3.12) (push) Failing after 8s
ci / test (3.13) (push) Failing after 10s

fetch_sources.sh downloads PharmVar per-gene zips; pgx db build adds core alleles for genes CPIC does not
define (normalised against the FASTA, *1 = reference). Masks re-derived with the new variants. GeT-RM:
CYP3A4 15/15, CYP2A6 7/9; all comparable genes 154/168 (CYP1A2/CYP2C8 definitions differ from GeT-RM's).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01814GKVzZVL3FuF3DeiZXhv
This commit is contained in:
kemalandClaude Opus 5.5 committed 2026-09-29 16:50:27 +01:00
1 parent 1428535e91
commit 4176ef33de
9 files changed
+289 -14

No files matched your search

+32 -1
View File
@@ -2,7 +2,9 @@
# Download the public PGx sources for `simurg pgx db build` (spec PGX-001) into a dated folder.
# bash scripts/pgx/fetch_sources.sh [OUT_DIR] (default data/pgx/sources)
# CPIC (CC0): tables from the CPIC API (https://api.cpicpgx.org, PostgREST) as JSON; the newest change-log date is
# recorded as the data version. Never committed (data/ is ignored).
# recorded as the data version. PharmVar (https://www.pharmvar.org; cite Gaedigk et al. 2018 CPT 103:399): per-gene
# zips (haplotype VCFs, GRCh37/GRCh38) for the star-allele genes CPIC does not define. Never committed (data/ is
# ignored); the DB records each source's version and file hashes.
set -euo pipefail
OUT=${1:-data/pgx/sources}
DATE=$(date -u +%Y%m%d)
@@ -25,3 +27,32 @@ files = {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(d.gl
"files": files}, indent=1))
print("CPIC data version", ver)
PY
# ---- PharmVar: star-allele genes without CPIC definitions
PV="$OUT/pharmvar-$DATE"
mkdir -p "$PV"
PV_GENES=${PV_GENES:-"CYP1A2 CYP2A6 CYP2A13 CYP2C8 CYP3A4"} # the PharmVar genes CPIC does not define (2026-09)
for g in $PV_GENES; do
if curl -sSf --retry 3 -o "$PV/$g.zip" \
"https://www.pharmvar.org/get-download-file?name=$g&refSeq=ALL&fileType=zip&version=current"; then
echo "PharmVar $g $(unzip -l "$PV/$g.zip" | awk 'NR==4{print $4}' | cut -d/ -f1)"
else
echo "PharmVar $g: not available"; rm -f "$PV/$g.zip"
fi
done
python3 - "$PV" <<'PY'
import hashlib, json, pathlib, re, sys, zipfile
d = pathlib.Path(sys.argv[1])
vers = set()
for z in sorted(d.glob("*.zip")):
top = zipfile.ZipFile(z).namelist()[0].split("/")[0]
m = re.search(r"-(\d+\.\d+\.\d+)$", top)
if m:
vers.add(m.group(1))
files = {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(d.glob("*.zip"))}
(d / "source.json").write_text(json.dumps({"name": "PharmVar", "version": ",".join(sorted(vers)),
"retrieved": d.name.split("-")[1], "url": "https://www.pharmvar.org",
"license": "PharmVar terms of use (cite Gaedigk et al. 2018)",
"files": files}, indent=1))
print("PharmVar version", ",".join(sorted(vers)))
PY
+3 -1
View File
@@ -57,7 +57,9 @@ def _ugt2b17(t: str) -> int: # *2 = whole-gene deletion
CN_TRUTH = {"GSTM1": _gstm1, "GSTT1": _gstt1, "UGT2B17": _ugt2b17} # capped: GSTM1 at 1, the others at 2
LEGACY_NOMENCLATURE = {"UGT1A1", "SLCO1B1"} # GeT-RM uses pre-2023 names (*60, SLCO1B1 *1B/*17/*21) not in CPIC
# GeT-RM uses older names or definitions than the current CPIC/PharmVar ones: UGT1A1 *60 and SLCO1B1 *1B/*17/*21
# (pre-2023), CYP1A2 lettered alleles (*1F …), CYP2C8 *19 (PharmVar now defines rs2071426 alone as *19; GeT-RM *1)
LEGACY_NOMENCLATURE = {"UGT1A1", "SLCO1B1", "CYP1A2", "CYP2C8"}
def truth_alternatives(text: str) -> list[list[set[str]]]: