cpptraj (series) → residue×residue H-bond matrices
Use mdsa_tools.Cpptraj_import.cpptraj_hbond_import to parse a cpptraj
hbond ... out <file> series table into residue–residue time-series matrices
compatible with the rest of the pipeline.
What you get
Parsed residue index pairs in column order (
loader.indices).The raw series matrix of shape
(n_frames, n_pairs)(loader.data).A stack of per-frame residue×residue adjacency matrices
(n_frames, n_res+1, n_res+1)viacreate_systems_rep().
Quickstart
Minimal example using a topology readable by MDTraj (e.g., AMBER .prmtop) and a
cpptraj series table. If you’re unfamiliar with generating these, see Data generation (H-bond matrices).
1) Create the `series` table with cpptraj
parm system.prmtop
trajin traj.nc
hbond HB out hbonds.dat series
run
quit
Run with:
cpptraj -i cpptraj.in
2) Load and build matrices
from mdsa_tools.Cpptraj_import import cpptraj_hbond_import
import numpy as np
import os
series_path = "/path/to/hbonds.dat"
topology_path = "/path/to/system.prmtop"
loader = cpptraj_hbond_import(series_path, topology_path)
print("pairs:", loader.indices[:5])
print("series shape:", loader.data.shape) # (n_frames, n_pairs)
systems = loader.create_systems_rep() # (n_frames, n_res+1, n_res+1)
np.save(os.path.join("/path/to/out", "hbonds_residue_series.npy"), systems)
Notes
Matrices store 1-based residue labels in row/column
0; numeric adjacency is[1:, 1:].Self-contacts are zero; no symmetrization is applied by default.
Where this fits
Generate adjacency stacks here, then pass them to
mdsa_tools.Analysis.systems_analysisor plot withmdsa_tools.Viz.
See also
mdsa_tools.Data_gen_hbond— build per-frame H-bond matrices from trajectories.mdsa_tools.Cpptraj_import— parse cpptrajseriestables.mdsa_tools.Analysis.systems_analysis— downstream feature building and PCA.