H-bond detection#

Hydrogen bond detection (Baker–Hubbard).

  • Rust (phenoms_hbond_rs): fast batched geometry when the extension is built; falls back to MDTraj otherwise.

  • Polars (required): per-bond occupancy summaries in hbond_occupancy_table() and any export path that uses it (Rust does not call Polars; detection stays in Rust).

  • Backbone mode (default): donor/acceptor filtered to backbone-relevant N–O pairs.

  • All-bonds mode: include all donor/acceptor atom classes supported by topology.

phenoms.hbond.label_hbond(hbond, trajectory)[source]#

Label a hydrogen bond as ‘residue1 – residue2’ only if it is N–O (backbone-relevant). Returns None otherwise.

Parameters:
  • hbond (tuple (donor_idx, hydrogen_idx, acceptor_idx))

  • trajectory (mdtraj.Trajectory (single frame or full; only topology is used))

Returns:

e.g. ‘ALA1 – GLY2’ or None

Return type:

str or None

phenoms.hbond.process_frame(frame, trajectory)[source]#

Run Baker–Hubbard on one frame and label N–O bonds (MDTraj path).

phenoms.hbond.label_hbond_all(hbond, trajectory)[source]#

Label any detected H-bond as ‘DONORRES:ATOM – ACCEPTORRES:ATOM’.

phenoms.hbond.process_frame_all(frame, trajectory)[source]#

Run Baker-Hubbard on one frame and keep all detected donor/acceptor types.

phenoms.hbond.process_frames(trajectory, sub_frames=None, n_jobs=1, use_rust=True)[source]#

Process all (or sub_frames) frames; return N–O H-bonds only. Uses Rust when available and topology has bonds; otherwise MDTraj (parallel).

The Rust path uses the same geometric criteria as MDTraj Baker–Hubbard: r(H···A) < 0.25 nm and ∠D–H–A > 120° (angle at H). Use use_rust=False only for debugging or if the extension is not built.

phenoms.hbond.process_frames_all(trajectory, sub_frames=None, n_jobs=1, use_rust=True)[source]#

Process all (or sub_frames) frames; return all detected H-bonds (not backbone-only). Uses Rust when available and topology has bonds; otherwise MDTraj (parallel).

phenoms.hbond.hbond_occupancy_table(hbonds_df)[source]#

Build a per-bond occupancy summary from a frame-level H-bond DataFrame.

Returns columns:
  • Bond Label

  • Present Frames

  • Total Frames

  • Occupancy

Uses Polars for the aggregation (required dependency).

phenoms.hbond.export_hbond_occupancy_csv(hbonds_df, output_csv_path)[source]#

Write per-bond occupancy summary CSV.