openmmslicer.moves module¶
Here one can define a range of moves which can be used for enhanced sampling:
TranslationMove
, RotationMove
and
DihedralMove
, and combine them into a MoveList
.
- class openmmslicer.moves.DihedralMove(structure, rotatable_bond, residue=None, sampling='systematic')¶
Bases:
openmmslicer.moves.Move
A class which performs rotation around centre of mass.
- Parameters
structure (parmed.Structure) – An object containing all of the information about the system.
rotatable_bond ((int, int)) – A tuple of the indices of the two atoms defining the rotatable bond. If residue is None, absolute indices are required. Otherwise, relative indices must be used. Only the substituents of the second atom are moved.
residue (str or int or None) – If string, this is the first residue which has this residue name. If number, this is the index of the desired residue (starting from 0). If None, absolute atom indices must be passed to rotatable_bond.
sampling (str) – One of “multinomial” or “systematic” - to be passed to Move.sampler().
- sampling¶
One of “multinomial” or “systematic” - to be passed to Move.sampler().
- Type
str
- rotatable_bond¶
A tuple of the absolute indices of the two atoms defining the rotatable bond. Only the substituents of the second atom are moved.
- Type
(int, int)
- movable_atoms¶
A list of the absolute indices of all movable atoms.
- Type
[int]
- alchemical_atoms¶
A list of the absolute indices of all alchemical atoms.
- Type
[int]
- applyMove(input, rotation)¶
Applies a single dihedral rotation to a state, context or quantity. If a context is passed, it it also modified in place.
- Parameters
input (openmm.Context or openmm.State or openmm.unit.Quantity) – Input containing coordinate information.
rotation (numpy.ndarray) – A numpy vector whose direction specifies the axis of rotation and whose norm specifies the angle of anticlockwise rotaion.
- Returns
input – The transformed coordinates.
- Return type
openmm.unit.Quantity
- generateMoves(n_states)¶
Generates a list of translations.
- Parameters
n_states (int) – Number of samples to be generated.
- Returns
rotations – A numpy array containing n_states rows and 3 columns, which specifies the rotations around the rotatable bond.
- Return type
numpy.ndarray
- class openmmslicer.moves.Move¶
Bases:
object
- applyMove(*args, **kwargs)¶
Applies a move generated from generateMoves(). This is a virtual function which must be overloaded in the child classes.
- generateMoves(*args, **kwargs)¶
Generates an array of moves which can be read by applyMove(). This is a virtual function which must be overloaded in the child classes.
- static sampler(n_samples, sampling='systematic')¶
Samples from the uniform distribution between 0 and 1 using different sampling methods.
- Parameters
n_samples (int) – Number of uniform samples to be generated.
sampling (str) – One of “multinomial” - independent sampling of each sample and “systematic” - sampling on an evenly spaced grid with a randomly generated offset.
- Returns
samples – An array of all generated samples.
- Return type
numpy.ndarray
- class openmmslicer.moves.MoveList(moves)¶
Bases:
openmmslicer.moves.Move
A class which combines multiple moves.
- Parameters
moves ([Move]) – The instantiated moves to be combined.
- property alchemical_atoms¶
Returns the combined alchemical atoms of all moves.
- Type
[int]
- applyMove(input, transformations)¶
Applies a single transformation to a state, context or quantity. If a context is passed, it it also modified in place.
- Parameters
input (openmm.Context or openmm.State or openmm.unit.Quantity) – Input containing coordinate information.
transformations (list) – A list of all transformations to be passed to self.moves. Each transformation must be of an appropriate format for the underlying move.
- Returns
input – The transformed coordinates.
- Return type
openmm.unit.Quantity
- generateMoves(n_states)¶
Generates a list of transformations for each move.
- Parameters
n_states (int) – Number of samples to be generated.
- Returns
transformations – A list of all transformations.
- Return type
list
- class openmmslicer.moves.RotationMove(structure, rotatable_molecule, sampling='systematic')¶
Bases:
openmmslicer.moves.Move
A class which performs rotation around centre of mass.
- Parameters
structure (parmed.Structure) – An object containing all of the information about the system.
rotatable_molecule (str or int) – If string, this is the first residue which has this residue name. If number, this is the index of the desired residue (starting from 0).
sampling (str) – One of “multinomial” or “systematic” - to be passed to Move.sampler().
- sampling¶
One of “multinomial” or “systematic” - to be passed to Move.sampler().
- Type
str
- movable_atoms¶
A list of the absolute indices of all movable atoms.
- Type
[int]
- alchemical_atoms¶
A list of the absolute indices of all alchemical atoms.
- Type
[int]
- masses¶
An array of masses of the residue to be translated.
- Type
numpy.ndarray
- applyMove(input, rotation)¶
Applies a single rotation to a state, context or quantity. If a context is passed, it it also modified in place.
- Parameters
input (openmm.Context or openmm.State or openmm.unit.Quantity) – Input containing coordinate information.
rotation (numpy.ndarray) – A numpy vector whose direction specifies the axis of rotation and whose norm specifies the angle of anticlockwise rotaion.
- Returns
input – The transformed coordinates.
- Return type
openmm.unit.Quantity
- generateMoves(n_states)¶
Generates a list of translations.
- Parameters
n_states (int) – Number of samples to be generated.
- Returns
rotations – A numpy array containing n_states rows and 3 columns, which specifies the rotations around the centre of mass.
- Return type
numpy.ndarray
- class openmmslicer.moves.TranslationMove(structure, translatable_molecule, sampling='systematic', origins=None, radii=None, region='spherical')¶
Bases:
openmmslicer.moves.Move
A class which performs translation around one or more centres.
- Parameters
structure (parmed.Structure) – An object containing all of the information about the system.
translatable_molecule (str or int) – If string, this is the first residue which has this residue name. If number, this is the index of the desired residue (starting from 0).
sampling (str) – One of “multinomial” or “systematic” - to be passed to Move.sampler().
origins ([openmm.Quantity] or None) – Initialises origins. None stands for translation around current centre of mass.
radii ([openmm.Quantity]) – Initialises radii. Must be of the same length as origins.
region (str) – Initialises region. One of “spherical” or “cubic”. If cubic, the radii stand for half of the translation box length.
- sampling¶
One of “multinomial” or “systematic” - to be passed to Move.sampler().
- Type
str
- movable_atoms¶
A list of the absolute indices of all movable atoms.
- Type
[int]
- alchemical_atoms¶
A list of the absolute indices of all alchemical atoms.
- Type
[int]
- masses¶
An array of masses of the residue to be translated.
- Type
numpy.ndarray
- origins¶
A list of one or more origins around which the samples should be centred.
- Type
[openmm.Quantity]
- radii¶
A list of radii which determine the radius of sampling around each of the origins.
- Type
[openmm.Quantity]
- region¶
Determines the shape of the sampling area. One of “spherical” or “cubic”.
- Type
str
- applyMove(input, translation)¶
Applies a single translation to a state, context or quantity. If a context is passed, it it also modified in place.
- Parameters
input (openmm.Context or openmm.State or openmm.unit.Quantity) – Input containing coordinate information.
translation (openmm.unit.Quantity) – Coordinates of the new centre of mass.
- Returns
input – The transformed coordinates.
- Return type
openmm.unit.Quantity
- generateMoves(n_states)¶
Generates a list of translations.
- Parameters
n_states (int) – Number of samples to be generated.
- Returns
translations – A numpy array with units containing n_states rows and 3 columns, which specifies the new dimensionless centres of mass.
- Return type
numpy.ndarray
- property radii¶