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