Пример #1
0
    def project(self, mol):
        """ Project molecule.

        Parameters
        ----------
        mol : :class:`Molecule <moleculekit.molecule.Molecule>`
            A :class:`Molecule <moleculekit.molecule.Molecule>` object to project.

        Returns
        -------
        data : np.ndarray
            An array containing the projected data.
        """
        getMolProp = lambda prop: self._getMolProp(mol, prop)
        sel1 = getMolProp('sel1')
        sel2 = getMolProp('sel2')

        if np.ndim(sel1) == 1 and np.ndim(sel2) == 1:  # normal distances
            metric = pp_calcDistances(mol,
                                      sel1,
                                      sel2,
                                      self.metric,
                                      self.threshold,
                                      self.pbc,
                                      truncate=self.truncate)
        else:  # minimum distances by groups
            metric = pp_calcMinDistances(mol,
                                         sel1,
                                         sel2,
                                         self.metric,
                                         self.threshold,
                                         pbc=self.pbc,
                                         truncate=self.truncate)

        return metric
Пример #2
0
def closestDistance(mol1, mol2):
    from moleculekit.projections.util import pp_calcMinDistances

    mol1 = mol1.copy()
    mol1.segid[:] = "X"
    mol2 = mol2.copy()
    mol2.segid[:] = "Y"

    mol1.append(mol2)

    sel1 = mol1.atomselect("segid X")[None, :]
    sel2 = mol1.atomselect("segid Y")[None, :]

    return pp_calcMinDistances(mol1, sel1, sel2, periodic=None).squeeze()