transformato.restraints
Description
Manages restraints and the forces created from them.
Basic function:
From the ‘restraints’ section in the config.yaml, the intermediate state factory creates an appropriate restraints.yaml in the intermediate state directories.
When the simulation is run, openMM_run.py checks for the existence of these restraints.yaml. If it finds one, a number of Restraint() instances commensurate to the number of desired restraints is created. These each create an appropriate openMM force as defined by their parameters. That force ist then applied to the openMM simulation.
Usage:
Unless you directly want to modify functionality, you should not need to call here directly. Define your restraints in the config.yaml.
Hint
For further usage instructions, see the ‘System Setup’ section of the main documentation.
Classes
- class transformato.restraints.Restraint(selligand, selprotein, topology, k=3, shape='harmonic', wellsize=0.05, **kwargs)[source]
- Parameters:
selligand (str)
selprotein (str)
topology (Universe)
k (float)
shape (str)
wellsize (float)
- __init__(selligand, selprotein, topology, k=3, shape='harmonic', wellsize=0.05, **kwargs)[source]
Class representing a restraint to apply to the system.
Intermediary step - openMM force objects are generated directly from this class and applied to the system.
- Raises:
AttributeError – If the potential shape requested is not implemented.
- Parameters:
selligand (MDAnalysis selection string) – MDAnalysis selection strings
selprotein (MDAnalysis selection string) – MDAnalysis selection strings
k (float) – the force (=spring) constant applied to the potential energy formula. See the ‘System Setup’ section for details.
topology (Universe) – the MDAnalysis universe used to generate restraint geometries
shape (str) – one of ‘harmonic’, ‘flatbottom’, ‘flatbottom-oneside-sharp’ or ‘flatbottom-twoside’. Defines the shape of the harmonic energy potential.
wellsize (float) – Defines the well-size in a two-sided flat-bottom potential. Defaults to 0.05 nanometers.
kwargs – Catcher for additional restraint_args
- __weakref__
list of weak references to the object
- _add_flatbottom_parameters()[source]
Takes care of the initial setup of an openMM CustomCentroidBondForce with a flatbottom shape
- Parameters:
force – An openMM CustomCentroidBondForce object
- applyForce(system)[source]
Applies the force to the openMM system
- Parameters:
system (openMM.system) – The openMM system to which to apply the Force
- createForce(common_core_names)[source]
Actually creates the force, after dismissing all idxs not in the common core from the molecule.
- Parameters:
common_core_names (array[str]) –
Array with strings of the common core names. Usually provided by the restraint.yaml file.
- Returns:
An openMM force object representing the restraint bond.
- Return type:
openMM.CustomCentroidBondForce
Functions
- restraints.create_restraints_from_config(pdbpath)
Takes the restraints.yaml config and returns the specified restraints.
This is the function that should be invoked by openmm_run.py.
- Parameters:
config (dict) – the loaded yaml config (as returned by yaml.safe_load() or similar
- Returns:
An array of Restraint instances
- Return type:
array
- restraints.generate_extremities(topology, n_extremities, sphinner=0, sphouter=5)
Takes the common core and generates n extremities at the furthest point
Returns a selection string of the extremities with a sphlayer (see MDAnalysis docs) selecting type C from sphinner to sphouter. The algorithm works as follows:
(All of these operations only operate on carbons in the common core)
Take the furthest C from the center of Mass.
Take the furthest C from that C.
Until len(extremity_cores)==n_extremities:
Pick the C where the sum distance from all previous cores is greatest.
Add it to the extremity_cores.
Generate selection strings for all extremity cores and return.
- Parameters:
configuration (dict) – the read-in restraints.yaml
topology (MDAnalysis.Universe) – MDAnalysis.Universe object used to generate ligand geometries
n_extremities (int) – how many extremities to generate. Cannot exceed number of carbons in the ligand
sphinner (float) – Distance to start of the sphlayer, default 0
sphouter (float) – Distance to end of the sphlayer, default 5
- Raises:
ValueError – If an invalid amount of extremities is specified.
- Returns:
A nested array of MDAnalysis selection strings representing the selected extremities and its vicinity as defined by sphlayer and an array of the found extremity cores
- Return type:
[selection_strings,extremity_cores]
- restraints.generate_simple_selection()
Takes the common core and selects surrounding carbon-alphas
This ensures that the initial simple restraints on both sides is identical
- Parameters:
configuration (dict) – the read-in restraints.yaml
- Returns:
An MDAnalysis selection string, representing the carbon-alphas surrounding the cores.
- Return type:
str
- restraints.get3DDistance(pos2)
Takes two 3d positions as array and calculates the distance between them
- Parameters:
pos1 (3D-Array) – The positions of which to calculate the distances
pos2 (3D-Array) – The positions of which to calculate the distances
- Returns:
The distance between the two positions
- Return type:
float
- restraints.write_restraints_yaml(system, config, current_step)
Takes the full config as read in in utils.py, the information for the intstate and writes the restraints.yaml.
- Parameters:
path – the path to write to (e.g. ./combinedstructure/structure/intst2/restraints.yaml
system – the system object from state.py