mkt.databases.sasa.ResidueSASA
- class mkt.databases.sasa.ResidueSASA(*, dict_kinase: dict[str, KinaseInfo] | None = None, list_ids: list[str] | None = None, bool_biopython: bool = True, bool_pymol: bool = False, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: Annotated[float, Gt(gt=0)] = 1.4, n_points: Annotated[int, Ge(ge=1)] = 100, dot_density: Annotated[int, Ge(ge=1), Le(le=4)] = 3, n_jobs: int = 1)[source]
Bases:
BaseModelCalculate per-residue solvent accessible surface area from KinCore CIFs.
Configure the run via the fields below, then call
run()to compute per-residue SASA for each kinase with each selected backend; results are cached on and accessed via thedfproperty. Residues are numbered by UniProt sequence position (the CIFauth_seq_id), and hydrogens are removed by default so SASA reflects conventional heavy atoms.Prefer
from_dataclass()with aStandardSASAConfigspreset for vetted, backend-compatible options; direct construction is allowed but warns that option compatibility is the caller’s responsibility.Parameters:
- dict_kinasedict[str, KinaseInfo] | None
Mapping of HGNC name to
KinaseInfoobject. If None, kinases are deserialized on demand: one at a time viaload_kinase_objectwhenlist_idsis given, else the whole proteome viareturn_kinase_dict.- list_idslist[str] | None
HGNC names to deserialize (one at a time) when
dict_kinaseis None; None loads all kinases.- bool_biopythonbool
If True (default), compute SASA with Bio.PDB Shrake-Rupley.
- bool_pymolbool
If True, also compute SASA with PyMOL
dot_solvent(requirespymol-open-source, installed via conda); False by default. If PyMOL cannot be imported it is skipped with a warning, unless it is the only selected backend, in which case anImportErroris raised.- bool_include_hydrogensbool
If False (default), strip hydrogens for heavy-atom SASA; AlphaFold2 CIFs include explicit hydrogens.
- bool_relativebool
If True (default), add an
rsacolumn normalizing SASA by the Tien et al. (2013) theoretical maximum ASA for each residue type.- probe_radiusfloat
Solvent/probe radius in Å, shared by both backends, by default 1.40.
- n_pointsint
Shrake-Rupley sphere points per atom (Bio.PDB), by default 100. The default is fast but unlikely to be converged for per-residue SASA; use ~960 (e.g.
StandardSASAConfigs.BIOPYTHON_HEAVY) for analysis.- dot_densityint
PyMOL surface point density (1-4), by default 3.
- n_jobsint
Worker processes for
run(). 1 (default) runs serially; >1 uses a process pool; -1 uses all CPU cores. Parallelism is process-based (Shrake-Rupley is CPU-bound); each task carries itsKinaseInfo, so workers do no deserialization. Worthwhile for many kinases or highn_points.
- __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
Scalar config forwarded to the (picklable) per-kinase compute worker.
Check whether the optional PyMOL backend can be imported.
Resolve the backends to run, dropping PyMOL if it cannot be imported.
Resolve
n_jobsto a concrete worker count (>=1)._run_tasks(list_tasks)Run
(kinase, backend)tasks serially or across a process pool.Reject incompatible option combinations and warn on inert options.
from_dataclass(config, **kwargs)Build a ResidueSASA from a vetted config dataclass or standard preset.
run()Compute per-residue SASA for all kinases and backends.
Attributes
_building_from_dataclassPer-residue SASA results; None until
run()is called.Backends to run, selected via
bool_biopython/bool_pymol.Mapping of HGNC name to
KinaseInfo; deserialized on demand if None.HGNC names to deserialize (one at a time) when
dict_kinaseis None.Compute SASA with the Bio.PDB Shrake-Rupley backend.
Compute SASA with the PyMOL
dot_solventbackend.Keep explicit hydrogens; False gives conventional heavy-atom SASA.
Add relative SASA (rSASA); requires heavy-atom SASA (no explicit H).
Solvent/probe radius (Å), shared by both backends.
Shrake-Rupley sphere points per atom (Bio.PDB only); default 100 is unlikely to be converged for per-residue SASA (use ~960).
PyMOL surface point density 1-4 (PyMOL only).
1 serial, >1 pool, -1 all cores.
_df- _compute_params() dict[str, object][source]
Scalar config forwarded to the (picklable) per-kinase compute worker.
- static _pymol_available() bool[source]
Check whether the optional PyMOL backend can be imported.
The PyMOL PyPI wheel is unreliable, so any import failure (not just
ModuleNotFoundError) is treated as unavailable.Returns:
- bool
True if
pymol2imports successfully, otherwise False.
- _resolve_methods() list[str][source]
Resolve the backends to run, dropping PyMOL if it cannot be imported.
Returns:
- list[str]
Selected backends with “pymol” removed (with a warning) when
pymol2is unavailable but the Bio.PDB backend can stand in.
Raises:
- ImportError
If PyMOL is the only requested backend but is unavailable.
- _run_tasks(list_tasks: list[tuple]) list[DataFrame][source]
Run
(kinase, backend)tasks serially or across a process pool.
- _validate_config() ResidueSASA[source]
Reject incompatible option combinations and warn on inert options.
Numeric ranges are enforced by
Fieldconstraints; this covers the cross-field rules thatFieldcannot express.Raises:
- ValueError
If no backend is selected, or if relative SASA is requested together with explicit hydrogens.
- bool_biopython: bool
Compute SASA with the Bio.PDB Shrake-Rupley backend.
- bool_include_hydrogens: bool
Keep explicit hydrogens; False gives conventional heavy-atom SASA.
- bool_pymol: bool
Compute SASA with the PyMOL
dot_solventbackend.
- bool_relative: bool
Add relative SASA (rSASA); requires heavy-atom SASA (no explicit H).
- property df: DataFrame | None
Per-residue SASA results; None until
run()is called.Long-format DataFrame with columns
hgnc_name,method,uniprot_idx(UniProt position),residue(single-letter code),resname(3-letter code),sasa(Å^2), and, ifbool_relative,rsa. Empty if no kinase had a CIF structure.
- dict_kinase: dict[str, KinaseInfo] | None
Mapping of HGNC name to
KinaseInfo; deserialized on demand if None.
- dot_density: int
PyMOL surface point density 1-4 (PyMOL only).
- classmethod from_dataclass(config: BaseSASAConfig | StandardSASAConfigs, **kwargs) ResidueSASA[source]
Build a ResidueSASA from a vetted config dataclass or standard preset.
This is the recommended constructor: presets in
StandardSASAConfigscarry backend-compatible options, so the direct-construction compatibility warning is suppressed.Parameters:
- configBaseSASAConfig | StandardSASAConfigs
A SASA config dataclass (e.g.
BioPythonHeavyConfig) or aStandardSASAConfigsenum member.- **kwargs
Extra constructor arguments, e.g.
dict_kinaseorlist_ids.
Returns:
- ResidueSASA
Configured (but not yet run) instance.
- list_ids: list[str] | None
HGNC names to deserialize (one at a time) when
dict_kinaseis None.
- property list_methods: list[str]
Backends to run, selected via
bool_biopython/bool_pymol.
- n_points: int
Shrake-Rupley sphere points per atom (Bio.PDB only); default 100 is unlikely to be converged for per-residue SASA (use ~960).
- probe_radius: float
Solvent/probe radius (Å), shared by both backends.
- run() None[source]
Compute per-residue SASA for all kinases and backends.
Loops over each selected backend and kinase, tagging rows with
methodandhgnc_name; kinases without a KinCore CIF are skipped. The long-format result is stored ondf(not returned).Returns:
- None
Results are cached on
df; see that property for the columns.