1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The automatic relaxation curve fitting protocol."""
24
25
26 from os import sep
27 import sys
28 from time import time
29
30
31 from lib.io import get_file_path, open_write_file
32 from lib.plotting.grace import create_grace2images
33 from lib.text.sectioning import title
34 from lib.timing import print_elapsed_time
35 from pipe_control.pipes import cdp_name, has_pipe, switch
36 from prompt.interpreter import Interpreter
37 from status import Status; status = Status()
38
39
40
42 - def __init__(self, pipe_name=None, pipe_bundle=None, file_root='noe', results_dir=None, save_state=True):
43 """Perform relaxation curve fitting.
44
45 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:
46
47 - All the spins loaded.
48 - Unresolved spins deselected.
49 - The NOE peak intensities from the saturated and reference spectra.
50 - Either the baseplane noise RMSD values should be set or replicated spectra loaded.
51
52 @keyword pipe_name: The name of the data pipe containing all of the data for the analysis.
53 @type pipe_name: str
54 @keyword pipe_bundle: The data pipe bundle to associate all spawned data pipes with.
55 @type pipe_bundle: str
56 @keyword file_root: File root of the output filea.
57 @type file_root: str
58 @keyword results_dir: The directory where results files are saved.
59 @type results_dir: str
60 @keyword save_state: A flag which if True will cause a relax save state to be created at the end of the analysis.
61 @type save_state: bool
62 """
63
64
65 title(file=sys.stdout, text="Steady-state NOE auto-analysis")
66
67
68 try:
69
70 status.exec_lock.acquire(pipe_bundle, mode='auto-analysis')
71
72
73 status.init_auto_analysis(pipe_bundle, type='noe')
74 status.current_analysis = pipe_bundle
75
76
77 self.save_state = save_state
78 self.pipe_name = pipe_name
79 self.pipe_bundle = pipe_bundle
80 self.file_root = file_root
81 self.results_dir = results_dir
82 if self.results_dir:
83 self.grace_dir = results_dir + sep + 'grace'
84 else:
85 self.grace_dir = 'grace'
86
87
88 self.check_vars()
89
90
91 if self.pipe_name != cdp_name():
92 switch(self.pipe_name)
93
94
95 self.interpreter = Interpreter(show_script=False, raise_relax_error=True)
96 self.interpreter.populate_self()
97 self.interpreter.on(verbose=False)
98
99
100 self.run()
101
102
103 finally:
104
105 title(file=sys.stdout, text="Completion of the steady-state NOE auto-analysis")
106 print_elapsed_time(time() - status.start_time)
107
108
109 status.auto_analysis[self.pipe_bundle].fin = True
110 status.current_analysis = None
111 status.exec_lock.release()
112
113
115 """Set up and run the NOE analysis."""
116
117
118 self.interpreter.spectrum.error_analysis()
119
120
121 self.interpreter.minimise.calculate()
122
123
124 self.interpreter.value.write(param='noe', file=self.file_root+'.out', dir=self.results_dir, force=True)
125
126
127 self.interpreter.results.write(file='results', dir=self.results_dir, force=True)
128
129
130 self.interpreter.grace.write(y_data_type='peak_intensity', file='intensities.agr', dir=self.grace_dir, force=True)
131 self.interpreter.grace.write(y_data_type='noe', file='noe.agr', dir=self.grace_dir, force=True)
132
133
134 create_grace2images(dir=self.grace_dir)
135
136
137 if self.save_state:
138 self.interpreter.state.save(state='state', dir=self.results_dir, force=True)
139
140
142 """Check that the user has set the variables correctly."""
143
144
145 if not has_pipe(self.pipe_name):
146 raise RelaxNoPipeError(self.pipe_name)
147