TIES_MD packageο
Subpackagesο
- TIES_MD.eng_scripts package
- TIES_MD.openmmtools package
- Submodules
- TIES_MD.openmmtools.alchemy module
AlchemicalStateError
ModifiedAbsoluteAlchemicalFactory
ModifiedAlchemicalState
ModifiedAlchemicalState.apply_to_context()
ModifiedAlchemicalState.apply_to_system()
ModifiedAlchemicalState.check_system_consistency()
ModifiedAlchemicalState.from_system()
ModifiedAlchemicalState.get_alchemical_variable()
ModifiedAlchemicalState.get_function_variable()
ModifiedAlchemicalState.lambda_angles
ModifiedAlchemicalState.lambda_bonds
ModifiedAlchemicalState.lambda_electrostatics
ModifiedAlchemicalState.lambda_sterics
ModifiedAlchemicalState.lambda_torsions
ModifiedAlchemicalState.set_alchemical_parameters()
ModifiedAlchemicalState.set_alchemical_variable()
ModifiedAlchemicalState.set_function_variable()
- Module contents
- TIES_MD.ties_analysis package
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