molecular_simulations.simulate.omm_simulator module

class molecular_simulations.simulate.omm_simulator.CustomForcesSimulator(path, custom_force_objects, equil_steps=1250000, prod_steps=250000000, n_equil_cycles=3, reporter_frequency=1000, platform='CUDA', device_ids=[0], equilibration_force_constant=10.0)

Bases: Simulator

Simulator for utilizing custom user-defined forces. Inherits from Simulator while providing a way to inject custom forces.

Parameters:
  • path (PathLike) – Path to simulation inputs, same as output path.

  • custom_force_objects (list) –

    ??

  • equil_steps (int) – Defaults to 1,250,000 (2.5 ns). Number of simulation timesteps to perform equilibration for (2fs timestep).

  • prod_steps (int) – Defaults to 250,000,000 (1 µs). Number of simulation timesteps to perform production MD for (4fs timestep).

  • n_equil_cycles (int) – Defaults to 3 cycles. Number of additional unrestrained equilibration cycles to perform. Increasing this may triage unstable systems at the cost of more simulation time albeit this may be negligible in the grand scheme of things.

  • reporter_frequency (int) – Defaults to 1,000 timesteps. How often to write out to the logs and trajectory files in equilibration. X times less frequently during production MD.

  • platform (str) – Defaults to CUDA. Which OpenMM platform to simulate with (options include CUDA, CPU, OpenCL).

  • device_ids (list[int]) – Defaults to [0]. Which accelerators to use (multiple GPU support is tenuous with OpenMM). Primarily used to distribute jobs to different GPUs on a node of an HPC resource.

  • force_constant (float) – Defaults to 10.0 kcal/mol*Å^2. Force constant to use for harmonic restraints during equilibration. Currently restraints are only applied to protein backbone atoms.

  • equilibration_force_constant (float)

add_forces(system)

Systematically adds all custom forces to provided system.

Parameters:

system (System) – OpenMM system object.

Returns:

OpenMM system object with custom forces added.

Return type:

(System)

load_amber_files()

Loads OpenMM system and adds in custom forces.

Returns:

OpenMM system object with custom forces.

Return type:

(System)

class molecular_simulations.simulate.omm_simulator.ImplicitSimulator(path, equil_steps=1250000, prod_steps=250000000, n_equil_cycles=3, reporter_frequency=1000, platform='CUDA', device_ids=[0], force_constant=10.0, implicit_solvent=GBn2, solute_dielectric=1.0, solvent_dielectric=78.5)

Bases: Simulator

Implicit solvent simulator. Inherits from Simulator and overloads relevant methods to support the slight differences in how implicit solvent is implemented in OpenMM.

Parameters:
  • path (PathLike) – Path to simulation inputs, same as output path.

  • equil_steps (int) – Defaults to 1,250,000 (2.5 ns). Number of simulation timesteps to perform equilibration for (2fs timestep).

  • prod_steps (int) – Defaults to 250,000,000 (1 µs). Number of simulation timesteps to perform production MD for (4fs timestep).

  • n_equil_cycles (int) – Defaults to 3 cycles. Number of additional unrestrained equilibration cycles to perform. Increasing this may triage unstable systems at the cost of more simulation time albeit this may be negligible in the grand scheme of things.

  • reporter_frequency (int) – Defaults to 1,000 timesteps. How often to write out to the logs and trajectory files in equilibration. X times less frequently during production MD.

  • platform (str) – Defaults to CUDA. Which OpenMM platform to simulate with (options include CUDA, CPU, OpenCL).

  • device_ids (list[int]) – Defaults to [0]. Which accelerators to use (multiple GPU support is tenuous with OpenMM). Primarily used to distribute jobs to different GPUs on a node of an HPC resource.

  • force_constant (float) – Defaults to 10.0 kcal/mol*Å^2. Force constant to use for harmonic restraints during equilibration. Currently restraints are only applied to protein backbone atoms.

  • implicit_solvent (Singleton) – Defaults to GBn2. Which implicit solvent model to use.

  • solute_dielectric (float) – Defaults to 1.0. Probably shouldn’t change this.

  • solvent_dielectric (float) – Defaults to 78.5. Also shouldn’t change this.

