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