Core workflow#
- class phenoms.SimulationSet(pdb_files=None, resid_range=None, sub_frames=None, bond_statistics_threshold=None, output_dir=None, *, trajectories=None, topology=None, topologies=None, backbone_only=True)[source]#
Bases:
objectSingle or replicate MD simulations with H-bond analysis.
Simple form (unchanged): pass multi-frame PDB paths via
pdb_files.Native trajectories: pass
trajectories=plustopology=/topologies=, or usefrom_trajectories().backbone_only=True(default): Baker–Hubbard backbone N–O bonds (HDX-style).backbone_only=False: all detected donor/acceptor H-bonds.resid_range: filters heatmaps / manifold plots only; detection still runs on protein.
- classmethod from_trajectories(trajectories, topology=None, topologies=None, *, resid_range=None, sub_frames=None, bond_statistics_threshold=None, output_dir=None, backbone_only=True)[source]#
Build a SimulationSet from native MD trajectory + topology file(s).
- run(n_jobs=None, use_rust=True, *, qc=False, mdp_files=None, skip_mdp_consistency=False, qc_fail_on_nonconverged=True, qc_last_fraction=0.2, qc_mean_tolerance=0.05, qc_slope_tolerance=0.0001)[source]#
Load all trajectories, run Baker–Hubbard detection, build pivot tables. If bond_statistics_threshold was set, compute per-replicate stats and mean ± std.
- Parameters:
n_jobs (int or None) – MDTraj parallel workers per replicate (Rust path ignores this).
None=default_n_jobs()(all CPUs minus two).use_rust (bool) – If True, use Rust extension when available. Set False if Rust returns no bonds for your topology (MDTraj fallback).
qc (bool) – If True, run a simple replicate QC pass (RMSD convergence and optional MDP checks).
mdp_files (list[str] or None) – Optional list of .mdp paths to compare for parameter consistency.
skip_mdp_consistency (bool) – If True, skip MDP checks even if mdp_files are supplied.
qc_fail_on_nonconverged (bool) – If True, raise RuntimeError when any replicate fails RMSD convergence.
- export_run_artifacts(output_dir)[source]#
Write per-replicate H-bond tables, Polars-backed occupancy summaries, pivots, and a small
manifest.jsonunderoutput_dir/raw_data/.Safe to call again after
run()with a different path.
- property bond_statistics#
None or dict with mean_lifetimes, std_lifetimes, mean_break_frequencies, std_break_frequencies.
- plot_heatmaps(save_dir=None, use_legend=False)[source]#
Plot one heatmap per replicate (whole protein or region, depending on resid_range). Bond rows = union of bonds found in this set’s replicates. For comparison of two sets with aligned bond lists, use ComparisonSet.plot_heatmaps_both() instead.
- plot_top_hbonds(threshold=0.5, save_path=None)[source]#
Bar plot of top H-bonds by average lifetime (presence fraction > threshold).
- plot_bond_statistics(lifetime_title='Average Lifetime of Hydrogen Bonds with Standard Deviation (Threshold = 50%)', break_title='Frequency of Breaks of Hydrogen Bonds with Standard Deviation', save_lifetime_path=None, save_break_path=None)[source]#
Bar plots for mean lifetime and break frequency with error bars (requires bond_statistics_threshold).
- plot_aggregated_heatmap(save_path=None)[source]#
Average presence of each bond across all replicates.
- get_fluctuating_bonds(quantile=0.9)[source]#
Bonds with highest variance (fluctuation) across frames. For single-set highlighting.
- run_pca(group_labels=None, plot=True, title='PCA')[source]#
PCA on this set’s replicates (one point per replicate). Same bond space as two-set case.
- run_tsne(group_labels=None, perplexity=2, plot=True, title='t-SNE', random_state=42)[source]#
t-SNE on this set’s replicates.
- run_isomap(group_labels=None, n_neighbors=5, plot=True, title='Isomap')[source]#
Isomap on this set’s replicates.
- class phenoms.ComparisonSet(set_a, set_b, label_a='set_a', label_b='set_b', *, output_dir=None)[source]#
Bases:
objectTwo simulation sets (e.g. no ligand vs ligand): compare, plot difference, write PDB, run PCA/t-SNE/Isomap.
- export_connectivity_graph_html(output_html_path, *, graph_mode='diff', top_k_edges=30, min_abs_edge_delta=None, directed=False, title=None)[source]#
Export an interactive HTML residue connectivity graph derived from bond-level deltas.
- graph_mode:
“diff”: edges sized by abs(Δ occupancy) and colored by sign (sign consistent with flip_difference in compare()).
“set_a” / “set_b”: edges sized by occupancy (no sign).
- export_connectivity_community_graph_html(output_html_path, *, graph_mode='diff', top_k_edges=40, min_abs_edge_delta=None, directed=False, resolution=1.0, title=None, community_nodes_csv_path=None, community_summary_csv_path=None)[source]#
Export a community-aware connectivity graph and optional community CSV summaries.
- graph_mode:
“diff”: edges use delta occupancy (sign preserved).
“set_a”/”set_b”: edges use occupancy in that set.
- get_unified_bond_labels()[source]#
Union of all bond labels from both sets, sorted (for aligned heatmaps).
- plot_heatmaps_both(save_dir=None, use_legend=False)[source]#
Plot heatmaps for all replicates in both sets using a unified bond list, so the same H-bonds appear in the same order on every heatmap (missing bonds = 0).
- export_comparison_artifacts(output_dir)[source]#
Write
raw_data/comparison.csv(bond-level Δ table) andmanifest.jsonunderoutput_dir. Call aftercompare()(or rely onget_comparison_df()which triggerscompare()with defaults).
- phenoms.run_backbone_hbond_analysis(pdb_files, resid_range=None, sub_frames=None, n_jobs=None, plot_heatmaps=True, bond_statistics_threshold=None, output_dir=None, *, backbone_only=True)[source]#
One-shot: load replicates, run H-bond analysis, build pivot tables, optionally plot heatmaps and/or compute bond statistics.
Defaults to backbone N–O mode (
backbone_only=True). Passbackbone_only=Falsefor all-bond detection.
- phenoms.simulation_set_from_dir(input_dir, prepared_dir, *, resid_range=None, sub_frames=None, bond_statistics_threshold=None, output_dir=None, frame_dt_ps=1000.0, start_ps=None, end_ps=None, apply_imaging=True, center=True, fit=True, backbone_only=True)[source]#
Build a SimulationSet from a replicate directory or set directory.
Normalizes engine-native inputs (GROMACS/OpenMM/AMBER) to multi-frame PDBs, then returns a ready-to-
.run()SimulationSet. Backbone-only is the default.
- phenoms.comparison_sets_from_dirs(dir_a, dir_b, prepared_dir_a, prepared_dir_b, *, resid_range=None, sub_frames=None, bond_statistics_threshold=None, output_dir_a=None, output_dir_b=None, output_dir=None, frame_dt_ps=1000.0, start_ps=None, end_ps=None, apply_imaging=True, center=True, fit=True, label_a='set_a', label_b='set_b', backbone_only=True)[source]#
Build two SimulationSet objects from two class directories (e.g., WT and MUT).
output_dircontrols where the ComparisonSet’s own default bundle goes (None= auto-timestamped,False= disabled);output_dir_a/output_dir_bcontrol each SimulationSet’s own bundle independently.Returns (set_a, set_b, comparison_set).
- phenoms.detect_hbonds(path, *, top=None, sub_frames=None, n_jobs=None, use_rust=True, backbone_only=True)[source]#
Detect hydrogen bonds from a PDB or native trajectory path.
- Parameters:
path (str) – Trajectory / PDB path.
top (str or None) – Topology for native MD formats (
.xtc/.nc/…).sub_frames (int or None) – Number of frames to process; None uses all.
n_jobs (int or None) – Parallel jobs for MDTraj fallback; defaults to
default_n_jobs().use_rust (bool) – If True, use Rust backend when available.
backbone_only (bool) – If True (default), keep only backbone N–O labels. If False, return all detected donor/acceptor H-bonds.
- phenoms.detect_hbonds_with_occupancy(path, *, top=None, sub_frames=None, n_jobs=None, use_rust=True, backbone_only=True, output_csv_path=None)[source]#
Detect H-bonds and return both frame-level and occupancy summaries. Optionally writes occupancy summary CSV.