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) 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 R1 and R2 exponential relaxation curve fitting user functions.""" 
 24   
 25  # relax module imports. 
 26  from lib.errors import RelaxError, RelaxFuncSetupError, RelaxNoSequenceError 
 27  from pipe_control import pipes 
 28  from pipe_control.mol_res_spin import exists_mol_res_spin_data, spin_loop 
 29  from specific_analyses.relax_fit.api import Relax_fit 
 30   
 31  # The API object. 
 32  api_relax_fit = Relax_fit() 
 33   
 34   
35 -def model_setup(model, params):
36 """Update various model specific data structures. 37 38 @param model: The exponential curve type. 39 @type model: str 40 @param params: A list consisting of the model parameters. 41 @type params: list of str 42 """ 43 44 # Set the model. 45 cdp.curve_type = model 46 47 # Loop over the sequence. 48 for spin in spin_loop(): 49 # Skip deselected spins. 50 if not spin.select: 51 continue 52 53 # Initialise the data structures (if needed). 54 api_relax_fit.data_init(spin) 55 56 # The model and parameter names. 57 spin.model = model 58 spin.params = params
59 60
61 -def relax_time(time=0.0, spectrum_id=None):
62 """Set the relaxation time period associated with a given spectrum. 63 64 @keyword time: The time, in seconds, of the relaxation period. 65 @type time: float 66 @keyword spectrum_id: The spectrum identification string. 67 @type spectrum_id: str 68 """ 69 70 # Test if the spectrum id exists. 71 if spectrum_id not in cdp.spectrum_ids: 72 raise RelaxError("The peak heights corresponding to spectrum id '%s' have not been loaded." % spectrum_id) 73 74 # Initialise the global relaxation time data structure if needed. 75 if not hasattr(cdp, 'relax_times'): 76 cdp.relax_times = {} 77 78 # Add the time at the correct position. 79 cdp.relax_times[spectrum_id] = time
80 81
82 -def select_model(model='exp'):
83 """Function for selecting the model of the exponential curve. 84 85 @keyword model: The exponential curve type. Can be one of 'exp' or 'inv'. 86 @type model: str 87 """ 88 89 # Test if the current pipe exists. 90 pipes.test() 91 92 # Test if the pipe type is set to 'relax_fit'. 93 function_type = cdp.pipe_type 94 if function_type != 'relax_fit': 95 raise RelaxFuncSetupError(specific_setup.get_string(function_type)) 96 97 # Test if sequence data is loaded. 98 if not exists_mol_res_spin_data(): 99 raise RelaxNoSequenceError 100 101 # Two parameter exponential fit. 102 if model == 'exp': 103 print("Two parameter exponential fit.") 104 params = ['rx', 'i0'] 105 106 # Three parameter inversion recovery fit. 107 elif model == 'inv': 108 print("Three parameter inversion recovery fit.") 109 params = ['rx', 'i0', 'iinf'] 110 111 # Invalid model. 112 else: 113 raise RelaxError("The model '" + model + "' is invalid.") 114 115 # Set up the model. 116 model_setup(model, params)
117