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

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