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

Source Code for Module generic_fns.fix

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2003-2004, 2007-2009 Edward d'Auvergne                        # 
 4  #                                                                             # 
 5  # This file is part of the program relax.                                     # 
 6  #                                                                             # 
 7  # relax 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 2 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # relax 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 relax; if not, write to the Free Software                        # 
19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # Module docstring. 
24  """Module for holding certain model components fixed during optimisation.""" 
25   
26  # relax module imports. 
27  from generic_fns import pipes 
28  from generic_fns.mol_res_spin import exists_mol_res_spin_data, spin_loop 
29  from relax_errors import RelaxError, RelaxNoSequenceError, RelaxNoTensorError 
30   
31   
32 -def fix(element, fixed):
33 """Fix or allow certain model components values to vary during optimisation. 34 35 @param element: The model component to fix or unfix. If set to 'diff', then the diffusion 36 parameters can be toggled. If set to 'all_spins', then all spins can be 37 toggled. If set to 'all', then all model components are toggled. 38 @type element: str. 39 """ 40 41 # Test if the current data pipe exists. 42 pipes.test() 43 44 # Diffusion tensor. 45 if element == 'diff' or element == 'all': 46 # Test if the diffusion tensor data is loaded. 47 if not hasattr(cdp, 'diff_tensor'): 48 raise RelaxNoTensorError('diffusion') 49 50 # Set the fixed flag. 51 cdp.diff_tensor.fixed = fixed 52 53 54 # All spins. 55 if element == 'all_spins' or element == 'all': 56 # Test if sequence data exists. 57 if not exists_mol_res_spin_data(): 58 raise RelaxNoSequenceError 59 60 # Loop over the sequence and set the fixed flag. 61 for spin in spin_loop(): 62 # Skip deselected spins. 63 if not spin.select: 64 continue 65 66 # Set the flag. 67 spin.fixed = fixed 68 69 70 # Unknown. 71 if element not in ['diff', 'all_spins', 'all']: 72 raise RelaxError("The 'element' argument " + repr(element) + " is unknown.")
73