mkt.databases.three_d_hotspots.ThreeDHotspots
- 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.
- __init__(**data: Any) None
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Methods
_load()Read
Table S2and derivepositionStart._read_bytes(source)Return the raw workbook bytes from a local path or http(s) URL.
Resolve the source path or URL to read.
from_csv(path)Build a loader from a CSV written by
to_csv(), without downloading.from_dataframe(df)Build a loader from an already-cleaned table without reading the workbook.
get_gene(hugo_symbol)Return 3D hotspot residues for a single gene.
read_csv(path)Read a table written by
to_csv()back into a DataFrame.to_csv(path)Write the cleaned table to CSV.
Attributes
Cleaned residue-level 3D hotspot table populated at instantiation.
_df- _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