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)
This commit is contained in:
+16
-3
@@ -45,7 +45,7 @@ ONCO_COLORS = {
|
|||||||
"Resistance": "FFC7CE",
|
"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"
|
CIVIC_URL = "https://civicdb.org/api/variants?count=10000"
|
||||||
|
|
||||||
def load_token(path="~/.config/oncokb/token"):
|
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)
|
return pd.DataFrame(rows)
|
||||||
|
|
||||||
def fetch_oncokb(hgvs_g_list, token, tumor_type="All Solid Tumors", offline=False):
|
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:
|
if not token or offline:
|
||||||
return {}
|
return {}
|
||||||
if len(hgvs_g_list) > 500:
|
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:
|
if i % 100 == 0 and len(hgvs_g_list) > 100:
|
||||||
print(f" [oncokb] {i}/{len(hgvs_g_list)} ...", flush=True)
|
print(f" [oncokb] {i}/{len(hgvs_g_list)} ...", flush=True)
|
||||||
try:
|
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))
|
resp = requests.get(ONCOKB_URL, headers=headers, params=params, timeout=(3, 5))
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
j = resp.json()
|
j = resp.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user