TIES_MD package

Subpackages

Submodules

TIES_MD.TIES module

class TIES_MD.TIES.TIES(cwd, exp_name='complex', run_type='class', devices=None, rep_id=None, windows_mask=None, periodic=True, platform='CUDA', fast=False, lam=None, **kwargs)

Bases: object

Class to control TIES protocol, initializes variables and calls functions to start simulation or write input scripts

Parameters:
  • cwd – str, for current working directory

  • exp_name – str, for the names of experiment i.e. complex -> complex.pdb/complex.prmtop

  • run_type – str, flag to say if we should run dynamics or not

  • devices – list, list of ints for which cuda devices to use

  • rep_id – float, id denoting what replica of this simulation this execution of TIES_MD should run

  • windows_mask – list containing ints for start and end range of windows to be run

  • periodic – boolean determines if the simulation will be periodic

  • lam – Lambda class, allow passing of custom lambda schedule

  • platform – sting determines what platform OpenMM will target allowed values are [β€˜CPU’, β€˜CUDA’, β€˜OpenCL’, β€˜HIP’]

  • fast – bool, Do we want safe or fast settings for MD simulations

  • **kwargs –

    dict, containing setting from config file

build_results_dirs(folders)

Helper function to build output directories. :param folders: List of strings for what folders to build.

Returns:

None

property cell_basis_vec1

What is the 1st basis vector of the simulation cell

Returns:

list of floats for x, y, z components of vector

property cell_basis_vec2

What is the 2nd basis vector of the simulation cell

Returns:

list of floats for x, y, z components of vector

property cell_basis_vec3

What is the 3rd basis vector of the simulation cell

Returns:

list of floats for x, y, z components of vector

property elec_edges

here in lambda schedule (0->1) should the electrostatic potentials begin, stop appearing.

Returns:

list of floats for when the electrostatic potentials begin, stop appearing.

property engine

What molecular dynamics engine is going to be used (openmm/namd2.14/namd3)

Returns:

string for molecular dynamics engine.

get_options()

Prints out the options the user can change and their current values.

Returns:

None

property global_lambdas

The global values of lambda in the lambda schedule.

Returns:

list of floats for lambda schedule

run()

Function to run the simulations in parallel

Returns:

None

setup()

Function to setup simulations and then stop

Returns:

None

property split_run

boolean that sets if each execution of TIESMD or NAMD runs all replicas or a subset.

Returns:

bool for if run is split

property ster_edges

Where in lambda schedule (0->1) should the Lennard_Jones potentials begin, stop appearing.

Returns:

list of floats for when the Lennard_Jones potentials begin, stop appearing.

update_cfg()

Write a TIES config file this should be called after api changes are made.

Returns:

None

write_analysis_cfg()

Function to write the input configuration files for analysis.

Returns:

None

write_namd_eq()

Function to write eq1 and eq2 namd scripts used for equilibration.

Returns:

None

write_namd_min()

Function to write eq0.conf scripts used in minimization stage

Returns:

None

write_namd_prod()

Function to write sim1 namd conf script for production simulation.

Returns:

None

write_namd_scripts()

Function to call all functions needed to write all namd input scripts

Returns:

None

write_namd_submissions()

Function to write an example submission script of NAMD job on HPC (ARCHER2).

Returns:

None

write_openmm_submission()

Function to write an example submission script of OpenMM job on HPC (Summit).

Returns:

None

TIES_MD.TIES.get_box_vectors(box_type, d)

Function to compute the box vectors if we know the box type and edge length.

Parameters:
  • box_type – str, defining the bix type to make vectors for

  • d – float for edge length of box unit angstrom

Returns:

list of Vec3 for each basis vector

TIES_MD.TIES.get_header_and_run(engine, namd_version, split_run, num_windows, reps, exp_name, devices)

Function to prep submission file. Number of windows and replicas are inspected to make best guess at number of nodes and CPUS/GPUS

Parameters:
  • engine – str, What engine are we using [namd, openmm]

  • namd_version – float, What version of namd are we using if any

  • split_run – bool, Should each run line run all or one replica

  • num_windows – int for number of windows running

  • reps – int, number of replica simulations

  • exp_name – str, name of the experiment e.g. complex

  • devices – list of ints for which gpus to target

Returns:

str, str for header and run line of HPC sub script

TIES_MD.TIES.nice_print(string)

Function to print str with padding. :param string: A string which should be printed.

Returns:

None

TIES_MD.TIES.read_config(config_file)

Function to read config file from disk :param config_file: str pointing to TIES.cfg file :return: dict, containing all config file args

TIES_MD.alch module

class TIES_MD.alch.AlchSys(cwd, name, temperature, pressure, constraint_file, constraint_column, methods, basis_vectors, input_type='AMBER', absolute=False, periodic=True, platform='CUDA', fast=False, debug=False)

Bases: object

Class containing one leg of binding free energy calculation

