molecular_simulations.simulate.mmpbsa module¶
- class molecular_simulations.simulate.mmpbsa.MMPBSASettings(top, dcd, selections, first_frame=0, last_frame=-1, stride=1, n_cpus=1, out='mmpbsa', solvent_probe=1.4, offset=0, gb_surften=0.0072, gb_surfoff=0.0)[source]¶
Bases:
objectSettings dataclass for MMPBSA calculations.
- top¶
Path to topology file.
- dcd¶
Path to trajectory file.
- selections¶
List of residue selections for receptor and ligand.
- first_frame¶
First frame to analyze.
- last_frame¶
Last frame to analyze (-1 for all).
- stride¶
Frame stride.
- n_cpus¶
Number of parallel processes.
- out¶
Output prefix/path.
- solvent_probe¶
Probe radius for SASA.
- offset¶
SASA offset parameter.
- gb_surften¶
GB surface tension parameter.
- gb_surfoff¶
GB surface offset parameter.
- __init__(top, dcd, selections, first_frame=0, last_frame=-1, stride=1, n_cpus=1, out='mmpbsa', solvent_probe=1.4, offset=0, gb_surften=0.0072, gb_surfoff=0.0)¶
- class molecular_simulations.simulate.mmpbsa.MMPBSA(top, dcd, selections, first_frame=0, last_frame=-1, stride=1, n_cpus=1, out='mmpbsa', solvent_probe=1.4, offset=0, gb_surften=0.0072, gb_surfoff=0.0, amberhome=None, parallel_mode='frame', **kwargs)[source]¶
Bases:
MMPBSASettingsPerform MM-P(G)BSA calculations with parallelization support.
A reconstructed implementation of AMBER’s MM-P(G)BSA workflow with improved documentation and parallelization options. Supports both Generalized Born (GB) and Poisson-Boltzmann (PB) solvation methods.
- path¶
Working directory for calculations.
- fh¶
FileHandler instance for file management.
- analyzer¶
OutputAnalyzer instance for parsing results.
- free_energy¶
Final binding free energy after run().
- Parameters:
top (
Path|str) – Path to solvated system topology (prmtop).selections (
list[str]) – List of two residue ID selections for receptor and ligand, formatted for cpptraj (e.g., ‘:1-10’).first_frame (
int) – First frame to analyze. Defaults to 0.last_frame (
int) – Last frame (-1 for all). Defaults to -1.stride (
int) – Frame stride. Defaults to 1.n_cpus (
int) – Number of parallel processes. Defaults to 1.out (
str) – Output prefix or path. Defaults to ‘mmpbsa’.solvent_probe (
float) – Probe radius for SASA in Angstroms. Defaults to 1.4.offset (
int) – SASA offset. Defaults to 0.gb_surften (
float) – GB surface tension. Defaults to 0.0072.gb_surfoff (
float) – GB surface offset. Defaults to 0.0.amberhome (
str|None) – Path to AMBERHOME. If None, uses $AMBERHOME env var.parallel_mode (
Literal['frame','serial']) – ‘frame’ for frame-level parallelization (recommended), ‘serial’ for sequential processing.**kwargs – Additional keyword arguments stored as attributes.
Example
>>> mmpbsa = MMPBSA( ... "system.prmtop", "traj.dcd", [":1-100", ":101-150"], n_cpus=4 ... ) >>> mmpbsa.run() >>> print(mmpbsa.free_energy)
Initialize the MMPBSA calculator.
- Parameters:
first_frame (
int) – Starting frame.last_frame (
int) – Ending frame.stride (
int) – Frame stride.n_cpus (
int) – Number of CPUs.out (
str) – Output path/prefix.solvent_probe (
float) – SASA probe radius.offset (
int) – SASA offset.gb_surften (
float) – GB surface tension.gb_surfoff (
float) – GB surface offset.parallel_mode (
Literal['frame','serial']) – Parallelization strategy.**kwargs – Additional attributes.
- __init__(top, dcd, selections, first_frame=0, last_frame=-1, stride=1, n_cpus=1, out='mmpbsa', solvent_probe=1.4, offset=0, gb_surften=0.0072, gb_surfoff=0.0, amberhome=None, parallel_mode='frame', **kwargs)[source]¶
Initialize the MMPBSA calculator.
- Parameters:
first_frame (
int) – Starting frame.last_frame (
int) – Ending frame.stride (
int) – Frame stride.n_cpus (
int) – Number of CPUs.out (
str) – Output path/prefix.solvent_probe (
float) – SASA probe radius.offset (
int) – SASA offset.gb_surften (
float) – GB surface tension.gb_surfoff (
float) – GB surface offset.parallel_mode (
Literal['frame','serial']) – Parallelization strategy.**kwargs – Additional attributes.
- run()[source]¶
Execute the complete MM-PBSA workflow.
Runs file preparation, energy calculations, and result analysis using the configured parallelization mode.
- Return type:
- calculate_energy(pre, prm, trj, pdb, mdin, suf)[source]¶
Run mmpbsa_py_energy to compute system energy.
- class molecular_simulations.simulate.mmpbsa.OutputAnalyzer(path, surface_tension=0.0072, sasa_offset=0.0, _tolerance=0.005, log=True)[source]¶
Bases:
objectAnalyze and summarize MM-PBSA output files.
Parses energy output files and computes binding free energies for both GB and PB solvation methods.
- path¶
Working directory path.
- surften¶
Surface tension parameter.
- offset¶
SASA offset parameter.
- free_energy¶
Final [mean, std] after parse_outputs().
- gb¶
Polars DataFrame of GB results.
- pb¶
Polars DataFrame of PB results.
- Parameters:
Initialize the OutputAnalyzer.
- Parameters:
- __init__(path, surface_tension=0.0072, sasa_offset=0.0, _tolerance=0.005, log=True)[source]¶
Initialize the OutputAnalyzer.
- check_bonded_terms()[source]¶
Verify bonded terms cancel correctly between systems.
- Raises:
ValueError – If bonded terms don’t cancel.
- Return type:
- class molecular_simulations.simulate.mmpbsa.FileHandler(top, traj, path, sels, first, last, stride, cpptraj_binary, n_chunks=1)[source]¶
Bases:
objectHandle file preprocessing for MM-PBSA calculations.
Manages trajectory conversion, topology slicing, and file organization.
- top¶
Path to topology file.
- traj¶
Path to trajectory file.
- path¶
Working directory.
- selections¶
Receptor and ligand selections.
- topologies¶
List of generated topology paths.
- trajectories¶
List of generated trajectory paths.
- pdbs¶
List of generated PDB paths.
- trajectory_chunks¶
Dictionary of chunked trajectories.
- Parameters:
Initialize the FileHandler.
- Parameters:
- __init__(top, traj, path, sels, first, last, stride, cpptraj_binary, n_chunks=1)[source]¶
Initialize the FileHandler.
- Parameters:
- property files: zip[tuple[Path, Path, Path, Path]]¶
Get file paths for each system.
- Returns:
Zip of (prefix, topology, trajectory, pdb) for each system.