Ejemplo n.º 1
0
def superimpose_proteins(structure_dict):
    names = tuple(key for key in structure_dict.keys())

    ref_name = names[0]

    # Move reference structure to the origin
    centered_centroid = centroid.centroid(
        structure_dict[ref_name].get_carbons())
    centered_ref_coords = [
        atomic_coords - centered_centroid
        for atomic_coords in structure_dict[ref_name].get_carbons()
    ]
    structure_dict[ref_name].set_carbons(centered_ref_coords)

    for i in range(1, len(names)):
        moving_carbons = structure_dict[names[i]].get_carbons()

        # Superimpose the structure onto the reference structure and keep only the updated coordinates
        # (do not need rotation matrix or RMSD)
        centered_structure = superimpose.superimpose(
            np.asarray(centered_ref_coords), np.asarray(moving_carbons))[0]
        structure_dict[names[i]].set_carbons(centered_structure.tolist())

    # TODO update coordinates of all atoms after superimposing (not just carbon alpha and carbon beta atoms)
    '''
Ejemplo n.º 2
0
    def image(self, state):
        """Transform a state to a receptor image.

        A receptor image is one in which the binding site and ligand
        are first normalized to be within the same periodic box image
        and at the center of the box, and then only the binding site
        and ligand are retained.

        Parameters
        ----------
        state : object implementing WalkerState
            State with 'positions' (Nx3 dims) and 'box_vectors' (3x3 array)
            attributes.

        Returns
        -------

        receptor_image : array of float
            The positions of binding site and ligand after
            preprocessing.

        """

        # get the unaligned image
        state_image = self._unaligned_image(state)

        # then superimpose it to the reference structure
        sup_image, _, _ = superimpose(self.ref_image,
                                      state_image,
                                      idxs=self._image_bs_idxs)

        return sup_image
Ejemplo n.º 3
0
    def image(self, state):

        # get the unaligned image
        state_image = self._unaligned_image(state)

        # then superimpose it to the reference structure
        sup_image = superimpose(self.ref_image,
                                state_image,
                                idxs=self._image_bs_idxs)

        return sup_image
Ejemplo 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
Ejemplo n.º 5
0
    def image(self, state):
        """

        Parameters
        ----------
        state :
            

        Returns
        -------

        """

        # get the unaligned image
        state_image = self._unaligned_image(state)

        # then superimpose it to the reference structure
        sup_image, _, _ = superimpose(self.ref_image,
                                      state_image,
                                      idxs=self._image_bs_idxs)

        return sup_image