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