Package pipe_control :: Module fix
[hide private]
[frames] | no frames]

Source Code for Module pipe_control.fix

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2003-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 holding certain model components fixed during optimisation.""" 
24   
25  # relax module imports. 
26  from lib.errors import RelaxError, RelaxNoSequenceError, RelaxNoTensorError 
27  from pipe_control import pipes 
28  from pipe_control.mol_res_spin import exists_mol_res_spin_data, spin_loop 
29   
30   
31 -def fix(element, fixed):
32 """Fix or allow certain model components values to vary during optimisation. 33 34 @param element: The model component to fix or unfix. If set to 'diff', then the diffusion 35 parameters can be toggled. If set to 'all_spins', then all spins can be 36 toggled. If set to 'all', then all model components are toggled. 37 @type element: str. 38 """ 39 40 # Test if the current data pipe exists. 41 pipes.test() 42 43 # Diffusion tensor. 44 if element == 'diff' or element == 'all': 45 # Test if the diffusion tensor data is loaded. 46 if not hasattr(cdp, 'diff_tensor'): 47 raise RelaxNoTensorError('diffusion') 48 49 # Set the fixed flag. 50 cdp.diff_tensor.set_fixed(fixed) 51 52 # All spins. 53 if element == 'all_spins' or element == 'all': 54 # Test if sequence data exists. 55 if not exists_mol_res_spin_data(): 56 raise RelaxNoSequenceError 57 58 # Loop over the sequence and set the fixed flag. 59 for spin in spin_loop(): 60 # Skip deselected spins. 61 if not spin.select: 62 continue 63 64 # Set the flag. 65 spin.fixed = fixed 66 67 68 # Unknown. 69 if element not in ['diff', 'all_spins', 'all']: 70 raise RelaxError("The 'element' argument " + repr(element) + " is unknown.")
71