1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the base class for the automatic NOE analysis frames."""
25
26
27 from os import sep
28 import wx
29
30
31 from auto_analyses.noe import NOE_calc
32 from data_store import Relax_data_store; ds = Relax_data_store()
33 from graphics import ANALYSIS_IMAGE_PATH, IMAGE_PATH, fetch_icon
34 from gui.analyses.base import Base_analysis
35 from gui.analyses.elements.text_element import Text_ctrl
36 from gui.analyses.execute import Execute
37 from gui.analyses.results_analysis import color_code_noe
38 from gui.base_classes import Container
39 from gui.components.spectrum import Spectra_list
40 from gui.filedialog import RelaxDirDialog
41 from gui.message import error_message, Missing_data
42 from gui.string_conv import gui_to_str, str_to_gui
43 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
44 from gui.wizards.peak_intensity import Peak_intensity_wizard
45 from pipe_control.mol_res_spin import exists_mol_res_spin_data
46 from pipe_control.pipes import has_bundle, has_pipe
47 from status import Status; status = Status()
48
49
51 """The base class for the noe frames."""
52
53
54 analysis_type = None
55 bitmap = [ANALYSIS_IMAGE_PATH+"noe_200x200.png",
56 IMAGE_PATH+'noe.png']
57 label = None
58
59 - def __init__(self, parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=524288, name='scrolledpanel', gui=None, analysis_name=None, pipe_name=None, pipe_bundle=None, uf_exec=[], data_index=None):
60 """Build the automatic NOE analysis GUI frame elements.
61
62 @param parent: The parent wx element.
63 @type parent: wx object
64 @keyword id: The unique ID number.
65 @type id: int
66 @keyword pos: The position.
67 @type pos: wx.Size object
68 @keyword size: The size.
69 @type size: wx.Size object
70 @keyword style: The style.
71 @type style: int
72 @keyword name: The name for the panel.
73 @type name: unicode
74 @keyword gui: The main GUI class.
75 @type gui: gui.relax_gui.Main instance
76 @keyword analysis_name: The name of the analysis (the name in the tab part of the notebook).
77 @type analysis_name: str
78 @keyword pipe_name: The name of the data pipe associated with this analysis.
79 @type pipe_name: str
80 @keyword pipe_bundle: The name of the data pipe bundle associated with this analysis.
81 @type pipe_bundle: str
82 @keyword uf_exec: The list of user function on_execute methods returned from the new analysis wizard.
83 @type uf_exec: list of methods
84 @keyword data_index: The index of the analysis in the relax data store (set to None if no data currently exists).
85 @type data_index: None or int
86 """
87
88
89 self.gui = gui
90
91
92 self.init_flag = True
93
94
95 if data_index == None:
96
97 if not has_pipe(pipe_name):
98 self.gui.interpreter.apply('pipe.create', pipe_name=pipe_name, pipe_type='noe', bundle=pipe_bundle)
99
100
101 if not has_bundle(pipe_bundle):
102 self.gui.interpreter.apply('pipe.bundle', bundle=pipe_bundle, pipe=pipe_name)
103
104
105 data_index = ds.relax_gui.analyses.add('NOE')
106
107
108 ds.relax_gui.analyses[data_index].analysis_name = analysis_name
109 ds.relax_gui.analyses[data_index].pipe_name = pipe_name
110 ds.relax_gui.analyses[data_index].pipe_bundle = pipe_bundle
111
112
113 ds.relax_gui.analyses[data_index].frq = ''
114 ds.relax_gui.analyses[data_index].save_dir = self.gui.system_cwd_path
115
116
117 self.data = ds.relax_gui.analyses[data_index]
118 self.data_index = data_index
119
120
121 self.observer_register()
122
123
124 super(Auto_noe, self).__init__(parent, id=id, pos=pos, size=size, style=style, name=name)
125
126
141
142
144 """Assemble the data required for the Auto_noe class.
145
146 @return: A container with all the data required for the auto-analysis.
147 @rtype: class instance, list of str
148 """
149
150
151 data = Container()
152 missing = []
153
154
155 data.pipe_name = self.data.pipe_name
156 data.pipe_bundle = self.data.pipe_bundle
157
158
159 frq = gui_to_str(self.field_nmr_frq.GetValue())
160 if frq == None:
161 missing.append('NMR frequency')
162
163
164 data.file_root = 'noe.%s' % frq
165
166
167 data.save_dir = self.data.save_dir
168
169
170 if not exists_mol_res_spin_data():
171 missing.append("Sequence data")
172
173
174 if not hasattr(cdp, 'spectrum_ids') or len(cdp.spectrum_ids) < 2:
175 missing.append("Spectral data")
176
177
178 return data, missing
179
180
182 """Construct the right hand box to pack into the main NOE box.
183
184 @return: The right hand box element containing all NOE GUI elements (excluding the bitmap) to pack into the main Rx box.
185 @rtype: wx.BoxSizer instance
186 """
187
188
189 box = wx.BoxSizer(wx.VERTICAL)
190
191
192 self.add_title(box, "Steady-state NOE analysis")
193
194
195 Text_ctrl(box, self, text="The data pipe bundle:", default=self.data.pipe_bundle, tooltip="This is the data pipe bundle associated with this analysis.", editable=False, width_text=self.width_text, width_button=self.width_button, spacer=self.spacer_horizontal)
196
197
198 self.field_nmr_frq = Text_ctrl(box, self, text="NMR frequency label [MHz]:", default=self.data.frq, tooltip="This label is added to the output files. For example if the label is '600', the NOE values will be located in the file 'noe.600.out'.", width_text=self.width_text, width_button=self.width_button, spacer=self.spacer_horizontal)
199
200
201 self.field_results_dir = Text_ctrl(box, self, text="Results directory:", icon=fetch_icon('oxygen.actions.document-open-folder', "16x16"), default=self.data.save_dir, tooltip="The directory in which all automatically created files will be saved.", tooltip_button="Select the results directory.", fn=self.results_directory, button=True, width_text=self.width_text, width_button=self.width_button, spacer=self.spacer_horizontal)
202
203
204 self.add_spin_systems(box, self)
205
206
207 box.AddSpacer(40)
208 self.peak_intensity = Spectra_list(gui=self.gui, parent=self, box=box, id=str(self.data_index), fn_add=self.peak_wizard_launch, noe_flag=True)
209
210
211 box.AddSpacer(30)
212 box.AddStretchSpacer()
213
214
215 self.button_exec_relax = self.add_execute_analysis(box, self.execute)
216
217
218 return box
219
220
222 """Unregister the spin count from the user functions."""
223
224
225 self.observer_register(remove=True)
226
227
228 self.peak_intensity.delete()
229
230
231 if hasattr(self, 'peak_wizard'):
232 self.peak_wizard.Destroy()
233 del self.peak_wizard
234
235
236 if hasattr(self, 'missing_data'):
237 self.missing_data.Destroy()
238 del self.missing_data
239
240
281
282
303
304
306 """Launch the peak loading wizard.
307
308 @param event: The wx event.
309 @type event: wx event
310 """
311
312
313 if hasattr(self, 'peak_wizard'):
314 self.peak_wizard.Destroy()
315
316
317 self.peak_wizard = Peak_intensity_wizard(noe=True)
318
319
321 """The results directory selection.
322
323 @param event: The wx event.
324 @type event: wx event
325 """
326
327
328 dialog = RelaxDirDialog(parent=self, message='Select the results directory', defaultPath=self.field_results_dir.GetValue())
329
330
331 if status.show_gui and dialog.ShowModal() != wx.ID_OK:
332
333 return
334
335
336 path = gui_to_str(dialog.get_path())
337 if not path:
338 return
339
340
341 self.data.save_dir = path
342
343
344 self.field_results_dir.SetValue(str_to_gui(path))
345
346
348 """Synchronise the noe analysis frame and the relax data store, both ways.
349
350 This method allows the frame information to be uploaded into the relax data store, or for the information in the relax data store to be downloaded by the frame.
351
352 @keyword upload: A flag which if True will cause the frame to send data to the relax data store. If False, data will be downloaded from the relax data store to update the frame.
353 @type upload: bool
354 """
355
356
357 if upload:
358 self.data.frq = gui_to_str(self.field_nmr_frq.GetValue())
359 else:
360 self.field_nmr_frq.SetValue(str_to_gui(self.data.frq))
361
362
363 if upload:
364 self.data.save_dir = gui_to_str(self.field_results_dir.GetValue())
365 else:
366 self.field_results_dir.SetValue(str_to_gui(self.data.save_dir))
367
368
369
370
372 """The NOE analysis execution object."""
373
392