equilibrate()

Runs reduced equilibration protocol. Due to the faster convergence of using implicit solvent we don’t need to be quite as rigorous as with explicit solvent system relaxation.

Returns:

OpenMM simulation object.

Return type:

(Simulation)

load_amber_files()

Loads an OpenMM system object with implicit solvent parameters.

Returns:

OpenMM system object.

Return type:

(System)

class molecular_simulations.simulate.omm_simulator.Minimizer(topology, coordinates, out='min.pdb', platform='OpenCL', device_ids=[0])

Bases: object

Class for just performing energy minimization and writing out minimized structures.

Parameters:
  • topology (PathLike) – Topology file which can be either a PDB or an AMBER prmtop.

  • coordinates (OptPath) – Defaults to None. If using a prmtop, you need to provide an inpcrd file for the coordinates. Otherwise these are also acquired from the PDB used as topology.

  • out (PathLike) – Defaults to min.pdb. The name of the output minimized PDB file. The path is inherited from the parent path of the topology file.

  • platform (str) – Defaults to OpenCL. Which OpenMM platform to run.

  • device_ids (list[int]) – Accelerator IDs.

load_amber()

Loads AMBER input files into OpenMM System.

Returns:

OpenMM system object.

Return type:

(System)

load_files()

Loads an OpenMM system depending on what file types you have provided for the topology (AMBER, PDB, etc).

Return type:

None

Returns:

None

load_gromacs()

Loads GROMACS input files into OpenMM System. UNTESTED!

Returns:

OpenMM system object.

Return type:

(System)

load_pdb()

Loads PDB into OpenMM System. Beware the topology guesser.

Returns:

OpenMM system object.

Return type:

(System)

minimize()

Loads an OpenMM system, builds simulation object and runs energy minimization. Dumps final coordinates into output PDB file.

Return type:

None

Returns:

None

class molecular_simulations.simulate.omm_simulator.Simulator(path, equil_steps=1250000, prod_steps=250000000, n_equil_cycles=3, reporter_frequency=1000, platform='CUDA', device_ids=[0], force_constant=10.0)

Bases: object

Class for performing OpenMM simulations on AMBER FF inputs. Inputs must conform to naming conventions found below in the init.

Parameters:
  • path (PathLike) – Path to simulation inputs, same as output path.

  • equil_steps (int) – Defaults to 1,250,000 (2.5 ns). Number of simulation timesteps to perform equilibration for (2fs timestep).

  • prod_steps (int) – Defaults to 250,000,000 (1 µs). Number of simulation timesteps to perform production MD for (4fs timestep).

  • n_equil_cycles (int) – Defaults to 3 cycles. Number of additional unrestrained equilibration cycles to perform. Increasing this may triage unstable systems at the cost of more simulation time albeit this may be negligible in the grand scheme of things.

  • reporter_frequency (int) – Defaults to 1,000 timesteps. How often to write out to the logs and trajectory files in equilibration. X times less frequently during production MD.

  • platform (str) – Defaults to CUDA. Which OpenMM platform to simulate with (options include CUDA, CPU, OpenCL).

  • device_ids (list[int]) – Defaults to [0]. Which accelerators to use (multiple GPU support is tenuous with OpenMM). Primarily used to distribute jobs to different GPUs on a node of an HPC resource.

  • force_constant (float) – Defaults to 10.0 kcal/mol*Å^2. Force constant to use for harmonic restraints during equilibration. Currently restraints are only applied to protein backbone atoms.

static add_backbone_posres(system, positions, atoms, indices, restraint_force=10.0)

Adds harmonic restraints to an OpenMM system.

