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

Source Code for Module specific_fns.setup

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