utilities.random_builder submodule
- cg_openmm.utilities.random_builder.assign_position(positions, bond_length, distance_cutoff, parent_index, bead_index)[source]
Assign random position for a bead
- param positions
Positions for the particles in a coarse grained model.
- type positions
np.array( float * unit.angstrom ( num_particles x 3 ) )
- param bond_length
The distance to step when placing new particles.
- type bond_length
- param distance_cutoff
The distance below which particles will be considered to have “collisions”.
- type distance_cutoff
- param parent_bead_index
The index of the particle from which we will bond a new particle, when assigning pos
- itions.
- type parent_bead_index
int
- param bead_index
The index of the particle for which the function will assign positions.
- type bead_index
int
- returns
positions ( np.array( float * unit.angstrom ( num_particles x 3 ) ) ) - A set of positions for the updated model, including the particle that was just added.
success ( Logical ) - Indicates whether or not a particle was placed successfully.
- cg_openmm.utilities.random_builder.assign_position_lattice_style(cgmodel, positions, distance_cutoff, parent_bead_index, bead_index)[source]
Assign random position for a particle
- Parameters
cgmodel (class) – CGModel() class object.
positions (np.array( float * unit.angstrom ( num_particles x 3 ) )) – Positions for the particles in a coarse grained model.
distance_cutoff – The distance below which particles will be considered to have “collisions”.
parent_bead_index (int) – The index of the particle from which we will bond a new particle, when assigning positions.
bead_index (int) – The index of the particle for which the function will assign positions.
- Returns
test_positions ( np.array( float * unit.angstrom ( num_particles x 3 ) ) ) - A set of positions for the updated model, including the particle that was just added.
success ( Logical ) - Indicates whether or not a particle was placed successfully.
- cg_openmm.utilities.random_builder.attempt_lattice_move(parent_coordinates, bond_length, move_direction_list)[source]
Given a set of cartesian coordinates this function positions a new particle a distance of ‘bond_length’ away in a random direction.
- Parameters
parent_coordinates (np.array( float * unit.angstrom ( length = 3 ) )) – Positions for a single particle, away from which we will place a new particle a distance of ‘bond_length’ away.
bond_length – Bond length for all beads that are bonded.
move_direction_list (List( int )) – A list of cartesian directions (denoted by integers) that tracks the directions in which a particle placement has been attempted.
- Returns
trial_coordinates ( np.array( float * unit.angstrom ( length = 3 ) ) ) - The coordinates for a new, trial particle.
move_direction_list ( List(int) ) - A list of cartesian directions (denoted by integers) that tracks the directions in which a particle placement has been attempted.
- cg_openmm.utilities.random_builder.attempt_move(parent_coordinates, bond_length)[source]
Given a set of cartesian coordinates, assign a new particle a distance of ‘bond_length’ away in a random direction.
- param parent_coordinates
Positions for a single particle, away from which we will place a new particle a distance of ‘bond_length’ away.
- type parent_coordinates
np.array( float * unit.angstrom ( length = 3 ) )
- param bond_length
Bond length for all beads that are bonded.
- type bond_length
- returns
trial_coordinates ( np.array( float * unit.angstrom ( length = 3 ) ) ) - The coordinates for a new, trial
particle.
- cg_openmm.utilities.random_builder.collisions(distance_list, distance_cutoff)[source]
Determine if there are any collisions between non-bonded particles, where a “collision” is defined as a distance shorter than ‘distance_cutoff’.
- Parameters
distance_list – A list of distances.
distance_cutoff – The distance below which particles will be considered to have “collisions”.
- Returns
collision (Logical) - A variable indicating whether or not the model contains particle collisions.
- cg_openmm.utilities.random_builder.distance(positions_1, positions_2)[source]
Calculate the distance between two particles.
- Parameters
positions_1 – Positions for a particle
positions_2 – Positions for a particle
- Returns
distance ( Quantity() ) - The distance between the provided particles.
- cg_openmm.utilities.random_builder.distance_matrix(positions)[source]
Construct a matrix of the distances between an input array of particles.
- Parameters
positions (np.array( float * unit.angstrom ( num_particles x 3 ) )) – Positions for an array of particles.
- Returns
distance_matrix (np.array(num_particles x num_particles)) - Matrix containing the distances between all beads.
- cg_openmm.utilities.random_builder.distances(interaction_list, positions)[source]
Calculate the distances between all non-bonded particles in a model, given a list of particle interactions and particle positions.
- Parameters
interaction_list (List( [ int, int ] )) – A list of non-bonded particle interactions
positions (np.array( float * unit.angstrom ( num_particles x 3 ) )) – Positions for the particles in a coarse grained model.
- Returns
distance_list ( List( Quantity() ) ) - A list of distances for the non-bonded interactions in the coarse grained model.
- cg_openmm.utilities.random_builder.first_bead(positions)[source]
Determine if the provided ‘positions’ contain any particles (are the coordinates non-zero).
- Parameters
positions (np.array( float * unit ( shape = num_beads x 3 ) )) – Positions for all beads in the coarse-grained model.
- Returns
first_bead (Logical) - Variable stating if the positions are all non-zero.
- cg_openmm.utilities.random_builder.get_move(trial_coordinates, move_direction, distance, bond_length, finish_bond=False)[source]
Used to build random structures. Given a set of input coordinates, this function attempts to add a new particle.
- Parameters
trial_coordinates (np.array( float * unit.angstrom ( length = 3 ) )) – Positions for a particle
move_direction (int) – Cartesian direction in which we will attempt a particle placement, where: x=0, y=1, z=2.
distance – Current distance between the trial coordinates for the particle this function is positioning and the particle that it is branched from (bonded to).
bond_length – The distance to step before placing a new particle.
finish_bond – Logical variable determining how we will update the coordinates for this particle, default = False. If set to “True”, the “move” length will be the difference between “distance” and “bond_length”.
- Returns
trial_coordinates (np.array( float * unit.angstrom (length=3) )) - Updated positions for the particle.
- cg_openmm.utilities.random_builder.get_random_positions(cgmodel, max_attempts=1000, use_library=False, high_energy=False, low_energy=False, generate_library=False)[source]
Assign random positions for all beads in a coarse-grained polymer.
cgmodel: CGModel() class object.
- Parameters
max_attempts (int) – The maximum number of attempts to generate random positions a coarse grained model with the current parameters, default = 1000
use_library – A logical variable determining if a new random structure will be generated, or if an ensemble will be read from the ‘foldamers’ database, default = False
use_library – Logical
high_energy (Logical) – If set to ‘True’, this function will generate an ensemble of high-energy structures, default = False
low_energy (Logical) – If set to ‘True’, this function will generate an ensemble of low-energy structures, default = False
generate_library – If set to ‘True’, this function will save the poses that are generated to the ‘foldamers’ ensemble database.
- Returns
positions ( np.array( float * unit.angstrom ( num_particles x 3 ) ) ) - A set of coarse grained model positions.
- cg_openmm.utilities.random_builder.get_structure_from_library(cgmodel, high_energy=False, low_energy=False)[source]
Given a coarse grained model class object, this function retrieves a set of positions for the model from the ‘foldamers’ ensemble library, in: ‘foldamers/ensembles/${backbone_length}_${sidechain_length}_${sidechain_positions}’ If this coarse grained model does not have an ensemble library, an error message will be returned and positions at random with ‘random_positions()’.
cgmodel: CGModel() class object.
- Parameters
high_energy (Logical) – If set to ‘True’, this function will generate an ensemble of high-energy structures, default = False
low_energy (Logical) – If set to ‘True’, this function will generate an ensemble of low-energy structures, default = False
- Returns
positions ( np.array( float * unit.angstrom ( num_particles x 3 ) ) ) - A set of coarse grained model positions.