Package specific_analyses :: Module setup
[hide private]
[frames] | no frames]

Source Code for Module specific_analyses.setup

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-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 handling the setup of the specific analyses.""" 
 24   
 25  # relax module imports. 
 26  from lib.errors import RelaxError, RelaxFuncSetupError 
 27  from pipe_control import pipes 
 28  from specific_analyses.consistency_tests import Consistency_tests 
 29  from specific_analyses.frame_order import Frame_order 
 30  from specific_analyses.hybrid import Hybrid 
 31  from specific_analyses.jw_mapping import Jw_mapping 
 32  from specific_analyses.model_free import Model_free 
 33  from specific_analyses.n_state_model import N_state_model 
 34  from specific_analyses.noe import Noe 
 35  from specific_analyses.relax_fit import Relax_fit 
 36   
 37   
 38  # Instantiate all classes. 
 39  consistency_tests_obj = Consistency_tests() 
 40  frame_order_obj = Frame_order() 
 41  hybrid_obj = Hybrid() 
 42  jw_mapping_obj = Jw_mapping() 
 43  model_free_obj = Model_free() 
 44  n_state_model_obj = N_state_model() 
 45  noe_obj = Noe() 
 46  relax_fit_obj = Relax_fit() 
 47   
 48   
 49  # The function for returning the requested specific function. 
50 -def get_specific_fn(eqi, function_type=None, raise_error=True):
51 """The function for returning the requested specific function.""" 52 53 # Initialise. 54 function = None 55 if function_type == None: 56 function_type = pipes.get_type() 57 58 # Get the class instance corresponding to function_type. 59 inst = get_instance(function_type) 60 61 # Attempt to retrieve the function. 62 try: 63 # Back calculation of relaxation data. 64 if eqi == 'back_calc_ri': 65 function = inst.back_calc_ri 66 67 # Base data loop generator function. 68 if eqi == 'base_data_loop': 69 function = inst.base_data_loop 70 71 # BMRB NMR-STAR v3.1 reading function. 72 if eqi == 'bmrb_read': 73 function = inst.bmrb_read 74 75 # BMRB NMR-STAR v3.1 writing function. 76 if eqi == 'bmrb_write': 77 function = inst.bmrb_write 78 79 # Calculate function. 80 if eqi == 'calculate': 81 function = inst.calculate 82 83 # Optimisation constraint algorithm override. 84 if eqi == 'constraint_algorithm': 85 function = inst.constraint_algorithm 86 87 # Create Monte Carlo data function. 88 if eqi == 'create_mc_data': 89 function = inst.create_mc_data 90 91 # Data structure initialisation function. 92 if eqi == 'data_init': 93 function = inst.data_init 94 95 # List of parameter names returning function. 96 if eqi == 'data_names': 97 function = inst.data_names 98 99 # The parameter type function. 100 if eqi == 'data_type': 101 function = inst.data_type 102 103 # Default parameter value returning function. 104 if eqi == 'default_value': 105 function = inst.default_value 106 107 # Duplicate data function. 108 if eqi == 'duplicate_data': 109 function = inst.duplicate_data 110 111 # Eliminate models. 112 if eqi == 'eliminate': 113 function = inst.eliminate 114 115 # Parameter names function. 116 if eqi == 'get_param_names': 117 function = inst.get_param_names 118 119 # Parameter values function. 120 if eqi == 'get_param_values': 121 function = inst.get_param_values 122 123 # Grid search function. 124 if eqi == 'grid_search': 125 function = inst.grid_search 126 127 # Initial Monte Carlo parameter value search function. 128 if eqi == 'init_sim_values': 129 function = inst.sim_init_values 130 131 # Spin specific parameter determining function. 132 if eqi == 'is_spin_param': 133 function = inst.is_spin_param 134 135 # Map bounds function. 136 if eqi == 'map_bounds': 137 function = inst.map_bounds 138 139 # Minimise function. 140 if eqi == 'minimise': 141 function = inst.minimise 142 143 # Model loop. 144 if eqi == 'model_desc': 145 function = inst.model_desc 146 147 # Model loop. 148 if eqi == 'model_loop': 149 function = inst.model_loop 150 151 # Model statistics. 152 if eqi == 'model_stats': 153 function = inst.model_statistics 154 155 # Model type. 156 if eqi == 'model_type': 157 function = inst.model_type 158 159 # Molmol macro creation. 160 if eqi == 'molmol_macro': 161 function = inst.molmol_macro 162 163 # Number of instances. 164 if eqi == 'num_instances': 165 function = inst.num_instances 166 167 # Overfit deselect. 168 if eqi == 'overfit_deselect': 169 function = inst.overfit_deselect 170 171 # Pack Monte Carlo simulation data function. 172 if eqi == 'pack_sim_data': 173 function = inst.sim_pack_data 174 175 # Pymol macro creation. 176 if eqi == 'pymol_macro': 177 function = inst.pymol_macro 178 179 # Read results file function (Columnar format). 180 if eqi == 'read_columnar_results': 181 function = inst.read_columnar_results 182 183 # Read results file function (XML format). 184 #if eqi == 'read_xml_results': 185 # function = inst.read_xml_results 186 187 # Data returning function. 188 if eqi == 'return_data': 189 function = inst.return_data 190 191 # Parameter description returning function. 192 if eqi == 'return_data_desc': 193 function = inst.return_data_desc 194 195 # Data or parameter name returning function. 196 if eqi == 'return_data_name': 197 function = inst.return_data_name 198 199 # Data error returning function. 200 if eqi == 'return_error': 201 function = inst.return_error 202 203 # Factor of conversion between different parameter units returning function. 204 if eqi == 'return_conversion_factor': 205 function = inst.return_conversion_factor 206 207 # Grace string returning function. 208 if eqi == 'return_grace_string': 209 function = inst.return_grace_string 210 211 # Selected simulation array returning function. 212 if eqi == 'return_selected_sim': 213 function = inst.sim_return_selected 214 215 # Simulation chi-squared array returning function. 216 if eqi == 'return_sim_chi2': 217 function = inst.sim_return_chi2 218 219 # Simulation parameter array returning function. 220 if eqi == 'return_sim_param': 221 function = inst.sim_return_param 222 223 # String of the external parameter units returning function. 224 if eqi == 'return_units': 225 function = inst.return_units 226 227 # Value and error returning function. 228 if eqi == 'return_value': 229 function = inst.return_value 230 231 # Set error function. 232 if eqi == 'set_error': 233 function = inst.set_error 234 235 # Set parameter values function. 236 if eqi == 'set_param_values': 237 function = inst.set_param_values 238 239 # Set the selected simulations array. 240 if eqi == 'set_selected_sim': 241 function = inst.set_selected_sim 242 243 # Set update function. 244 if eqi == 'set_update': 245 function = inst.set_update 246 247 # Skip function. 248 if eqi == 'skip_function': 249 function = inst.skip_function 250 251 # Deselection function. 252 if eqi == 'deselect': 253 function = inst.deselect 254 255 # Catch if the function is missing. 256 except AttributeError: 257 function = None 258 259 # Raise an error if the function doesn't exist. 260 if raise_error and function == None: 261 # Raise the error. 262 raise RelaxFuncSetupError(get_string(function_type)) 263 264 # Return the function. 265 return function
266 267
268 -def get_instance(function_type):
269 """Function for returning the class instance corresponding to the function type.""" 270 271 # Consistency testing. 272 if function_type == 'ct': 273 return consistency_tests_obj 274 275 # The Frame Order theories. 276 if function_type == 'frame order': 277 return frame_order_obj 278 279 # NOE calculation. 280 if function_type == 'noe': 281 return noe_obj 282 283 # The N-state model. 284 if function_type == 'N-state': 285 return n_state_model_obj 286 287 # Relaxation curve fitting. 288 if function_type == 'relax_fit': 289 return relax_fit_obj 290 291 # Reduced spectral density mapping. 292 if function_type == 'jw': 293 return jw_mapping_obj 294 295 # Model-free analysis. 296 if function_type == 'mf': 297 return model_free_obj 298 299 # Hybrid models. 300 if function_type == 'hybrid': 301 return hybrid_obj 302 303 # Unknown analysis. 304 raise RelaxError("The function_type " + repr(function_type) + " is unknown.")
305 306
307 -def get_string(function_type):
308 """Function for returning a string corresponding to the function type.""" 309 310 # Consistency testing. 311 if function_type == 'ct': 312 return "consistency testing" 313 314 # The Frame Order theories. 315 if function_type == 'frame order': 316 return "Frame Order theories" 317 318 # NOE calculation. 319 if function_type == 'noe': 320 return "NOE calculations" 321 322 # The N-state model. 323 if function_type == 'N-state': 324 return "the N-state model" 325 326 # Relaxation curve fitting. 327 if function_type == 'relax_fit': 328 return "relaxation curve fitting" 329 330 # Reduced spectral density mapping. 331 if function_type == 'jw': 332 return "reduced spectral density mapping" 333 334 # Model-free analysis. 335 if function_type == 'mf': 336 return "Model-free analysis" 337 338 # Hybrid models. 339 if function_type == 'hybrid': 340 return "hybrid models" 341 342 # Unknown analysis. 343 raise RelaxError("The function_type " + repr(function_type) + " is unknown.")
344