neurosnap.algos.amber_relax module#
Amber-style relaxation / energy minimization utilities built on OpenMM.
This module loads a PDB, cleans it with PDBFixer (adds missing atoms/hydrogens, replaces nonstandard residues), removes waters and non-biopolymers, and then performs energy minimization (“relaxation”) using the Amber14 force field (amber14-all.xml with amber14/tip3p.xml). By default it uses HBond constraints, no PME (NoCutoff), and a Langevin integrator (300 K, 2 fs) for context initialization; only the minimizer is used to relax coordinates.
Requirements#
OpenMM (python package openmm) must be installed to use any function here.
pdbfixer is required for structure fixing.
NumPy is used for RMSD calculations.
Optional: CUDA-compatible GPU for faster context creation/minimization (set use_gpu=True, uses mixed precision and disables PME stream).
Key functions#
minimize(…): Run energy minimization on a PDB file. Accepts a tolerance in kcal/mol (clamped to [0.1, 10.0]), supports GPU/CPU selection, and returns a dict with rmsd (Å), initial_energy and final_energy (kJ/mol). B-factors from the input PDB are preserved and copied to the minimized output.
_compute_rmsd(…): Internal RMSD helper (nm in OpenMM units; returned as Å).
_load_bfactors_from_pdb(…) / _apply_bfactors_to_pdb(…): Internal helpers to snapshot and restore B-factors on ATOM/HETATM records.
Notes & caveats#
Uses NoCutoff for nonbonded interactions; adapt if you need PME/periodic systems. Hydrogens are constrained via HBonds.
Minimization stops when the maximum force falls below the specified tolerance (converted to kJ/mol) or when max_iterations is reached.
Example
>>> minimize("input.pdb", output_minimized_pdb="minimized.pdb",
... tolerance=1.0, max_iterations=1000, use_gpu=True)
- neurosnap.algos.amber_relax.minimize(pdb_file, output_minimized_pdb='minimized.pdb', max_iterations=1000, tolerance=1.0, use_gpu=True, properties={})[source]#
Loads a PDB file and performs energy minimization with a specified tolerance.
- Parameters:
pdb_file (
str) – Path to input PDB file.output_minimized_pdb (
str) – Path to output minimized PDB file.max_iterations (
int) – Number of minimization iterations.tolerance (
float) – Convergence tolerance in Kcal/mol (range: 0.1 - 10.0).use_gpu (
bool) – Whether to use GPU (CUDA). Defaults to True.properties (
dict[str,Any]) – Platform properties to provide to OpenMM if needed.
- Returns:
Contains RMSD, initial energy, and final energy.
- Return type: