def build(cls, data_handler, matrix_creation_parameters):
        """
        Generates a matrix with the method used in the handler creation.

        @param trajectory_handler:
        @param matrix_creation_parameters:

        @return: The created matrix.
        """
        calculator_type = matrix_creation_parameters.get_value("calculator_type", 
                                                               default_value = "QTRFIT_OMP_CALCULATOR")

        calculator_options = matrix_creation_parameters.get_value("calculator_options", 
                                                               default_value = ProtocolParameters({"number_of_threads":8,
                                                                                "blocks_per_grid":8,
                                                                                "threads_per_block":32}))
        calculator_options = ProtocolParameters(calculator_options)
        
        structure = data_handler.get_data()
        fit_selection_coordsets = structure.getFittingCoordinates()
        calc_selection_coordsets = structure.getCalculationCoordinates()
        
        if calc_selection_coordsets is None:
            calculator = RMSDCalculator(calculatorType = calculator_type,
                                        fittingCoordsets  = fit_selection_coordsets)
        else:
            symm_groups = []
            if "symmetries" in matrix_creation_parameters:
                # Then prepare it to handle calculation symmetries
                # Description of equivalences must have the same number of atoms
                symm_groups = cls.process_symm_groups(matrix_creation_parameters,
                                                      structure,
                                                      calc_selection_coordsets)
                print "Using symmetries", symm_groups
            
            
            
            calculator = RMSDCalculator(calculatorType = calculator_type,
                                        fittingCoordsets  = fit_selection_coordsets,
                                        calculationCoordsets = calc_selection_coordsets,
                                        calcSymmetryGroups = symm_groups)
        
        try:
            calculator.setNumberOfOpenMPThreads(calculator_options.get_value("number_of_threads",
                                            default_value = 8))
        except KeyError:
            pass
        
        try:
            calculator.setCUDAKernelThreadsPerBlock(calculator_options.get_value("threads_per_block",
                                                                             default_value = 32), 
                                                calculator_options.get_value("blocks_per_grid",
                                                                             default_value = 8))
        except KeyError:
            pass
        
        rmsds = calculator.pairwiseRMSDMatrix()
        return CondensedMatrix(rmsds)
def superimpose_coordinates(all_coordsets, iterpose = True):
    all_superimposed_coordsets = []
    for coordsets in all_coordsets:
        calculator = RMSDCalculator(calculatorType = "QTRFIT_OMP_CALCULATOR",
                                fittingCoordsets = coordsets)
        calculator.setNumberOfOpenMPThreads(4)
        
        if iterpose:
            print "\t- Using iterposition on trajectory (shape ", coordsets.shape, ")"
            calculator.iterativeSuperposition()
            all_superimposed_coordsets.append(coordsets)
        else:
            print "\t- Superimposing with first trajectory frame (shape ", coordsets.shape, ")"
            _, superimposed_coordsets = calculator.oneVsTheOthers(0, get_superposed_coordinates = True)
            all_superimposed_coordsets.append(superimposed_coordsets)
    return all_superimposed_coordsets
Пример #3
0
def coords_rmsf(ca_coords):
    calculator = RMSDCalculator(calculatorType="QTRFIT_OMP_CALCULATOR",
                                fittingCoordsets=ca_coords)

    calculator.setNumberOfOpenMPThreads(4)

    new_ca_coords = calculator.iterativeSuperposition()

    # Calculate the actual rmsf
    mean_conformation = new_ca_coords.mean(0)

    ssqf = numpy.zeros(mean_conformation.shape)

    for conf in new_ca_coords:
        ssqf += (conf - mean_conformation)**2

    return (ssqf.sum(1) / new_ca_coords.shape[0])**0.5
Пример #4
0
def superimpose_coordinates(all_coordsets, iterpose=True):
    all_superimposed_coordsets = []
    for coordsets in all_coordsets:
        calculator = RMSDCalculator(calculatorType="QTRFIT_OMP_CALCULATOR",
                                    fittingCoordsets=coordsets)
        calculator.setNumberOfOpenMPThreads(4)

        if iterpose:
            print "\t- Using iterposition on trajectory (shape ", coordsets.shape, ")"
            calculator.iterativeSuperposition()
            all_superimposed_coordsets.append(coordsets)
        else:
            print "\t- Superimposing with first trajectory frame (shape ", coordsets.shape, ")"
            _, superimposed_coordsets = calculator.oneVsTheOthers(
                0, get_superposed_coordinates=True)
            all_superimposed_coordsets.append(superimposed_coordsets)
    return all_superimposed_coordsets
Пример #5
0
    def build(cls, data_handler, matrix_creation_parameters):
        """
        Generates a matrix with the method used in the handler creation.

        @param trajectory_handler:
        @param matrix_creation_parameters:

        @return: The created matrix.
        """
        calculator_type = matrix_creation_parameters.get_value(
            "calculator_type", default_value="QTRFIT_OMP_CALCULATOR")

        calculator_options = matrix_creation_parameters.get_value(
            "calculator_options",
            default_value=ProtocolParameters({
                "number_of_threads": 8,
                "blocks_per_grid": 8,
                "threads_per_block": 32
            }))
        calculator_options = ProtocolParameters(calculator_options)

        structure = data_handler.get_data()
        fit_selection_coordsets = structure.getFittingCoordinates()
        calc_selection_coordsets = structure.getCalculationCoordinates()

        if calc_selection_coordsets is None:
            calculator = RMSDCalculator(
                calculatorType=calculator_type,
                fittingCoordsets=fit_selection_coordsets)
        else:
            symm_groups = []
            if "symmetries" in matrix_creation_parameters:
                # Then prepare it to handle calculation symmetries
                # Description of equivalences must have the same number of atoms
                symm_groups = cls.process_symm_groups(
                    matrix_creation_parameters, structure,
                    calc_selection_coordsets)
                print "Using symmetries", symm_groups

            calculator = RMSDCalculator(
                calculatorType=calculator_type,
                fittingCoordsets=fit_selection_coordsets,
                calculationCoordsets=calc_selection_coordsets,
                calcSymmetryGroups=symm_groups)

        try:
            calculator.setNumberOfOpenMPThreads(
                calculator_options.get_value("number_of_threads",
                                             default_value=8))
        except KeyError:
            pass

        try:
            calculator.setCUDAKernelThreadsPerBlock(
                calculator_options.get_value("threads_per_block",
                                             default_value=32),
                calculator_options.get_value("blocks_per_grid",
                                             default_value=8))
        except KeyError:
            pass

        rmsds = calculator.pairwiseRMSDMatrix()
        return CondensedMatrix(rmsds)