Parameters:
  • system (System) – OpenMM system object.

  • positions (np.ndarray) – Position array for all atoms in system.

  • atoms (list[topology.Atom]) – List of all Atom objects in system.

  • indices (list[int]) – List of atomic indices to restrain.

  • restraint_force (float) – Defaults to 10.0 kcal/mol*Å^2. The force constant to use for harmonic restraints.

Returns:

OpenMM system with harmonic restraints.

Return type:

(System)

attach_reporters(simulation, dcd_file, log_file, rst_file, restart=False)

Attaches a StateDataReporter for logging, CheckpointReporter to output periodic checkpoints and a DCDReporter to output trajectory data to simulation object.

Parameters:
  • simulation (Simulation) – OpenMM simulation object.

  • dcd_file (PathLike) – DCD file to write to.

  • log_file (PathLike) – Log file to write to.

  • rst_file (PathLike) – Checkpoint file to write to.

  • restart (bool) – Defaults to False. Whether or not we should be appending to an existing DCD file or writing a new one, potentially overwriting an existing DCD (if false).

Returns:

OpenMM simulation object with reporters now attached.

Return type:

(Simulation)

check_num_steps_left()

Reads the production log file to see if we have completed a simulation. If there is still simulation to be completed, decrements the existing progress from internal number of steps to perform. Additionally, accounts for any frames that have been written to DCD that are not accounted for in the log.

Return type:

None

Returns:

None

equilibrate()

Sets up and runs equilibrium MD, including energy minimization to begin. Sets backbone harmonic restraints and performs a slow heating protocol before periodically lessening restraints, finishing with user-specified number of rounds of unrestrained equilibration.

Returns:

OpenMM simulation object.

Return type:

(Simulation)

get_restraint_indices(addtl_selection='')

Obtains atom indices that will be used to set harmonic restraints. First loads an MDAnalysis universe with the input prmtop and inpcrd files. Uses a base selection of protein or nucleic acid backbone but if provided an additional selection can be included for things like restraining ligand molecules.

Parameters:

addtl_selection (str) – Defaults to empty string. If provided, will be used to define additional atoms for restraining.

Returns:

List of atomic indices for atoms to be restrained.

Return type:

(list[int])

load_amber_files()

Builds an OpenMM system using the prmtop/inpcrd files. PME is utilized for electrostatics and a 1 nm non-bonded cutoff is used as well as 1.5 amu HMR.

Returns:

OpenMM system

Return type:

(System)

load_checkpoint(simulation, checkpoint)

Loads a previous checkpoint into provided simulation object.

Parameters:
  • simulation (Simulation) – OpenMM simulation object.

  • checkpoint (PathLike) – OpenMM checkpoint file.

Returns:

OpenMM simulation object that has been checkpointed.

Return type:

(Simulation)

production(chkpt, restart=False)

Performs production MD. Loads a new system, integrator and simulation object and loads equilibration or past production checkpoint to allow either the continuation of a past simulation or to inherit the outputs of equilibration.

Parameters:
  • chkpt (PathLike) – The checkpoint file to load. Should be either the equilibration checkpoint or a past production checkpoint.

  • restart (bool) – Defaults to False. Flag to ensure we log the full simulation to reporter log. Otherwise restarts will overwrite the original log file.

Return type:

None

run()

Main logic of class. Determines whether or not we are restarting based on if all the equilibration outputs are present. Importantly the state file will not be written out until equilibration is complete. Also checks the production MD log to see if we have finished, otherwise decrements our progress from the total number of timesteps. Finally, runs production MD.

Return type:

None

setup_sim(system, dt)

Builds OpenMM Integrator and Simulation objects utilizing a provided OpenMM System object and integration timestep, dt.

Parameters:
  • system (System) – OpenMM system to build simulation object of.

  • dt (float) – Integration timestep in units of picoseconds.

Returns:

A tuple containing both the Simulation

and Integrator objects.

Return type:

(tuple[Simulation, Integrator])