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