wepy.boundary_conditions.randomwalk module¶
Boundary conditions for random walk.
- class wepy.boundary_conditions.randomwalk.RandomWalkBC(threshold=None, initial_states=None, initial_weights=None, **kwargs)[source]¶
Bases:
WarpBC
Boundary condition for a random walk simulation with warping controlled by the sum of walker positions crossing a threshold.
Implements the WarpBC superclass.
This boundary condition will warp walkers to a number of initial states whenever a walker crosses the threshold distance from the origin.
Constructor for RandomWalkBC.
- Parameters:
threshold (int) – The threshold distance for recording a warping event.
initial_states (list of objects implementing the State interface) – The list of possible states that warped walkers will assume.
initial_weights (list of float, optional) – List of normalized probabilities of the initial_states provided. If not given, uniform probabilities will be used.
ligand_idxs (arraylike of int) – The indices of the atom positions in the state considered the ligand.
binding_site_idxs (arraylike of int) – The indices of the atom positions in the state considered the binding site.
- Raises:
AssertionError – If any of the following kwargs are not given: threshold, initial_states.
- BC_FIELDS = ('threshold_distance',)¶
String names of fields produced in this record group.
Boundary condition (BC) records are typically used to report on changes to the state of the BC object.
Notes
These fields are not critical to the proper functioning of the rest of the wepy framework and can be modified freely.
However, reporters specific to this boundary condition probably will make use of these records.
- BC_SHAPES = ((1,),)¶
Numpy-style shapes of all fields produced in records.
There should be the same number of elements as there are in the corresponding ‘FIELDS’ class constant.
Each entry should either be:
A tuple of ints that specify the shape of the field element array.
Ellipsis, indicating that the field is variable length and limited to being a rank one array (e.g. (3,) or (1,)).
None, indicating that the first instance of this field will not be known until runtime. Any field that is returned by a record producing method will automatically interpreted as None if not specified here.
Note that the shapes must be tuple and not simple integers for rank-1 arrays.
Option B will result in the special h5py datatype ‘vlen’ and should not be used for large datasets for efficiency reasons.
- BC_DTYPES = (<class 'int'>,)¶
Specifies the numpy dtypes to be used for records.
There should be the same number of elements as there are in the corresponding ‘FIELDS’ class constant.
Each entry should either be:
A numpy.dtype object.
None, indicating that the first instance of this field will not be known until runtime. Any field that is returned by a record producing method will automatically interpreted as None if not specified here.
- WARPING_FIELDS = ('walker_idx', 'target_idx', 'weight')¶
String names of fields produced in this record group.
Warping records are typically used to report whenever a walker satisfied the boundary conditions and was warped and had its state changed.
Warning
Be careful when modifying these fields as they may be integrated with other wepy framework features. Namely recognition of discontinuous warping events for making contiguous trajectories from cloning and merging lineages.
The behavior of whether or not a warping event is discontinuous is given by a BoundaryCondition class’s warping_discontinuity which likely depends on the existence of particular fields.
- WARPING_SHAPES = ((1,), (1,), (1,))¶
Numpy-style shapes of all fields produced in records.
There should be the same number of elements as there are in the corresponding ‘FIELDS’ class constant.
Each entry should either be:
A tuple of ints that specify the shape of the field element array.
Ellipsis, indicating that the field is variable length and limited to being a rank one array (e.g. (3,) or (1,)).
None, indicating that the first instance of this field will not be known until runtime. Any field that is returned by a record producing method will automatically interpreted as None if not specified here.
Note that the shapes must be tuple and not simple integers for rank-1 arrays.
Option B will result in the special h5py datatype ‘vlen’ and should not be used for large datasets for efficiency reasons.
- WARPING_DTYPES = (<class 'int'>, <class 'int'>, <class 'float'>)¶
Specifies the numpy dtypes to be used for records.
There should be the same number of elements as there are in the corresponding ‘FIELDS’ class constant.
Each entry should either be:
A numpy.dtype object.
None, indicating that the first instance of this field will not be known until runtime. Any field that is returned by a record producing method will automatically interpreted as None if not specified here.
- WARPING_RECORD_FIELDS = ('walker_idx', 'target_idx', 'weight')¶
Optional, names of fields to be selected for truncated representation of the record group.
These entries should be strings that are previously contained in the ‘FIELDS’ class constant.
While strictly no constraints on to which fields can be added here you should only choose those fields whose features could fit into a plaintext csv or similar format.
- PROGRESS_FIELDS = ('distance',)¶
String names of fields produced in this record group.
Progress records are typically used to report on measures of walkers at each cycle.
Notes
These fields are not critical to the proper functioning of the rest of the wepy framework and can be modified freely.
However, reporters specific to this boundary condition probably will make use of these records.
- PROGRESS_SHAPES = (Ellipsis,)¶
Numpy-style shapes of all fields produced in records.
There should be the same number of elements as there are in the corresponding ‘FIELDS’ class constant.
Each entry should either be:
A tuple of ints that specify the shape of the field element array.
Ellipsis, indicating that the field is variable length and limited to being a rank one array (e.g. (3,) or (1,)).
None, indicating that the first instance of this field will not be known until runtime. Any field that is returned by a record producing method will automatically interpreted as None if not specified here.
Note that the shapes must be tuple and not simple integers for rank-1 arrays.
Option B will result in the special h5py datatype ‘vlen’ and should not be used for large datasets for efficiency reasons.
- PROGRESS_DTYPES = (<class 'int'>,)¶
Specifies the numpy dtypes to be used for records.
There should be the same number of elements as there are in the corresponding ‘FIELDS’ class constant.
Each entry should either be:
A numpy.dtype object.
None, indicating that the first instance of this field will not be known until runtime. Any field that is returned by a record producing method will automatically interpreted as None if not specified here.
- PROGRESS_RECORD_FIELDS = ('distance',)¶
Optional, names of fields to be selected for truncated representation of the record group.
These entries should be strings that are previously contained in the ‘FIELDS’ class constant.
While strictly no constraints on to which fields can be added here you should only choose those fields whose features could fit into a plaintext csv or similar format.
- property threshold¶
The cutoff RMSD for considering a walker bound.
- _progress(walker)[source]¶
Calculate if the walker has bound and provide progress record.
- Parameters:
walker (object implementing the Walker interface)
- Returns:
is_bound (bool) – Whether the walker is unbound (warped) or not
progress_data (dict of str : value) – Dictionary of the progress record group fields for this walker alone.
- BC_RECORD_FIELDS = ()¶
Optional, names of fields to be selected for truncated representation of the record group.
These entries should be strings that are previously contained in the ‘FIELDS’ class constant.
While strictly no constraints on to which fields can be added here you should only choose those fields whose features could fit into a plaintext csv or similar format.
- DISCONTINUITY_TARGET_IDXS = Ellipsis¶
Specifies which ‘target_idxs’ values are considered discontinuous targets.
Values are either integer indices, Ellipsis (indicating all possible values are discontinuous), or None indicating no possible value is discontinuous.
- _update_bc(new_walkers, warp_data, progress_data, cycle)¶
Perform an update to the boundary conditions.
No updates to the bc are ever done in this null implementation.
- _warp(walker)¶
Perform the warping of a walker.
Chooses an initial state to replace the walker’s state with according to it’s given weight.
Returns a walker of the same type and weight.
- Parameters:
walker (object implementing the Walker interface)
- Returns:
warped_walker (object implementing the Walker interface) – The walker with the state after the warping. Weight should be the same.
warping_data (dict of str : value) – The dictionary-style ‘WARPING’ record for this event. Excluding the walker index which is done in the main warp_walkers method.
- bc_field_dtypes()¶
Access the class level DTYPES constant for this record group.
- bc_field_names()¶
Access the class level FIELDS constant for this record group.
- bc_field_shapes()¶
Access the class level SHAPES constant for this record group.
- bc_fields()¶
Returns a list of zipped field specs.
- bc_record_field_names()¶
Access the class level RECORD_FIELDS constant for this record group.
- property initial_states¶
The possible initial states warped walkers may assume.
- property initial_weights¶
The probabilities of each initial state being chosen during a warping.
- progress_field_dtypes()¶
Access the class level DTYPES constant for this record group.
- progress_field_names()¶
Access the class level FIELDS constant for this record group.
- progress_field_shapes()¶
Access the class level SHAPES constant for this record group.
- progress_fields()¶
Returns a list of zipped field specs.
- progress_record_field_names()¶
Access the class level RECORD_FIELDS constant for this record group.
- warp_walkers(walkers, cycle)¶
Test the progress of all the walkers, warp if required, and update the boundary conditions.
- Parameters:
- Returns:
new_walkers (list of objects implementing the Walker interface) – The new set of walkers that may have been warped.
warp_data (list of dict of str : value) – The dictionary-style records for WARPING update events
- bc_datalist of dict of strvalue
The dictionary-style records for BC update events
- progress_datadict of strarraylike
The dictionary-style records for PROGRESS update events
- classmethod warping_discontinuity(warping_record)¶
Tests whether a warping record generated by this class is discontinuous or not.
- warping_field_dtypes()¶
Access the class level DTYPES constant for this record group.
- warping_field_names()¶
Access the class level FIELDS constant for this record group.
- warping_field_shapes()¶
Access the class level SHAPES constant for this record group.
- warping_fields()¶
Returns a list of zipped field specs.
- warping_record_field_names()¶
Access the class level RECORD_FIELDS constant for this record group.