Parameters:
  • cwd – str, for current working directory

  • name – str, name of system

  • temperature – temperature of the simulation and target for the thermostat

  • pressure – pressure of the simulation and target for the barostat

  • constraint_file – str, for location of pdb which details constraints

  • constraint_column – str, defines if constraints are read from the beta or occupancy columns

  • methods – list of str, list for what methods we want to use example [β€˜MBAR’, β€˜TI’]

  • basis_vectors – list of list containing explicit cell vectors

  • absolute – boolean determines if we are doing an absolute calculation

  • periodic – boolean determines if we are doing PME or CutoffNonPeriodic

  • platform – sting determines what platform OpenMM will target allowed values are [β€˜CPU’, β€˜CUDA’, β€˜OpenCL’]

  • fast – bool, will deviate from NAMD setting at use fastest recommended settings for simulation

  • debug – bool, removes all forces but nonbonded for testing

Note: GROMACS input and Absolute calculations are currently not tested.

add_consraints()

Function to add constraints to OpenMM system. Uses values for constrains initialized from file during class construction. Note: as written these constraints may not work with periodic boundary conditions on GPU.

Returns:

None

amend_original_positions(positions)

Function to update the stored positions if a clash of atoms is found during initialization.

Parameters:

positions – list, for the positions of all atoms in the system to be used to initialise simulations

Returns:

None

build_simulation(system, device_id)

Function to take OpenMM system and build OpenMM simulation object.

Parameters:
  • system – OpenMM system object

  • device_id – str, index for which cuda device this simulation will run on

Returns:

dict, containing OpenMM simulation and integrator.

debug_force(system)

Function which removes all but nonbonded forces while maintaining NPT ensemble

Parameters:

system – OpenMM system to modify

Returns:

None

get_gradients(param, val, context, h, analitic_sterics=False)

Function to compute the gradients of the potential w.r.t the alchemical parameters.

Parameters:
  • param – string, for lambda parameter eg β€˜lambda_electrostatics_appear’

  • val – float, value of lambda parameter

  • context – OpenMM Context

  • context – OpenMM Context

  • h – float, finite difference to use

  • analitic_sterics – boolean, are analytic steric gradients calculated (experimental)

Returns:

float, gradient calculated with numerical finite difference

get_intersect_angles(system, appear_idxs, disappear_idxs)

Function to get the idxs of angles which straddle the alchemical region.

Parameters:
  • system – OpenMM system object

  • appear_idxs – list of indexes for appearing atoms

  • disappear_idxs – list of indexes for dissapearing atoms

Returns:

list of indexes for angles which straddle alchemical regions

get_intersect_bonds(system, appear_idxs, disappear_idxs)

Function to get the idxs of bonds which straddle the alchemical region.

Parameters:
  • system – OpenMM system object

  • appear_idxs – list of indexes for appearing atoms

  • disappear_idxs – list of indexes for dissapearing atoms

Returns:

list of indexes for bonds which straddle alchemical regions

get_intersect_torsions(system, appear_idxs, disappear_idxs)

Function to get the idxs of torsions which straddle the alchemical region.

Parameters:
  • system – OpenMM system object

  • appear_idxs – list of indexes for appearing atoms

  • disappear_idxs – list of indexes for disappearing atoms

Returns:

list of indexes for torsions which straddle alchemical regions

rebuild_torsion(system, intersect_torsions)

Function to rebuild torsion force without any non physical torsion which straddle the alchemical region. We want to remove these fully as some times they result in nan evals.

Parameters:
  • system – OpenMM system

  • intersect_torsions – List of ints, ints references torsions that straddle the alchemical regions.

Returns:

None

set_context_to_state(param_vals, context, NPT=True)

Function to set the lambda values of the stored OpenMM contexts.

Parameters:
  • param_vals – dict, containing lambda values

  • context – the context we want to modify

  • NPT – bool, flag to see if this is the NPT or NVT context

Returns:

None

shift_alchemical_positions()

Function to add a small pertubation to the positions of all appearing atoms in alchemical region. This can help to resolve any nans caused by overlapping atoms.

Returns:

None

test_sim(simulation)

Function to test if system can be minimized, useful to find clashed atoms or undefined potentials

Parameters:

simulation – OpenMM simulation object to test.

Returns:

None

class TIES_MD.alch.PDB_line(line)

Bases: object

Class to let us address line of a PDB file in a readable format

Parameters:

line – str, file path to pdb

class TIES_MD.alch.System_ID(device_id, rep_id)

Bases: object

Class as a ID for a simulation providing information for what GPU this simulation should run on and what number repeat this simulation is out of some total number of repeats.

Parameters:
  • device_id – int, for OpenMM GPU device id

  • rep_id – str, id number denoting which replica this is

TIES_MD.alch.add_simulation_reporters(sim, total_steps, save)

Function to add reporters to a simulation.

Parameters:
  • sim – OpenMM simulation object to add a reporter to

  • total_steps – int for the number of total steps in the simulation

  • save – string pointing to the file location to save dcd

Returns:

None

TIES_MD.alch.equilibriation(NVT, NPT, steps, save_file, constraint)

