mkt.databases.three_d_hotspots
Loader and parser for the 3D Hotspots database.
Provides ThreeDHotspots to load and parse the residue-level 3D hotspot
calls (Table S2) published by 3dhotspots.org, with the HotspotClass
enumeration for the per-residue classification.
Unlike mkt.databases.cancer_hotspots, 3dhotspots.org exposes no API: the
data ship as a single XLSX workbook (3d_hotspots.xls). Following the pattern
in mkt.databases.oncotree, the loader reads a local copy under
<repo_root>/data when present and otherwise downloads DEFAULT_URL.
Module Attributes
Default filename for the 3D Hotspots workbook, relative to |
|
Upstream URL for the 3D Hotspots workbook; used when no local file is found. |
|
Workbook sheet holding the per-residue hotspot calls. |
|
Prefix of the ODbL license-boilerplate column upstream appends to every sheet. |
|
Rename map from the raw |
|
Regex capturing the integer position from a |
Classes
|
Per-residue 3D hotspot classification from |
|
Loader for the residue-level 3D hotspot calls from 3dhotspots.org. |
- mkt.databases.three_d_hotspots.COLUMN_RENAME = {'#Mutations': 'mutationCount', 'Class': 'hotspotClass', 'Gene': 'hugoSymbol', 'Residue': 'residue', 'p-value': 'pValue'}
Rename map from the raw
Table S2headers to camelCase columns.hugoSymbol/residuemirrormkt.databases.cancer_hotspotsso the two hotspot resources share a column vocabulary.
- mkt.databases.three_d_hotspots.DEFAULT_FILENAME = '3d_hotspots.xls'
Default filename for the 3D Hotspots workbook, relative to
<repo_root>/data.
- mkt.databases.three_d_hotspots.DEFAULT_URL = 'https://www.3dhotspots.org/files/3d_hotspots.xls'
Upstream URL for the 3D Hotspots workbook; used when no local file is found.
- class mkt.databases.three_d_hotspots.HotspotClass(value)[source]
Bases:
str,EnumPer-residue 3D hotspot classification from
Table S2.- CLUSTER_EXCLUSIVE = 'Cluster-exclusive'
3D-cluster residue not otherwise called as a linear hotspot.
- HOTSPOT = 'Hotspot'
Recurrently mutated residue also called as a linear (single-residue) hotspot.
- HOTSPOT_LINKED = 'Hotspot-linked'
3D-cluster residue sharing a cluster with a linear hotspot residue.
- mkt.databases.three_d_hotspots.LICENSE_COL_PREFIX = 'Data available under ODC'
Prefix of the ODbL license-boilerplate column upstream appends to every sheet.
- mkt.databases.three_d_hotspots.RESIDUE_RE = re.compile('^[A-Za-z]+(\\d+)$')
Regex capturing the integer position from a
"<ref-AA><position>"residue.
- mkt.databases.three_d_hotspots.RESIDUE_SHEET = 'Table S2'
Workbook sheet holding the per-residue hotspot calls.
- class mkt.databases.three_d_hotspots.ThreeDHotspots(*, filepath: str | None = None)[source]
Bases:
BaseModelLoader for the residue-level 3D hotspot calls from 3dhotspots.org.
Source: https://www.3dhotspots.org/files/3d_hotspots.xls (
Table S2)The workbook’s
Table S2sheet lists one row per hotspot residue with its gene, mutation count, p-value, andHotspotClass. The loader drops the trailing ODbL license-boilerplate column, renames the headers to the camelCase vocabulary shared withmkt.databases.cancer_hotspots(hugoSymbol/residue), and derives a nullable-integerpositionStartfrom each residue label. The cleaned table is exposed via thedfproperty and filtered per gene withget_gene().- Parameters:
filepath (str | None) – Optional path to the 3D Hotspots workbook. If unset, the loader looks for
<repo_root>/data/3d_hotspots.xlsand falls back to downloadingDEFAULT_URLwhen no local file exists.
- _load() DataFrame[source]
Read
Table S2and derivepositionStart.- Returns:
Columns, in order:
hugoSymbol,residue,positionStart,mutationCount,pValue,hotspotClass.- Return type:
pd.DataFrame
- static _read_bytes(source: str) bytes[source]
Return the raw workbook bytes from a local path or http(s) URL.
- _resolve_source() str[source]
Resolve the source path or URL to read.
- Returns:
self.filepathif set; otherwise the repo-bundled default path if it exists on disk; otherwiseDEFAULT_URL.- Return type:
str
- property df: DataFrame
Cleaned residue-level 3D hotspot table populated at instantiation.
- filepath: str | None
- classmethod from_csv(path: str) ThreeDHotspots[source]
Build a loader from a CSV written by
to_csv(), without downloading.- Parameters:
path (str) – Path to a CSV previously written by
to_csv().- Returns:
Instance backed by the cached table.
- Return type:
- classmethod from_dataframe(df: DataFrame) ThreeDHotspots[source]
Build a loader from an already-cleaned table without reading the workbook.
Bypasses
model_post_init(which would read/download the workbook) and sets_dfdirectly, so cached data can be reloaded offline.- Parameters:
df (pd.DataFrame) – Cleaned table (e.g. from
read_csv()ordf).- Returns:
Instance backed by
df;get_gene()works as usual.- Return type:
- get_gene(hugo_symbol: str) DataFrame[source]
Return 3D hotspot residues for a single gene.
- Parameters:
hugo_symbol (str) – HGNC gene symbol to filter on (e.g.
"BRAF").- Returns:
Rows of
dfwhosehugoSymbolmatches; empty if none.- Return type:
pd.DataFrame