Beispiel #1
0
    def test_validation(self):
        symm_group_1 = [ [1,2] ] # This is a single symm group. It means that atom 1 and 2 are equivalent. We will try 
                                # to swap 1 and 2.
                                 
        symm_group_2 = [ [3,4],[5,6] ]  # This is a single symm group. It means that atom 3 and 4, as well as 
                                        # atoms 5,6 are equivalent, and they have to be swapped at the same time. 
                                        # We will try with the following combinations:
                                        # (3,4)  (5,6)
                                        # (4,3)  (6,5)

        # The validation function validates a list of this symmetry groups. When we use this list, all permutations are
        # used (i.e. sym_perm(symm_group_1) x sym_perm(symm_group_2)). That is:
        # (1,2) (3,4)  (5,6)
        # (1,2) (4,3)  (6,5)
        # (2,1) (3,4)  (5,6)
        # (2,1) (4,3)  (6,5)

        # A symm group is not a valid description
        self.assertRaises(ValueError, symm_groups_validation, symm_group_1)
        
        # A list of symm groups is a valid symmetry descriptor
        try:
            symm_groups_validation([symm_group_1])
            symm_groups_validation([symm_group_1, symm_group_2])
        except ValueError:
            self.fail("Value exception has been raised.")
    
        symm_group_3 = [ [2,1,3] ] # A symm group must have elements of len 2
         
        self.assertRaises(ValueError, symm_groups_validation, [symm_group_3])
Beispiel #2
0
    def __init__(self,
                 calculatorType,
                 fittingCoordsets,
                 calculationCoordsets=None,
                 fitSymmetryGroups=[],
                 calcSymmetryGroups=[]):
        """
        Class constructor.

        @param calculatorType: One of the calculators returned by 'availableCalculators()'. i.e. KABSCH_OMP_CALCULATOR

        @param fittingCoordsets: An array containing the used coordinates of each conformation. It has the following form:
            coordsets: [Conformation 1, Conformation 2, ..., Conformation N]
            Conformation: [Atom 1, Atom 2,..., Atom M]
            Atom: [x,y,z]

            This coordinates will be used for both structural superposition and RMSD calculation if the 'calculation
            coordinates' parameter is not defined.

            The array type is constrained to be a numpy.array object with dtype = numpy.float64 (dtype will not be always double
            by default).

            Input coordinates are modified after each operation (usually centered and superposed into reference conformation).

        @param calculationCoordsets: An array containing the coordinates used to calculate the RMSD. Must have the same structure
            than 'fittingCoordinates'.

        @param fitSymmetryGroups: List of symmetry groups. 
            Symm. groups are a low-level structure-agnostic of the type of symmetries that can be found in some ligands,
            i.e. in rotating benzene groups. It can also be used in symmetries of bigger selections though.
            See :py:func:`pyRMSD.symmTools.symm_permutations` 
        @param calcSymmetryGroups: As in 'fitSymmetryGroups', a list of symmetry groups.

        @author: vgil
        @date: 26/11/2012
        """
        if not calculatorType in availableCalculators():
            print("Calculator ", calculatorType,
                  " is not an available calculator.")
            raise ValueError
        else:
            self.fitting_coordinates = fittingCoordsets
            self.calculator_type = calculatorType
            self.number_of_conformations = self.fitting_coordinates.shape[0]
            self.number_of_fitting_atoms = self.fitting_coordinates.shape[1]

            self.calculation_coordinates = calculationCoordsets
            if self.calculation_coordinates is not None:
                self.calculation_coordinates = calculationCoordsets
                if self.number_of_conformations != self.calculation_coordinates.shape[
                        0]:
                    print(
                        "Calculation coordinates must hold the same number of conformations than fitting coordinates."
                    )
                    raise ValueError
                self.number_of_calculation_atoms = self.calculation_coordinates.shape[
                    1]
            else:
                self.number_of_calculation_atoms = 0

            # Default values for openMP and CUDA flags
            self.__threads_per_block = 32
            self.__blocks_per_grid = 8
            self.__number_of_threads = 8

            # Symmetry group handling
            symm_groups_validation(fitSymmetryGroups)
            symm_groups_validation(calcSymmetryGroups)
            self.fit_symmetry_groups = fitSymmetryGroups
            self.calc_symmetry_groups = calcSymmetryGroups
    def __init__(
        self, calculatorType, fittingCoordsets, calculationCoordsets=None, fitSymmetryGroups=[], calcSymmetryGroups=[]
    ):
        """
        Class constructor.

        @param calculatorType: One of the calculators returned by 'availableCalculators()'. i.e. KABSCH_OMP_CALCULATOR

        @param fittingCoordsets: An array containing the used coordinates of each conformation. It has the following form:
            coordsets: [Conformation 1, Conformation 2, ..., Conformation N]
            Conformation: [Atom 1, Atom 2,..., Atom M]
            Atom: [x,y,z]

            This coordinates will be used for both structural superposition and RMSD calculation if the 'calculation
            coordinates' parameter is not defined.

            The array type is constrained to be a numpy.array object with dtype = numpy.float64 (dtype will not be always double
            by default).

            Input coordinates are modified after each operation (usually centered and superposed into reference conformation).

        @param calculationCoordsets: An array containing the coordinates used to calculate the RMSD. Must have the same structure
            than 'fittingCoordinates'.

        @param fitSymmetryGroups: List of symmetry groups. 
            Symm. groups are a low-level structure-agnostic of the type of symmetries that can be found in some ligands,
            i.e. in rotating benzene groups. It can also be used in symmetries of bigger selections though.
            See :py:func:`pyRMSD.symmTools.symm_permutations` 
        @param calcSymmetryGroups: As in 'fitSymmetryGroups', a list of symmetry groups.

        @author: vgil
        @date: 26/11/2012
        """
        if not calculatorType in availableCalculators():
            print "Calculator ", calculatorType, " is not an available calculator."
            raise ValueError
        else:
            self.fitting_coordinates = fittingCoordsets
            self.calculator_type = calculatorType
            self.number_of_conformations = self.fitting_coordinates.shape[0]
            self.number_of_fitting_atoms = self.fitting_coordinates.shape[1]

            self.calculation_coordinates = calculationCoordsets
            if self.calculation_coordinates is not None:
                self.calculation_coordinates = calculationCoordsets
                if self.number_of_conformations != self.calculation_coordinates.shape[0]:
                    print "Calculation coordinates must hold the same number of conformations than fitting coordinates."
                    raise ValueError
                self.number_of_calculation_atoms = self.calculation_coordinates.shape[1]
            else:
                self.number_of_calculation_atoms = 0

            # Default values for openMP and CUDA flags
            self.__threads_per_block = 32
            self.__blocks_per_grid = 8
            self.__number_of_threads = 8

            # Symmetry group handling
            symm_groups_validation(fitSymmetryGroups)
            symm_groups_validation(calcSymmetryGroups)
            self.fit_symmetry_groups = fitSymmetryGroups
            self.calc_symmetry_groups = calcSymmetryGroups