TIES_MD package¶

Submodules¶

TIES_MD.TIES module¶

class TIES_MD.TIES.TIES(cwd, exp_name, run_type='class', devices=None, node_id=None, windows_mask=None, periodic=True, 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

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

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

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

  • node_id – str, 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

  • **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 :return: None

get_options()¶
run()¶

Function to run the simulations in parallel

setup()¶

Function to setup simulations and then stop

write_analysis_cfg()¶

Function to write the input configuration files for analysis.

write_namd_eq()¶

Function to write eq1 and eq2 namd scripts used for equilibration

write_namd_min()¶

Function to write eq0.conf scripts used in minimization stage

write_namd_prod()¶

Function to write sim1 namd conf script for production simulation

write_namd_scripts()¶

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

write_namd_submissions()¶

Function to write an example submission script of NAMD job on HPC (SuperMUC-NG)

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.nice_print(string)¶

Function to print str with padding.

Parameters

string – A string which should be printed.

TIES_MD.TIES.sort_results(string)¶

Helper function to sort directory paths by specific index in file name.

Parameters

string – Path to a results file.

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)¶

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

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.

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

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, force_to_compute=None)¶

Function can be used in debugging to turn forces on and off.

Parameters
  • system – OpenMM system object

  • force_to_compute – list of forces to not turn off in the system

Returns

list of indexs for system forces

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

  • 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 turn of torsions

Parameters
  • system – OpenMM system

  • intersect_torsions – List of ints, ints references torsions that have alchemical indexes in them

Returns

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

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.

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.

class TIES_MD.alch.PDB_line(line)¶

Bases: object

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

Parameters

str – line from a pdb file

class TIES_MD.alch.System_ID(device_id, node_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

  • node_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

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

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

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

TIES_MD.alch.remove_simulation_reporters(sim)¶
Parameters

sim – OpenMM simulation object to remove reporter from

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

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.cli.read_config(config_file)¶

Function to read config file from disk

Parameters

config_file – str pointing to TIES.cfg file

Returns

dict, containing all config file args

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.

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¶