mkt.databases.sasa
Solvent-accessible surface area (SASA) computation configs and residue-level calculation.
Defines SASA configuration dataclasses (Biopython and PyMOL backends, with and without
hydrogens), the StandardSASAConfigs presets, and the ResidueSASA
model produced by residue-level SASA computation.
Module Attributes
Theoretical maximum accessible surface area (Å^2) per residue. |
|
Default solvent/probe radius (Å), shared by both SASA backends. |
|
Default Shrake-Rupley sphere points per atom (Bio.PDB); presets raise this to ~960 for converged per-residue SASA. |
|
Default PyMOL surface point density (1-4). |
Functions
|
Build the per-residue DataFrame and optional relative-SASA column. |
|
Compute per-residue SASA for one kinase with one backend. |
|
Per-residue SASA rows via Bio.PDB Shrake-Rupley. |
|
Per-residue SASA rows via PyMOL |
|
Worker entry point: compute one (kinase, backend) task and tag the rows. |
|
Remove all hydrogen atoms from a Bio.PDB Structure in place. |
Classes
|
Backend-compatible options for |
|
Heavy-atom Bio.PDB Shrake-Rupley with converged sampling (recommended). |
|
All-atom (explicit-H) Bio.PDB Shrake-Rupley; rSASA disabled. |
|
Heavy-atom SASA from both backends with matched probe/sampling. |
|
All-atom (explicit-H) SASA from both backends; rSASA disabled. |
|
Heavy-atom PyMOL |
|
All-atom (explicit-H) PyMOL |
|
Calculate per-residue solvent accessible surface area from KinCore CIFs. |
|
String aliases for |
|
Named, internally consistent SASA configurations. |
- class mkt.databases.sasa.BaseSASAConfig(*, bool_biopython: bool = True, bool_pymol: bool = False, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: float = 1.4, n_points: int = 100, dot_density: int = 3)[source]
Bases:
objectBackend-compatible options for
ResidueSASA.Field names mirror the
ResidueSASAconstructor so a config can be expanded viaResidueSASA.from_dataclass(). Presets (subclasses) override these defaults into vetted, internally consistent recipes; seeStandardSASAConfigs.- __init__(*, bool_biopython: bool = True, bool_pymol: bool = False, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: float = 1.4, n_points: int = 100, dot_density: int = 3) None
- bool_biopython: bool = True
Compute SASA with the Bio.PDB Shrake-Rupley backend.
- bool_include_hydrogens: bool = False
Keep explicit hydrogens; False gives conventional heavy-atom SASA.
- bool_pymol: bool = False
Compute SASA with the PyMOL
dot_solventbackend.
- bool_relative: bool = True
Add relative SASA (rSASA); requires heavy-atom SASA (no explicit H).
- dot_density: int = 3
PyMOL surface point density 1-4 (PyMOL only).
- n_points: int = 100
Shrake-Rupley sphere points per atom (Bio.PDB only); default 100 is unlikely to be converged for per-residue SASA (presets use ~960).
- probe_radius: float = 1.4
Solvent/probe radius (Å), shared by both backends.
- class mkt.databases.sasa.BioPythonHeavyConfig(*, bool_biopython: bool = True, bool_pymol: bool = False, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: float = 1.4, n_points: int = 960, dot_density: int = 3)[source]
Bases:
BaseSASAConfigHeavy-atom Bio.PDB Shrake-Rupley with converged sampling (recommended).
- __init__(*, bool_biopython: bool = True, bool_pymol: bool = False, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: float = 1.4, n_points: int = 960, dot_density: int = 3) None
- bool_biopython: bool = True
Compute SASA with the Bio.PDB Shrake-Rupley backend.
- bool_pymol: bool = False
Compute SASA with the PyMOL
dot_solventbackend.
- n_points: int = 960
Shrake-Rupley sphere points per atom (Bio.PDB only); default 100 is unlikely to be converged for per-residue SASA (presets use ~960).
- class mkt.databases.sasa.BioPythonHydrogenConfig(*, bool_biopython: bool = True, bool_pymol: bool = False, bool_include_hydrogens: bool = True, bool_relative: bool = False, probe_radius: float = 1.4, n_points: int = 960, dot_density: int = 3)[source]
Bases:
BaseSASAConfigAll-atom (explicit-H) Bio.PDB Shrake-Rupley; rSASA disabled.
Bondi radii + explicit hydrogens is a standard, self-consistent all-atom surface (not a double count). rSASA is disabled because the Tien et al. (2013) maxima are a heavy-atom reference; the structures must actually carry hydrogens (the run warns per structure if they do not).
- __init__(*, bool_biopython: bool = True, bool_pymol: bool = False, bool_include_hydrogens: bool = True, bool_relative: bool = False, probe_radius: float = 1.4, n_points: int = 960, dot_density: int = 3) None
- bool_biopython: bool = True
Compute SASA with the Bio.PDB Shrake-Rupley backend.
- bool_include_hydrogens: bool = True
Keep explicit hydrogens; False gives conventional heavy-atom SASA.
- bool_pymol: bool = False
Compute SASA with the PyMOL
dot_solventbackend.
- bool_relative: bool = False
Add relative SASA (rSASA); requires heavy-atom SASA (no explicit H).
- n_points: int = 960
Shrake-Rupley sphere points per atom (Bio.PDB only); default 100 is unlikely to be converged for per-residue SASA (presets use ~960).
- class mkt.databases.sasa.CrossValidationConfig(*, bool_biopython: bool = True, bool_pymol: bool = True, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: float = 1.4, n_points: int = 960, dot_density: int = 4)[source]
Bases:
BaseSASAConfigHeavy-atom SASA from both backends with matched probe/sampling.
- __init__(*, bool_biopython: bool = True, bool_pymol: bool = True, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: float = 1.4, n_points: int = 960, dot_density: int = 4) None
- bool_biopython: bool = True
Compute SASA with the Bio.PDB Shrake-Rupley backend.
- bool_pymol: bool = True
Compute SASA with the PyMOL
dot_solventbackend.
- dot_density: int = 4
PyMOL surface point density 1-4 (PyMOL only).
- n_points: int = 960
Shrake-Rupley sphere points per atom (Bio.PDB only); default 100 is unlikely to be converged for per-residue SASA (presets use ~960).
- class mkt.databases.sasa.CrossValidationHydrogenConfig(*, bool_biopython: bool = True, bool_pymol: bool = True, bool_include_hydrogens: bool = True, bool_relative: bool = False, probe_radius: float = 1.4, n_points: int = 960, dot_density: int = 4)[source]
Bases:
BaseSASAConfigAll-atom (explicit-H) SASA from both backends; rSASA disabled.
- __init__(*, bool_biopython: bool = True, bool_pymol: bool = True, bool_include_hydrogens: bool = True, bool_relative: bool = False, probe_radius: float = 1.4, n_points: int = 960, dot_density: int = 4) None
- bool_biopython: bool = True
Compute SASA with the Bio.PDB Shrake-Rupley backend.
- bool_include_hydrogens: bool = True
Keep explicit hydrogens; False gives conventional heavy-atom SASA.
- bool_pymol: bool = True
Compute SASA with the PyMOL
dot_solventbackend.
- bool_relative: bool = False
Add relative SASA (rSASA); requires heavy-atom SASA (no explicit H).
- dot_density: int = 4
PyMOL surface point density 1-4 (PyMOL only).
- n_points: int = 960
Shrake-Rupley sphere points per atom (Bio.PDB only); default 100 is unlikely to be converged for per-residue SASA (presets use ~960).
- mkt.databases.sasa.DEFAULT_DOT_DENSITY = 3
Default PyMOL surface point density (1-4).
- mkt.databases.sasa.DEFAULT_N_POINTS = 100
Default Shrake-Rupley sphere points per atom (Bio.PDB); presets raise this to ~960 for converged per-residue SASA.
- mkt.databases.sasa.DEFAULT_PROBE_RADIUS = 1.4
Default solvent/probe radius (Å), shared by both SASA backends.
- mkt.databases.sasa.MAX_ASA_TIEN_2013 = {'ALA': 129.0, 'ARG': 274.0, 'ASN': 195.0, 'ASP': 193.0, 'CYS': 167.0, 'GLN': 225.0, 'GLU': 223.0, 'GLY': 104.0, 'HIS': 224.0, 'ILE': 197.0, 'LEU': 201.0, 'LYS': 236.0, 'MET': 224.0, 'PHE': 240.0, 'PRO': 159.0, 'SER': 155.0, 'THR': 172.0, 'TRP': 285.0, 'TYR': 263.0, 'VAL': 174.0}
Theoretical maximum accessible surface area (Å^2) per residue.
From Tien et al. (2013), PLoS ONE 8(11): e80635; used to normalize SASA to relative solvent accessibility (rSASA), keyed by 3-letter residue name.
- class mkt.databases.sasa.PyMOLHeavyConfig(*, bool_biopython: bool = False, bool_pymol: bool = True, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: float = 1.4, n_points: int = 100, dot_density: int = 4)[source]
Bases:
BaseSASAConfigHeavy-atom PyMOL
dot_solventwith high dot density.- __init__(*, bool_biopython: bool = False, bool_pymol: bool = True, bool_include_hydrogens: bool = False, bool_relative: bool = True, probe_radius: float = 1.4, n_points: int = 100, dot_density: int = 4) None
- bool_biopython: bool = False
Compute SASA with the Bio.PDB Shrake-Rupley backend.
- bool_pymol: bool = True
Compute SASA with the PyMOL
dot_solventbackend.
- dot_density: int = 4
PyMOL surface point density 1-4 (PyMOL only).
- class mkt.databases.sasa.PyMOLHydrogenConfig(*, bool_biopython: bool = False, bool_pymol: bool = True, bool_include_hydrogens: bool = True, bool_relative: bool = False, probe_radius: float = 1.4, n_points: int = 100, dot_density: int = 4)[source]
Bases:
BaseSASAConfigAll-atom (explicit-H) PyMOL
dot_solvent; rSASA disabled.- __init__(*, bool_biopython: bool = False, bool_pymol: bool = True, bool_include_hydrogens: bool = True, bool_relative: bool = False, probe_radius: float = 1.4, n_points: int = 100, dot_density: int = 4) None
- bool_biopython: bool = False
Compute SASA with the Bio.PDB Shrake-Rupley backend.
- bool_include_hydrogens: bool = True
Keep explicit hydrogens; False gives conventional heavy-atom SASA.
- bool_pymol: bool = True
Compute SASA with the PyMOL
dot_solventbackend.
- bool_relative: bool = False
Add relative SASA (rSASA); requires heavy-atom SASA (no explicit H).
- dot_density: int = 4
PyMOL surface point density 1-4 (PyMOL only).
- 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.
- _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.
- class mkt.databases.sasa.StandardSASAConfigChoice(value)[source]
Bases:
str,EnumString aliases for
StandardSASAConfigs(e.g. for CLI choices).- BIOPYTHON_HEAVY = 'BIOPYTHON_HEAVY'
- BIOPYTHON_HYDROGEN = 'BIOPYTHON_HYDROGEN'
- CROSS_VALIDATION = 'CROSS_VALIDATION'
- CROSS_VALIDATION_HYDROGEN = 'CROSS_VALIDATION_HYDROGEN'
- PYMOL_HEAVY = 'PYMOL_HEAVY'
- PYMOL_HYDROGEN = 'PYMOL_HYDROGEN'
- class mkt.databases.sasa.StandardSASAConfigs(value)[source]
Bases:
EnumNamed, internally consistent SASA configurations.
Use via
ResidueSASA.from_dataclass(StandardSASAConfigs.BIOPYTHON_HEAVY). Each value omits any backend-inert field, so nothing silently no-ops.*_HEAVYgive heavy-atom SASA with rSASA;*_HYDROGENgive all-atom (explicit-H) absolute SASA with rSASA disabled.- BIOPYTHON_HEAVY = BioPythonHeavyConfig(bool_biopython=True, bool_pymol=False, bool_include_hydrogens=False, bool_relative=True, probe_radius=1.4, n_points=960, dot_density=3)
- BIOPYTHON_HYDROGEN = BioPythonHydrogenConfig(bool_biopython=True, bool_pymol=False, bool_include_hydrogens=True, bool_relative=False, probe_radius=1.4, n_points=960, dot_density=3)
- CROSS_VALIDATION = CrossValidationConfig(bool_biopython=True, bool_pymol=True, bool_include_hydrogens=False, bool_relative=True, probe_radius=1.4, n_points=960, dot_density=4)
- CROSS_VALIDATION_HYDROGEN = CrossValidationHydrogenConfig(bool_biopython=True, bool_pymol=True, bool_include_hydrogens=True, bool_relative=False, probe_radius=1.4, n_points=960, dot_density=4)
- PYMOL_HEAVY = PyMOLHeavyConfig(bool_biopython=False, bool_pymol=True, bool_include_hydrogens=False, bool_relative=True, probe_radius=1.4, n_points=100, dot_density=4)
- PYMOL_HYDROGEN = PyMOLHydrogenConfig(bool_biopython=False, bool_pymol=True, bool_include_hydrogens=True, bool_relative=False, probe_radius=1.4, n_points=100, dot_density=4)
- mkt.databases.sasa._assemble_sasa_df(list_rows: list[dict[str, object]], *, bool_relative: bool) DataFrame[source]
Build the per-residue DataFrame and optional relative-SASA column.
- mkt.databases.sasa._compute_kinase_sasa(obj_kinase: KinaseInfo, str_method: str, *, bool_include_hydrogens: bool, bool_relative: bool, probe_radius: float, n_points: int, dot_density: int) DataFrame | None[source]
Compute per-residue SASA for one kinase with one backend.
Returns the per-residue DataFrame (without
hgnc_name/methodtags), or None if the kinase has no KinCore CIF structure.
- mkt.databases.sasa._residue_sasa_biopython(structure: Structure, *, bool_include_hydrogens: bool, probe_radius: float, n_points: int) list[dict[str, object]][source]
Per-residue SASA rows via Bio.PDB Shrake-Rupley.
- mkt.databases.sasa._residue_sasa_pymol(structure: Structure, *, bool_include_hydrogens: bool, probe_radius: float, dot_density: int) list[dict[str, object]][source]
Per-residue SASA rows via PyMOL
dot_solvent(lazypymol2import).
- mkt.databases.sasa._sasa_task(task: tuple) DataFrame | None[source]
Worker entry point: compute one (kinase, backend) task and tag the rows.
taskis(hgnc_name, obj_kinase, str_method, params)whereparamsis the scalar config dict fromResidueSASA._compute_params().