Package specific_analyses :: Module api
[hide private]
[frames] | no frames]

Source Code for Module specific_analyses.api

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-2014 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  """The specific analysis API. 
 24   
 25  This module is for directly accessing the specific analysis API.  The individual API objects should not be accessed directly, but instead the functions here should be used. 
 26  """ 
 27   
 28  # relax module imports. 
 29  from data_store import Relax_data_store; ds = Relax_data_store() 
 30  from lib.errors import RelaxError 
 31  from pipe_control import pipes 
 32   
 33   
34 -def get_string(function_type):
35 """Function for returning a string corresponding to the function type.""" 36 37 # Consistency testing. 38 if function_type == 'ct': 39 return "consistency testing" 40 41 # The Frame Order theories. 42 if function_type == 'frame order': 43 return "Frame Order theories" 44 45 # NOE calculation. 46 if function_type == 'noe': 47 return "NOE calculations" 48 49 # The N-state model. 50 if function_type == 'N-state': 51 return "the N-state model" 52 53 # Relaxation dispersion curve fitting. 54 if function_type == 'relax_disp': 55 return "relaxation dispersion curve fitting" 56 57 # Relaxation curve fitting. 58 if function_type == 'relax_fit': 59 return "relaxation curve fitting" 60 61 # Reduced spectral density mapping. 62 if function_type == 'jw': 63 return "reduced spectral density mapping" 64 65 # Model-free analysis. 66 if function_type == 'mf': 67 return "Model-free analysis" 68 69 # Hybrid models. 70 if function_type == 'hybrid': 71 return "hybrid models" 72 73 # Unknown analysis. 74 raise RelaxError("The function_type " + repr(function_type) + " is unknown.")
75 76
77 -def return_api(analysis_type=None, pipe_name=None):
78 """Return the specific analysis API class instance corresponding to the function type. 79 80 @keyword analysis_type: The specific analysis type. This overrides the pipe_name argument. 81 @type analysis_type: str or None 82 @keyword pipe_name: The name of the data pipe to obtain the analysis type from. This is ignored if the analysis_type argument is given. If both arguments are None, then the current data pipe will be used. 83 """ 84 85 # The analysis type, if not given. 86 if analysis_type is None: 87 # Check if a data pipe exists. 88 pipes.test() 89 90 # Use a custom data pipe name. 91 if pipe_name: 92 analysis_type = ds[pipe_name].pipe_type 93 94 # Use the current data pipe. 95 else: 96 analysis_type = cdp.pipe_type 97 98 # Initialise the analysis object. 99 obj = None 100 101 # Consistency testing. 102 if analysis_type == 'ct': 103 from specific_analyses.consistency_tests.api import Consistency_tests 104 obj = Consistency_tests() 105 106 # The Frame Order theories. 107 elif analysis_type == 'frame order': 108 from specific_analyses.frame_order.api import Frame_order 109 obj = Frame_order() 110 111 # Hybrid models. 112 elif analysis_type == 'hybrid': 113 from specific_analyses.hybrid import Hybrid 114 obj = Hybrid() 115 116 # Reduced spectral density mapping. 117 elif analysis_type == 'jw': 118 from specific_analyses.jw_mapping.api import Jw_mapping 119 obj = Jw_mapping() 120 121 # Model-free analysis. 122 elif analysis_type == 'mf': 123 from specific_analyses.model_free.api import Model_free 124 obj = Model_free() 125 126 # The N-state model. 127 elif analysis_type == 'N-state': 128 from specific_analyses.n_state_model.api import N_state_model 129 obj = N_state_model() 130 131 # NOE calculation. 132 elif analysis_type == 'noe': 133 from specific_analyses.noe.api import Noe 134 obj = Noe() 135 136 # Relaxation dispersion curve fitting. 137 elif analysis_type == 'relax_disp': 138 from specific_analyses.relax_disp.api import Relax_disp 139 obj = Relax_disp() 140 141 # Relaxation curve fitting. 142 elif analysis_type == 'relax_fit': 143 from specific_analyses.relax_fit.api import Relax_fit 144 obj = Relax_fit() 145 146 # Return the object. 147 if obj != None: 148 return obj 149 150 # Unknown analysis. 151 raise RelaxError("The analysis type '%s' is unknown." % analysis_type)
152