def _unaligned_image(self, state): """ Parameters ---------- state : Returns ------- """ # get the box lengths from the vectors box_lengths, box_angles = box_vectors_to_lengths_angles( state['box_vectors']) # recenter the protein-ligand complex into the center of the # periodic boundary conditions # regroup the ligand and protein in together grouped_positions = group_pair(state['positions'], box_lengths, self._bs_idxs, self._lig_idxs) # then center them around the binding site centered_positions = center_around(grouped_positions, self._bs_idxs) # slice these positions to get the image state_image = centered_positions[self._image_idxs] return state_image
def _progress(self, walker): """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. """ # first recenter the ligand and the receptor in the walker box_lengths, box_angles = box_vectors_to_lengths_angles( walker.state['box_vectors']) grouped_walker_pos = group_pair(walker.state['positions'], box_lengths, self.binding_site_idxs, self.ligand_idxs) # center the positions around the center of the binding site centered_walker_pos = center_around(grouped_walker_pos, self.binding_site_idxs) # superimpose the walker state positions over the native state # matching the binding site indices only sup_walker_pos, _, _ = superimpose(self.native_state['positions'], centered_walker_pos, idxs=self.binding_site_idxs) # calculate the rmsd of the walker ligand (superimposed # according to the binding sites) to the native state ligand native_rmsd = calc_rmsd(self.native_state['positions'], sup_walker_pos, idxs=self.ligand_idxs) # test to see if the ligand is re-bound rebound = False if native_rmsd <= self.cutoff_rmsd: rebound = True progress_data = {'native_rmsd': native_rmsd} return rebound, progress_data
def _unaligned_image(self, state): """The preprocessing method of states. First it groups the binding site and ligand into the same periodic box image and then centers the box around their mutual center of mass and returns only the positions of the binding site and ligand. Parameters ---------- state : object implementing WalkerState State with 'positions' (Nx3 dims) and 'box_vectors' (3x3 array) attributes. Returns ------- """ # get the box lengths from the vectors box_lengths, box_angles = box_vectors_to_lengths_angles( state['box_vectors']) # recenter the protein-ligand complex into the center of the # periodic boundary conditions # regroup the ligand and protein in together grouped_positions = group_pair(state['positions'], box_lengths, self._bs_idxs, self._lig_idxs) # then center them around the binding site centered_positions = center_around(grouped_positions, self._bs_idxs) # slice these positions to get the image state_image = centered_positions[self._image_idxs] return state_image
def __init__(self, native_state=None, cutoff_rmsd=0.2, initial_states=None, initial_weights=None, ligand_idxs=None, binding_site_idxs=None, **kwargs): """Constructor for RebindingBC. Arguments --------- native_state : object implementing the State interface The reference bound state. Will be automatically centered. cutoff_rmsd : float The cutoff RMSD for considering a walker bound. 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: native_state, initial_states, ligand_idxs, receptor_idxs. """ super().__init__(initial_states=initial_states, initial_weights=initial_weights, ligand_idxs=ligand_idxs, receptor_idxs=binding_site_idxs **kwargs) # test inputs assert native_state is not None, "Must give a native state" assert type(cutoff_rmsd) is float native_state_d = native_state.dict() # save the native state and center it around it's binding site native_state_d['positions'] = center_around(native_state['positions'], binding_site_idxs) native_state = WalkerState(**native_state_d) # save attributes self._native_state = native_state self._cutoff_rmsd = cutoff_rmsd