Exemplo n.º 1
0
    def image_distance(self, image_a, image_b):
        """

        Parameters
        ----------
        image_a :
            
        image_b :
            

        Returns
        -------

        """

        # we calculate the rmsd of only the ligands between each image
        # and the reference
        state_a_rmsd = calc_rmsd(self.ref_image,
                                 image_a,
                                 idxs=self._image_lig_idxs)
        state_b_rmsd = calc_rmsd(self.ref_image,
                                 image_b,
                                 idxs=self._image_lig_idxs)

        # then we get the absolute value of the reciprocals of these rmsd
        # values
        d = abs(1. / state_a_rmsd - 1. / state_b_rmsd)

        return d
Exemplo n.º 2
0
    def get_rmsd_native(self, walkers):
        num_walkers = len(walkers)

        small_lig_idxs = np.array(range(len(self.ligand_idxs)))
        small_bs_idxs = np.array(
            range(len(self.ligand_idxs),
                  len(self.ligand_idxs) + len(self.binding_site_idxs)))
        keep_atoms = np.concatenate((self.ligand_idxs, self.binding_site_idxs),
                                    axis=0)

        small_pos = self._xyz_from_walkers(walkers, keep_atoms)
        box_lengths = self._box_from_walkers(walkers)

        newpos_small = np.zeros_like(small_pos)

        for frame_idx, positions in enumerate(small_pos):
            newpos_small[frame_idx, :, :] = recenter_pair(
                positions, box_lengths[frame_idx], small_lig_idxs,
                small_bs_idxs)

        small_top = self.topology.subset(keep_atoms)
        traj_rec = mdj.Trajectory(newpos_small, small_top)

        traj_rec.superpose(self.comp_traj, atom_indices=small_bs_idxs)
        rmsd_native = np.zeros((num_walkers))
        for i in range(num_walkers):
            rmsd_native[i] = calc_rmsd(traj_rec.xyz[i], self.comp_traj.xyz[0],
                                       small_lig_idxs)

        if self.alt_maps is not None:
            # figure out the "small" alternative maps
            small_alt_maps = deepcopy(self.alt_maps)
            for i, a in enumerate(self.alt_maps):
                for j, e in enumerate(a):
                    try:
                        small_alt_maps[i][j] = list(self.binding_site_idxs).index(e) +\
                                               len(self.ligand_idxs)
                    except:
                        raise Exception(
                            'Alternative maps are assumed to be permutations of'
                            ' existing binding site indices')

            for alt_map in small_alt_maps:
                alt_traj_rec = mdj.Trajectory(newpos_small, small_top)
                alt_traj_rec.superpose(self.comp_traj,
                                       atom_indices=small_bs_idxs,
                                       ref_atom_indices=alt_map)
                for i in range(num_walkers):
                    dist = calc_rmsd(alt_traj_rec.xyz[i],
                                     self.comp_traj.xyz[0], small_lig_idxs)
                    if dist < rmsd_native[i]:
                        rmsd_native[i] = dist
        return rmsd_native
Exemplo n.º 3
0
    def image_distance(self, image_a, image_b):

        # we calculate the rmsd of only the ligands between the
        # images
        lig_rmsd = calc_rmsd(image_a, image_b, idxs=self._image_lig_idxs)

        return lig_rmsd
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    def image_distance(self, image_a, image_b):
        """

        Parameters
        ----------
        image_a :
            
        image_b :
            

        Returns
        -------

        """

        # we calculate the rmsd of only the ligands between the
        # images
        lig_rmsd = calc_rmsd(image_a, image_b, idxs=self._image_lig_idxs)

        return lig_rmsd
Exemplo n.º 6
0
    [-18.577, -10.001, 17.996]
])


N = frag_a.shape[0]
# Calculate center of geometry
comA = np.sum(frag_a, axis=0)/N
comB = np.sum(frag_b, axis=0)/N

# Center each fragment
frag_a = frag_a - comA
frag_b = frag_b - comB

# align to a subselection of the frames
idxs = np.array([0,1,2,3])
rmsd, rot_mat = theobald_qcp(frag_a, frag_b, idxs=idxs)

print("theobald alignment RMSD: {}".format(rmsd))

# apply the rotation matrix and calculate the rmsd of only the
# alignemnt coordinates to check
frag_b_rot = np.dot(frag_b, rot_mat)
rot_rmsd = calc_rmsd(frag_b_rot, frag_a, idxs=idxs)
print("Rotation alignment RMSD: {}".format(rot_rmsd))

# calculate the RMSD of the whole set of coordinates for the given
# alignment
frag_b_rot = np.dot(frag_b, rot_mat)
rot_rmsd = calc_rmsd(frag_b_rot, frag_a)
print("Total rotation alignment RMSD: {}".format(rot_rmsd))