1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 """The automatic relaxation curve fitting protocol."""
26
27
28 from os import sep
29
30
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
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
62 status.exec_lock.acquire(pipe_bundle, mode='auto-analysis')
63
64
65 status.init_auto_analysis(pipe_bundle, type='noe')
66 status.current_analysis = pipe_bundle
67
68
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
80 self.check_vars()
81
82
83 if self.pipe_name != cdp_name():
84 switch(self.pipe_name)
85
86
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
92 self.run()
93
94
95 status.auto_analysis[self.pipe_bundle].fin = True
96 status.current_analysis = None
97 status.exec_lock.release()
98
99
101 """Set up and run the NOE analysis."""
102
103
104 self.interpreter.spectrum.error_analysis()
105
106
107 self.interpreter.calc()
108
109
110 self.interpreter.value.write(param='noe', file=self.file_root+'.out', dir=self.results_dir, force=True)
111
112
113 self.interpreter.results.write(file='results', dir=self.results_dir, force=True)
114
115
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
121 if self.save_state:
122 self.interpreter.state.save(state=self.file_root+'.save', dir=self.results_dir, force=True)
123
124
126 """Check that the user has set the variables correctly."""
127
128
129 if not has_pipe(self.pipe_name):
130 raise RelaxNoPipeError(self.pipe_name)
131