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