PGx: PharmVar genes (CYP1A2, CYP2A6, CYP2A13, CYP2C8, CYP3A4), CYP2A6 *4 from CN (PGX-001/006)

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).
This commit is contained in:
kemal committed 2026-09-29 16:50:27 +01:00
1 parent 46422b8de4
commit dfba22496a
9 files changed
+289 -14

No files matched your search

+21
View File
@@ -237,3 +237,24 @@ def result_basis(gene: str, names: list[str]) -> str:
if names and all(n.startswith("*") for n in names):
return "star_allele"
return "variant_based"
def pharmvar_core_alleles(gene: str, vcfs: dict[str, str]) -> dict[str, list[tuple[str, int, str, str, str | None]]]:
"""PharmVar per-allele GRCh38 VCFs (file name → text) → core alleles (``*N``; sub-alleles ``*N.001`` skipped) and
their variants (chrom, pos, ref, alt, rsid) as written by PharmVar [DB: PharmVar haplotype VCFs]."""
out: dict[str, list[tuple[str, int, str, str, str | None]]] = {}
pat = re.compile(rf"^{re.escape(gene)}_(\d+)\.vcf$")
for name, text in vcfs.items():
m = pat.match(name.rsplit("/", 1)[-1])
if not m:
continue
recs = []
for ln in text.splitlines():
if not ln or ln.startswith("#"):
continue
f = ln.split("\t")
rsid = f[2] if f[2].startswith("rs") else None
for alt in f[4].split(","):
recs.append((f[0], int(f[1]), f[3].upper(), alt.upper(), rsid))
out[f"*{m.group(1)}"] = recs
return out