Perform NVT and then NPT equilibration for total time defined by user.

Parameters:
  • NVT – dict, containing OpenMM simulation and integrator objects for NVT simulation

  • NPT – dict, containing OpenMM simulation and integrator objects for NPT simulation

  • steps – int, number of equilibration steps

  • save_file – string, where to write the equilibrating state

  • constraint – list or None, indicates whether this system has constraints

Returns:

None

TIES_MD.alch.get_alchemical_atoms(pdb_file, absolute)

Function to read PDB file and pull out alchemical indexes from temp factor or occupancy column (set by user).

Parameters:
  • pdb_file – str, pointing to the PDB file to read

  • absolute – bool, used in logic to determine how to read idxs

Returns:

List, List of ints addressing appearing and disappearing alchemical atoms

TIES_MD.alch.get_constraints(file, column)

Fuction to read constraints from PDB file.

Parameters:
  • file – str, file path to pdb containing constraint information

  • column – str, determines whether the occupancy row of temp factor will be read for data

Returns:

list, list of floats for constraint strength on each atom

TIES_MD.alch.minimization(NVT, constraint)

Performs minimization and constraint relaxation.

Parameters:
  • NVT – list[context, integrator] for NVT system

  • constraint – list or None, indicates whether this system has constraints

Returns:

None

TIES_MD.alch.preproduction(NVT, NPT, equili_steps, equili_state_file, constraint)

Meta function to wrap minimization and equilibration together.

Parameters:
  • NVT – dict, containing OpenMM simulation and integrator objects for NVT simulation

  • NPT – dict, containing OpenMM simulation and integrator objects for NPT simulation

  • equili_steps – int, number of total NVT and NPT equilib steps to perform

  • equili_state_file – string, where to write the equilibrating state

  • constraint – list or None, indicates whether this system has constraints

Returns:

None

TIES_MD.alch.remove_simulation_reporters(sim)

Function to strip OpenMM reporters out of a simulation :param sim: OpenMM simulation object to remove reporter from

Returns:

None

TIES_MD.alch.simulate_system(ids, alch_sys, Lam, mask, cwd, niter, equili_steps, steps_per_iter=1000)

Main function to perform simulations. Will iterate over windows assigned to this worker. Performs pre-production, and then production simulation. Will collect required grads and potentials for TI/FEP. Will then write any results to disk.

Sampling per repeat = (number of windows * niter * steps_per_iter * 2fs) + (number of windows * equili_steps * 2fs)

Parameters:
  • ids – System_ID class containing ids for GPU, repeat and node

  • alch_sys – AlchSys class containing the alchemical system

  • Lam – Lambda class containing lambda schedule

  • mask – list containing ints for start and end range of windows to be run

  • name – string, name of the current experiment we are running

  • niter – int, number of iterations per window #How many times we sample grad

  • equili_steps – int, number of 2fs steps for equilibration

  • steps_per_iter – int, number of 2fs steps per iteration #How much sampling between sampling grad

Returns:

None

TIES_MD.cli module

TIES_MD.cli.main(argv=None)

Entry point for the TIES program.

Parameters:

argv – dict, containing command line arguments

TIES_MD.lambdas module

class TIES_MD.lambdas.Lambdas(elec_edges, ster_edges, global_lambs, custom=None, debug=True)

Bases: object

Class containing lambda schedule

Parameters:
  • elec_edges – list, values for what fraction of the lambda schedule the electric potential should start and stop appearing

  • ster_edges – list, values for what fraction of the lambda schedule the steric potential should start and stop appearing

  • global_lambs – list of floats for global lambda schedule

  • custom – dict, containing keys lambda_(sterics/electrostatics)_(appear/disappear) with list of floats for values

  • debug – boolean, whether to print the schedule to terminal

update_attrs_from_schedule()

Function to update the lambda attributes e.g. self.lambda_sterics_appear from self.schedule if it has changed.

Returns:

None

TIES_MD.lambdas.appear_func(start, stop, x)

Function to get the evaluation of a line constructed from two points (start, 0) and (stop, 1)

Parameters:
  • start – float, when line should start appearing

  • stop – float, when line should finish appearing

  • x – float, value for which line should be evaluate at

Returns:

float, y value of evaluated line

TIES_MD.lambdas.disappear_func(start, stop, x)

Function to get the evaluation of a line constructed from two points (start, 1) and (stop, 0)

Parameters:
  • start – float, when line should start disappearing

  • stop – float, when line should finish disappearing

  • x – float, value for which line should be evaluate at

Returns:

float, y value of evaluated line

TIES_MD.lambdas.get_line(start, stop, global_lam, appear)

Function to create a numpy array interpolating between end states to use in lambda schedule

Parameters:
  • start – float, value at which line should begin to change

  • stop – float, value at which line should be finished changing

  • global_lam – list, of values in the global lambdas

  • appear – bool, True for appearing line i.e 0-> 1 False for disappear i.e 1->0

Returns:

np.array([]), values for the line across windows

Module contents