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

Source Code for Module auto_analyses.noe

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-2014 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 pipe_control.pipes import cdp_name, has_pipe, switch 
 31  from prompt.interpreter import Interpreter 
 32  from status import Status; status = Status() 
 33   
 34   
 35   
36 -class NOE_calc:
37 - def __init__(self, pipe_name=None, pipe_bundle=None, file_root='noe', results_dir=None, save_state=True):
38 """Perform relaxation curve fitting. 39 40 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: 41 42 - All the spins loaded. 43 - Unresolved spins deselected. 44 - The NOE peak intensities from the saturated and reference spectra. 45 - Either the baseplane noise RMDS values should be set or replicated spectra loaded. 46 47 @keyword pipe_name: The name of the data pipe containing all of the data for the analysis. 48 @type pipe_name: str 49 @keyword pipe_bundle: The data pipe bundle to associate all spawned data pipes with. 50 @type pipe_bundle: str 51 @keyword file_root: File root of the output filea. 52 @type file_root: str 53 @keyword results_dir: The directory where results files are saved. 54 @type results_dir: str 55 @keyword save_state: A flag which if True will cause a relax save state to be created at the end of the analysis. 56 @type save_state: bool 57 """ 58 59 # Execution lock. 60 status.exec_lock.acquire(pipe_bundle, mode='auto-analysis') 61 62 # Set up the analysis status object. 63 status.init_auto_analysis(pipe_bundle, type='noe') 64 status.current_analysis = pipe_bundle 65 66 # Store the args. 67 self.save_state = save_state 68 self.pipe_name = pipe_name 69 self.pipe_bundle = pipe_bundle 70 self.file_root = file_root 71 self.results_dir = results_dir 72 if self.results_dir: 73 self.grace_dir = results_dir + sep + 'grace' 74 else: 75 self.grace_dir = 'grace' 76 77 # Data checks. 78 self.check_vars() 79 80 # Set the data pipe to the current data pipe. 81 if self.pipe_name != cdp_name(): 82 switch(self.pipe_name) 83 84 # Load the interpreter. 85 self.interpreter = Interpreter(show_script=False, raise_relax_error=True) 86 self.interpreter.populate_self() 87 self.interpreter.on(verbose=False) 88 89 # Execute. 90 self.run() 91 92 # Finish and unlock execution. 93 status.auto_analysis[self.pipe_bundle].fin = True 94 status.current_analysis = None 95 status.exec_lock.release()
96 97
98 - def run(self):
99 """Set up and run the NOE analysis.""" 100 101 # Peak intensity error analysis. 102 self.interpreter.spectrum.error_analysis() 103 104 # Calculate the NOEs. 105 self.interpreter.calc() 106 107 # Save the NOEs. 108 self.interpreter.value.write(param='noe', file=self.file_root+'.out', dir=self.results_dir, force=True) 109 110 # Save the results. 111 self.interpreter.results.write(file='results', dir=self.results_dir, force=True) 112 113 # Create Grace plots of the data. 114 self.interpreter.grace.write(y_data_type='peak_intensity', file='intensities.agr', dir=self.grace_dir, force=True) 115 self.interpreter.grace.write(y_data_type='noe', file='noe.agr', dir=self.grace_dir, force=True) 116 117 # Save the program state. 118 if self.save_state: 119 self.interpreter.state.save(state=self.file_root+'.save', dir=self.results_dir, force=True)
120 121
122 - def check_vars(self):
123 """Check that the user has set the variables correctly.""" 124 125 # The pipe name. 126 if not has_pipe(self.pipe_name): 127 raise RelaxNoPipeError(self.pipe_name)
128