prolint.contacts.exact_contacts

Exact contact storage and aggregation.

This module provides the ExactContacts class for storing contacts with exact frame-level information and computing duration-based metrics.

Attributes

Classes

ExactContacts

Exact contact storage with duration-based metric computation.

Module Contents

prolint.contacts.exact_contacts.logger[source]
class prolint.contacts.exact_contacts.ExactContacts(ts, contact_frames, norm_factor: float = 1.0)[source]

Bases: prolint.contacts.base.BaseContactStore

Exact contact storage with duration-based metric computation.

Stores contacts at frame-level precision and computes metrics based on contiguous contact durations (binding events).

Parameters:
  • ts (Universe) – MDAnalysis Universe instance.

  • contact_frames (dict) – Nested dict mapping residue_id -> database_id -> list of frame indices.

  • norm_factor (float, default=1.0) – Normalization factor for duration calculations.

contacts[source]

Contact durations organized by residue, database type, and molecule ID.

Type:

dict

contact_frames[source]

Raw frame indices where contacts occur.

Type:

dict

Examples

>>> contacts = universe.compute_contacts(cutoff=7.0)
>>> occupancy = contacts.compute_metric("occupancy", target_resname="CHOL")
>>> mean_duration = contacts.compute_metric("mean")

See also

BaseContactStore

Abstract base class

ComputedContacts

High-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 contacts attribute.

Parameters:

database_resnames (str or list of str, optional) – Residue names to process. If None, processes all unique residue names in the database.

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:

dict

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:

dict

Examples

>>> # Custom metric: number of binding events
>>> n_events = contacts.apply_function(len, target_resname="CHOL")
compute_database_durations(contact_frame: Dict[int, List[int]], database_resname: str) Dict[int, numpy.ndarray][source]

Compute contact durations for a specific database residue type.

Parameters:
  • contact_frame (dict) – Mapping of database_id -> list of frame indices.

  • database_resname (str) – Residue name to filter by.

Returns:

Mapping of database_id -> array of contact durations.

Return type:

dict