Package specific_analyses :: Package relax_fit :: Module uf
[hide private]
[frames] | no frames]

Source Code for Module specific_analyses.relax_fit.uf

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2014 Edward d'Auvergne                                   # 
  4  # Copyright (C) 2006 Chris MacRaild                                           # 
  5  # Copyright (C) 2008 Sebastien Morin                                          # 
  6  #                                                                             # 
  7  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  8  #                                                                             # 
  9  # This program is free software: you can redistribute it and/or modify        # 
 10  # it under the terms of the GNU General Public License as published by        # 
 11  # the Free Software Foundation, either version 3 of the License, or           # 
 12  # (at your option) any later version.                                         # 
 13  #                                                                             # 
 14  # This program is distributed in the hope that it will be useful,             # 
 15  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 16  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 17  # GNU General Public License for more details.                                # 
 18  #                                                                             # 
 19  # You should have received a copy of the GNU General Public License           # 
 20  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 21  #                                                                             # 
 22  ############################################################################### 
 23   
 24  # Module docstring. 
 25  """The R1 and R2 exponential relaxation curve fitting user functions.""" 
 26   
 27  # relax module imports. 
 28  from lib.errors import RelaxError, RelaxFuncSetupError, RelaxNoSequenceError 
 29  from pipe_control.pipes import check_pipe 
 30  from pipe_control.mol_res_spin import exists_mol_res_spin_data, spin_loop 
 31  from specific_analyses.relax_fit.api import Relax_fit 
 32   
 33  # The API object. 
 34  api_relax_fit = Relax_fit() 
 35   
 36   
37 -def model_setup(model, params):
38 """Update various model specific data structures. 39 40 @param model: The exponential curve type. 41 @type model: str 42 @param params: A list consisting of the model parameters. 43 @type params: list of str 44 """ 45 46 # Set the model. 47 cdp.curve_type = model 48 49 # Loop over the sequence. 50 for spin, spin_id in spin_loop(return_id=True): 51 # Skip deselected spins. 52 if not spin.select: 53 continue 54 55 # Initialise the data structures (if needed). 56 api_relax_fit.data_init(spin_id) 57 58 # The model and parameter names. 59 spin.model = model 60 spin.params = params
61 62
63 -def relax_time(time=0.0, spectrum_id=None):
64 """Set the relaxation time period associated with a given spectrum. 65 66 @keyword time: The time, in seconds, of the relaxation period. 67 @type time: float 68 @keyword spectrum_id: The spectrum identification string. 69 @type spectrum_id: str 70 """ 71 72 # Test if the spectrum id exists. 73 if spectrum_id not in cdp.spectrum_ids: 74 raise RelaxError("The peak heights corresponding to spectrum id '%s' have not been loaded." % spectrum_id) 75 76 # Initialise the global relaxation time data structure if needed. 77 if not hasattr(cdp, 'relax_times'): 78 cdp.relax_times = {} 79 80 # Add the time at the correct position. 81 cdp.relax_times[spectrum_id] = time
82 83
84 -def select_model(model='exp'):
85 """Function for selecting the model of the exponential curve. 86 87 @keyword model: The exponential curve type. Can be one of 'exp', 'inv', or 'sat'. 88 @type model: str 89 """ 90 91 # Test if the current pipe exists. 92 check_pipe() 93 94 # Test if the pipe type is set to 'relax_fit'. 95 function_type = cdp.pipe_type 96 if function_type != 'relax_fit': 97 raise RelaxFuncSetupError(specific_setup.get_string(function_type)) 98 99 # Test if sequence data is loaded. 100 if not exists_mol_res_spin_data(): 101 raise RelaxNoSequenceError 102 103 # Two parameter exponential fit. 104 if model == 'exp': 105 print("Two parameter exponential fit.") 106 params = ['rx', 'i0'] 107 108 # Three parameter inversion recovery fit. 109 elif model == 'inv': 110 print("The inversion recovery experiment.") 111 params = ['rx', 'i0', 'iinf'] 112 113 # The saturation recovery. 114 elif model == 'sat': 115 print("The saturation recovery experiment.") 116 params = ['rx', 'iinf'] 117 118 # Invalid model. 119 else: 120 raise RelaxError("The model '" + model + "' is invalid.") 121 122 # Set up the model. 123 model_setup(model, params)
124