Package target_functions :: Module ens_pivot_finder
[hide private]
[frames] | no frames]

Source Code for Module target_functions.ens_pivot_finder

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2011-2013 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program is free software: you can redistribute it and/or modify        # 
 8  # it under the terms of the GNU General Public License as published by        # 
 9  # the Free Software Foundation, either version 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program is distributed in the hope that it will be useful,             # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
15  # GNU General Public License for more details.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Module docstring. 
23  """Module for the target function for handling all types of structural superimpositions.""" 
24   
25  # Python module imports. 
26  from copy import deepcopy 
27   
28  # relax module import. 
29  from lib.structure.statistics import atomic_rmsd 
30  from lib.structure.superimpose import fit_to_mean 
31   
32   
33 -class Pivot_finder:
34 """Class for finding the optimal pivot point for motions between the given models.""" 35
36 - def __init__(self, models, coord):
37 """Set up the class for pivot point optimisation for an ensemble of structures. 38 39 @keyword models: The list of models to use. If set to None, then all models will be used. 40 @type models: list of int or None 41 @keyword coord: The array of molecular coordinates. The first dimension corresponds to the model, the second the atom, the third the coordinate. 42 @type coord: rank-3 numpy array 43 """ 44 45 # Store the args. 46 self.models = models 47 self.coord = coord 48 49 # Store a copy of the coordinates for restoration. 50 self.orig_coord = deepcopy(coord)
51 52
53 - def func(self, params):
54 """Target function for the optimisation of the motional pivot point from an ensemble of structures. 55 56 @param params: The parameter vector from the optimisation algorithm. 57 @type params: list 58 @return: The target function value defined as the combined RMSD value. 59 @rtype: float 60 """ 61 62 # The fit to mean algorithm. 63 T, R, pivot = fit_to_mean(models=self.models, coord=self.coord, centroid=params, verbosity=0) 64 65 # The RMSD. 66 val = atomic_rmsd(self.coord) 67 68 # Restore the coordinates. 69 self.coord = deepcopy(self.orig_coord) 70 71 # Return the RMSD. 72 return val
73