Package specific_analyses :: Package model_free :: Module data
[hide private]
[frames] | no frames]

Source Code for Module specific_analyses.model_free.data

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2007-2014 Edward d'Auvergne                                   # 
 4  # Copyright (C) 2007 Gary S Thompson (https://gna.org/users/varioustoxins)    # 
 5  #                                                                             # 
 6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 7  #                                                                             # 
 8  # This program is free software: you can redistribute it and/or modify        # 
 9  # it under the terms of the GNU General Public License as published by        # 
10  # the Free Software Foundation, either version 3 of the License, or           # 
11  # (at your option) any later version.                                         # 
12  #                                                                             # 
13  # This program is distributed in the hope that it will be useful,             # 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
16  # GNU General Public License for more details.                                # 
17  #                                                                             # 
18  # You should have received a copy of the GNU General Public License           # 
19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # Module docstring. 
24  """The Lipari-Szabo model-free analysis base data functions.""" 
25   
26   
27  # Python module imports. 
28  from re import search 
29   
30  # relax module imports. 
31  from lib.errors import RelaxError 
32   
33   
34 -def compare_objects(object_from, object_to, pipe_from, pipe_to):
35 """Compare the contents of the two objects and raise RelaxErrors if they are not the same. 36 37 @param object_from: The first object. 38 @type object_from: any object 39 @param object_to: The second object. 40 @type object_to: any object 41 @param pipe_from: The name of the data pipe containing the first object. 42 @type pipe_from: str 43 @param pipe_to: The name of the data pipe containing the second object. 44 @type pipe_to: str 45 """ 46 47 # Loop over the modifiable objects. 48 for data_name in dir(object_from): 49 # Skip special objects (starting with _, or in the original class and base class namespaces). 50 if search('^_', data_name) or data_name in list(object_from.__class__.__dict__.keys()) or (hasattr(object_from.__class__, '__bases__') and len(object_from.__class__.__bases__) and data_name in list(object_from.__class__.__bases__[0].__dict__.keys())): 51 continue 52 53 # Skip some more special objects. 54 if data_name in ['structural_data']: 55 continue 56 57 # Get the original object. 58 data_from = None 59 if hasattr(object_from, data_name): 60 data_from = getattr(object_from, data_name) 61 62 # Get the target object. 63 if data_from and not hasattr(object_to, data_name): 64 raise RelaxError("The structural object " + repr(data_name) + " of the " + repr(pipe_from) + " data pipe is not located in the " + repr(pipe_to) + " data pipe.") 65 elif data_from: 66 data_to = getattr(object_to, data_name) 67 else: 68 continue 69 70 # The data must match! 71 if data_from != data_to: 72 raise RelaxError("The object " + repr(data_name) + " is not consistent between the pipes " + repr(pipe_from) + " and " + repr(pipe_to) + ".")
73