moleculekit.openmmtools module#

moleculekit.openmmtools.minimize_soft_potential(mol, mobile_atom_indices, max_iterations=200)#

Run a soft-potential energy minimization on selected atoms.

All other atoms are frozen (mass = 0). Uses a soft repulsive CustomNonbondedForce so overlapping atoms are gently pushed apart rather than exploding. Only interactions involving at least one mobile atom are computed.

Harmonic bond and angle restraints are added for bonds in mol.bonds involving at least one mobile atom; equilibrium values are taken from the current coordinates. This keeps bond lengths and angles close to their starting geometry so the minimization resolves clashes by rotating dihedrals rather than distorting covalent structure.

Parameters:
  • mol (Molecule) – The molecule to minimize (modified in place).

  • mobile_atom_indices (set | list) – Indices of atoms that are free to move.

  • max_iterations (int) – Maximum number of minimization iterations. Default 200.

Returns:

True if minimization was performed, False if OpenMM is unavailable.

Return type:

bool

moleculekit.openmmtools.openmm_to_molecule(topology, positions)#

Convert an OpenMM topology and positions into a Molecule.

Atom names, elements, residue names, residue ids, chains, insertion codes, formal charges, coordinates and bonds are copied from the OpenMM topology into a new Molecule object.

Parameters:
  • topology (openmm.app.Topology) – The OpenMM topology describing the atoms, residues, chains and bonds.

  • positions (openmm.unit.Quantity) – The atom positions as an OpenMM Quantity (e.g. with nanometer units). They are converted to Angstrom in the resulting Molecule.

Returns:

mol – The molecule built from the OpenMM topology and positions.

Return type:

Molecule