Ejemplo n.º 1
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
Ejemplo n.º 2
0
    def _unaligned_image(self, state):

        # 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
        rece_positions = recenter_pair(state['positions'], box_lengths,
                                       self._bs_idxs, self._lig_idxs)

        # slice these positions to get the image
        state_image = rece_positions[self._image_idxs]

        return state_image
Ejemplo n.º 3
0
    def distance(self, walkers):
        n_walkers = len(walkers)

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

        # recenter protein and ligand
        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)

        # profile ligand-protein interactions for each walker (in parallel)
        profiles = [[] for i in range(n_walkers)]
        for i in range(n_walkers):
            # pass coordinates in angstroms
            coords = [
                10 * newpos_small[i][small_lig_idxs],
                10 * newpos_small[i][small_prot_idxs]
            ]
            system = self.sys_type.to_system(coords)
            profiles[i] = self.profiler.profile(system)

        # vectorize profiles (in serial)
        inte_vec, names = self.vectorize_profiles(profiles, n_walkers)

        # calculate distance matrix in interaction space
        dist_mat = np.zeros((n_walkers, n_walkers))
        for i in range(n_walkers):
            for j in range(i + 1, n_walkers):
                dist = np.linalg.norm(inte_vec[i] - inte_vec[j], ord=2)
                dist_mat[i][j] = dist
                dist_mat[j][i] = dist

        return dist
Ejemplo n.º 4
0
        "clipped_{}_{}_{}_tryp_ben.pdb".format(*unit_corner))

# first group the protein and ligand together, this may be outside of
# the PBCs
grouped_coords = group_pair(uncentered_system.xyz[0], box_lengths, prot_idxs,
                            lig_idxs)

# write this out to check it
grouped_system = mdj.Trajectory(
    grouped_coords,
    top,
    unitcell_lengths=uncentered_system.unitcell_lengths,
    unitcell_angles=uncentered_system.unitcell_angles)

# grouped_system.save_pdb("grouped_tryp_ben.pdb")

# finally we can combine these functions into something that recenters
# our box around a pair of groups (molecules for instance)

recentered_coords = recenter_pair(uncentered_system.xyz[0], box_lengths,
                                  prot_idxs, lig_idxs)

# write them out so we can visualize
recentered_system = mdj.Trajectory(
    recentered_coords,
    top,
    unitcell_lengths=uncentered_system.unitcell_lengths,
    unitcell_angles=uncentered_system.unitcell_angles)

recentered_system.save_pdb("recentered_tryp_ben.pdb")