From baa87ea048e6ec48caaadd026df2f937a56a2430 Mon Sep 17 00:00:00 2001 From: Matiq Date: Tue, 8 Sep 2026 23:31:01 +0300 Subject: [PATCH] fix OncoKB endpoint byHgvsVariant->byGenomicChange (GRCh38) - 7:g.140753336A>T now Tier I/Oncogenic (was 404) - 1:g.18396307G>A correctly Unknown/empty (expected) - offline still skips OncoKB as requested (VAF>20% default) --- annotate_clean.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/annotate_clean.py b/annotate_clean.py index ac808f2..1d4722c 100644 --- a/annotate_clean.py +++ b/annotate_clean.py @@ -45,7 +45,7 @@ ONCO_COLORS = { "Resistance": "FFC7CE", } -ONCOKB_URL = "https://www.oncokb.org/api/v1/annotate/mutations/byHgvsVariant" +ONCOKB_URL = "https://www.oncokb.org/api/v1/annotate/mutations/byGenomicChange" CIVIC_URL = "https://civicdb.org/api/variants?count=10000" def load_token(path="~/.config/oncokb/token"): @@ -202,7 +202,7 @@ def vep_annotate(df, reference, gtf_path=None, offline=False, all_transcripts=Fa return pd.DataFrame(rows) def fetch_oncokb(hgvs_g_list, token, tumor_type="All Solid Tumors", offline=False): - """Batch query OncoKB byHgvsVariant. Returns dict hgvs_g -> {amp, oncogenic}.""" + """Batch query OncoKB byGenomicChange (GRCh38). Returns dict hgvs_g -> {amp, oncogenic}.""" if not token or offline: return {} if len(hgvs_g_list) > 500: @@ -214,7 +214,20 @@ def fetch_oncokb(hgvs_g_list, token, tumor_type="All Solid Tumors", offline=Fals if i % 100 == 0 and len(hgvs_g_list) > 100: print(f" [oncokb] {i}/{len(hgvs_g_list)} ...", flush=True) try: - params = {"hgvsg": hgvs, "tumorType": tumor_type} + # hgvs like "7:g.140753336A>T" -> genomicLocation "7,140753336,140753336,A,T" + try: + chrom_part, rest = hgvs.split(":g.") + pos_ref, alt = rest.split(">") + # pos_ref like "140753336A" + pos_str = "".join(c for c in pos_ref if c.isdigit()) + ref = "".join(c for c in pos_ref if c.isalpha()) + pos = int(pos_str) if pos_str else 0 + except Exception: + chrom_part, pos, ref, alt = "1", 0, "A", "T" + pos = 0 + chrom = chrom_part + params = {"genomicLocation": f"{chrom},{pos},{pos},{ref},{alt}", + "referenceGenome": "GRCh38", "tumorType": tumor_type} resp = requests.get(ONCOKB_URL, headers=headers, params=params, timeout=(3, 5)) if resp.status_code == 200: j = resp.json()