Esempio n. 1
0
    def rmsd(self, other):
        """Compute the RMSD between two molecules.

           Arguments:
            | ``other``  --  Another molecule with the same atom numbers

           Return values:
            | ``transformation``  --  the transformation that brings 'self' into
                                  overlap with 'other'
            | ``other_trans``  --  the transformed coordinates of geometry 'other'
            | ``rmsd``  --  the rmsd of the distances between corresponding atoms in
                            'self' and 'other'

           Make sure the atoms in `self` and `other` are in the same order.

           Usage::

             >>> print molecule1.rmsd(molecule2)[2]/angstrom
        """
        if self.numbers.shape != other.numbers.shape or \
           (self.numbers != other.numbers).all():
            raise ValueError(
                "The other molecule does not have the same numbers as this molecule."
            )
        return fit_rmsd(self.coordinates, other.coordinates)
Esempio n. 2
0
def compute_rotsym(molecule, graph, threshold=1e-3*angstrom):
    """Compute the rotational symmetry number

       Arguments:
        | ``molecule``  --  The molecule
        | ``graph``  --  The corresponding bond graph

       Optional argument:
        | ``threshold``  --  only when a rotation results in an rmsd below the
                             given threshold, the rotation is considered to
                             transform the molecule onto itself.
    """
    result = 0
    for match in graph.symmetries:
        permutation = list(j for i,j in sorted(match.forward.iteritems()))
        new_coordinates = molecule.coordinates[permutation]
        rmsd = fit_rmsd(molecule.coordinates, new_coordinates)[2]
        if rmsd < threshold:
            result += 1
    return result
Esempio n. 3
0
def compute_rotsym(molecule, graph, threshold=1e-3 * angstrom):
    """Compute the rotational symmetry number

       Arguments:
        | ``molecule``  --  The molecule
        | ``graph``  --  The corresponding bond graph

       Optional argument:
        | ``threshold``  --  only when a rotation results in an rmsd below the
                             given threshold, the rotation is considered to
                             transform the molecule onto itself.
    """
    result = 0
    for match in graph.symmetries:
        permutation = list(j for i, j in sorted(match.forward.items()))
        new_coordinates = molecule.coordinates[permutation]
        rmsd = fit_rmsd(molecule.coordinates, new_coordinates)[2]
        if rmsd < threshold:
            result += 1
    return result
Esempio n. 4
0
    def rmsd(self, other):
        """Compute the RMSD between two molecules.

           Arguments:
            | ``other``  --  Another molecule with the same atom numbers

           Return values:
            | ``transformation``  --  the transformation that brings 'self' into
                                  overlap with 'other'
            | ``other_trans``  --  the transformed coordinates of geometry 'other'
            | ``rmsd``  --  the rmsd of the distances between corresponding atoms in
                            'self' and 'other'

           Make sure the atoms in `self` and `other` are in the same order.

           Usage::

             >>> print molecule1.rmsd(molecule2)[2]/angstrom
        """
        if self.numbers.shape != other.numbers.shape or \
           (self.numbers != other.numbers).all():
            raise ValueError("The other molecule does not have the same numbers as this molecule.")
        return fit_rmsd(self.coordinates, other.coordinates)