Package auto_analyses :: Module noe
[hide private]
[frames] | no frames]

Source Code for Module auto_analyses.noe

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-2011 Edward d'Auvergne                                   # 
  4  # Copyright (C) 2010 Michael Bieri                                            # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """The automatic relaxation curve fitting protocol.""" 
 25   
 26  # Python module imports. 
 27  from os import sep 
 28   
 29  # relax module imports. 
 30  from generic_fns.pipes import cdp_name, has_pipe, switch 
 31  import generic_fns.structure.main 
 32  from prompt.interpreter import Interpreter 
 33  from status import Status; status = Status() 
 34   
 35   
 36   
37 -class NOE_calc:
38 - def __init__(self, pipe_name=None, pipe_bundle=None, file_root='noe', results_dir=None, save_state=True):
39 """Perform relaxation curve fitting. 40 41 To use this auto-analysis, a data pipe with all the required data needs to be set up. This data pipe should contain the following: 42 43 - All the spins loaded. 44 - Unresolved spins deselected. 45 - The NOE peak intensities from the saturated and reference spectra. 46 - Either the baseplane noise RMDS values should be set or replicated spectra loaded. 47 48 @keyword pipe_name: The name of the data pipe containing all of the data for the analysis. 49 @type pipe_name: str 50 @keyword pipe_bundle: The data pipe bundle to associate all spawned data pipes with. 51 @type pipe_bundle: str 52 @keyword file_root: File root of the output filea. 53 @type file_root: str 54 @keyword results_dir: The directory where results files are saved. 55 @type results_dir: str 56 @keyword save_state: A flag which if True will cause a relax save state to be created at the end of the analysis. 57 @type save_state: bool 58 """ 59 60 # Execution lock. 61 status.exec_lock.acquire(pipe_bundle, mode='auto-analysis') 62 63 # Set up the analysis status object. 64 status.init_auto_analysis(pipe_bundle, type='noe') 65 status.current_analysis = pipe_bundle 66 67 # Store the args. 68 self.save_state = save_state 69 self.pipe_name = pipe_name 70 self.pipe_bundle = pipe_bundle 71 self.file_root = file_root 72 self.results_dir = results_dir 73 if self.results_dir: 74 self.grace_dir = results_dir + sep + 'grace' 75 else: 76 self.grace_dir = 'grace' 77 78 # Data checks. 79 self.check_vars() 80 81 # Set the data pipe to the current data pipe. 82 if self.pipe_name != cdp_name(): 83 switch(self.pipe_name) 84 85 # Load the interpreter. 86 self.interpreter = Interpreter(show_script=False, quit=False, raise_relax_error=True) 87 self.interpreter.populate_self() 88 self.interpreter.on(verbose=False) 89 90 # Execute. 91 self.run() 92 93 # Finish and unlock execution. 94 status.auto_analysis[self.pipe_bundle].fin = True 95 status.current_analysis = None 96 status.exec_lock.release()
97 98
99 - def run(self):
100 """Set up and run the NOE analysis.""" 101 102 # Peak intensity error analysis. 103 self.interpreter.spectrum.error_analysis() 104 105 # Calculate the NOEs. 106 self.interpreter.calc() 107 108 # Save the NOEs. 109 self.interpreter.value.write(param='noe', file=self.file_root+'.out', dir=self.results_dir, force=True) 110 111 # Save the results. 112 self.interpreter.results.write(file='results', dir=self.results_dir, force=True) 113 114 # Create Grace plots of the data. 115 self.interpreter.grace.write(y_data_type='ref', file='ref.agr', dir=self.grace_dir, force=True) 116 self.interpreter.grace.write(y_data_type='sat', file='sat.agr', dir=self.grace_dir, force=True) 117 self.interpreter.grace.write(y_data_type='noe', file='noe.agr', dir=self.grace_dir, force=True) 118 119 # Save the program state. 120 if self.save_state: 121 self.interpreter.state.save(state=self.file_root+'.save', dir=self.results_dir, force=True)
122 123
124 - def check_vars(self):
125 """Check that the user has set the variables correctly.""" 126 127 # The pipe name. 128 if not has_pipe(self.pipe_name): 129 raise RelaxNoPipeError(self.pipe_name)
130