prolint.contacts¶
Contact storage and aggregation strategies.
This module provides classes for storing contact data and computing duration-based metrics from contact frame indices.
Submodules¶
Classes¶
Abstract base class for contact storage strategies. |
|
Exact contact storage with duration-based metric computation. |
Package Contents¶
- class prolint.contacts.BaseContactStore(ts, contact_frames, norm_factor: float = 1.0)[source]¶
Abstract base class for contact storage strategies.
Defines the interface for storing and computing metrics on contact data. Subclasses implement specific storage and aggregation strategies.
- Parameters:
See also
ExactContactsConcrete implementation for exact contact aggregation
- norm_factor¶
- contact_frames¶
- abstractmethod run(database_resnames: str | List = None)[source]¶
Process contact frames into aggregated contact data.
- Parameters:
database_resnames (str or list of str, optional) – Residue names to process. If None, processes all.
- Raises:
NotImplementedError – Subclasses must implement this method.
- compute(metric: str, target_resname=None)[source]¶
Compute a standard metric on contacts.
- Parameters:
metric ({"max", "sum", "mean", "occupancy"}) – Metric to compute.
target_resname (str, optional) – Filter by residue name.
- Returns:
Computed metric values.
- Return type:
- Raises:
ValueError – If metric is not recognized.
- abstractmethod compute_metric(metric: str, target_resname=None)[source]¶
Compute a specific metric. Implemented by subclasses.
- Parameters:
- Raises:
NotImplementedError – Subclasses must implement this method.
- abstractmethod apply_function(func: Callable, target_resname=None)[source]¶
Apply a custom function to contact data.
- Parameters:
func (callable) – Function to apply to contact durations.
target_resname (str, optional) – Filter by residue name.
- Raises:
NotImplementedError – Subclasses must implement this method.
- property contacts¶
Processed contact data.
- Returns:
Contact data organized by residue and database molecule.
- Return type:
- Raises:
ValueError – If run() has not been called yet.
- class prolint.contacts.ExactContacts(ts, contact_frames, norm_factor: float = 1.0)[source]¶
Bases:
prolint.contacts.base.BaseContactStoreExact contact storage with duration-based metric computation.
Stores contacts at frame-level precision and computes metrics based on contiguous contact durations (binding events).
- Parameters:
Examples
>>> contacts = universe.compute_contacts(cutoff=7.0) >>> occupancy = contacts.compute_metric("occupancy", target_resname="CHOL") >>> mean_duration = contacts.compute_metric("mean")
See also
BaseContactStoreAbstract base class
ComputedContactsHigh-level wrapper for contact results
- run(database_resnames: str | List = None) None[source]¶
Aggregate contact frames into contact durations.
Processes raw contact frame indices into contiguous binding events (durations) for each residue-molecule pair. Results are stored in the
contactsattribute.
- compute_metric(metric: str, target_resname=None)[source]¶
Compute a metric across all contacts.
- Parameters:
metric ({"max", "sum", "mean", "occupancy"}) – Metric to compute: - “occupancy”: Fraction of frames with contact - “mean”: Mean contact duration - “max”: Maximum contact duration - “sum”: Total contact duration
target_resname (str, optional) – Filter by database residue name (e.g., “CHOL”).
- Returns:
Nested dict with structure: {residue_id: {database_name: {“global”: value, “per_id”: {id: value}}}}
- Return type:
- apply_function(func: Callable, target_resname=None)[source]¶
Apply a custom function to contact duration arrays.
- Parameters:
func (callable) – Function that takes an array of durations and returns a value.
target_resname (str, optional) – Filter by database residue name.
- Returns:
Function results organized by residue and database ID.
- Return type:
Examples
>>> # Custom metric: number of binding events >>> n_events = contacts.apply_function(len, target_resname="CHOL")