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 spectrum user function GUI elements."""
25
26
27 from os import sep
28 import wx
29
30
31 from base import UF_base, UF_page
32 from gui.misc import gui_to_float, gui_to_int, gui_to_str, str_to_gui
33 from gui.paths import WIZARD_IMAGE_PATH
34
35
36
38 """The container class for holding all GUI elements."""
39
46
47
48 - def delete(self, spectrum_id=None):
49 """The spectrum.delete user function.
50
51 @keyword spectrum_id: The starting spectrum ID string.
52 @type spectrum_id: str
53 """
54
55
56 wizard, page = self.create_wizard(size_x=700, size_y=400, name='spectrum.delete', uf_page=Delete_page, return_page=True)
57
58
59 if spectrum_id:
60 page.spectrum_id.SetValue(str_to_gui(spectrum_id))
61
62
63 wizard.run()
64
65
72
73
80
81
88
89
96
97
98
100 """The spectrum.baseplane_rmsd() user function page."""
101
102
103 image_path = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png'
104 uf_path = ['spectrum', 'baseplane_rmsd']
105
106 - def add_contents(self, sizer):
107 """Add the specific GUI elements.
108
109 @param sizer: A sizer object.
110 @type sizer: wx.Sizer instance
111 """
112
113
114 self.error = self.input_field(sizer, "The error:", tooltip=self.uf._doc_args_dict['error'])
115
116
117 self.spectrum_id = self.combo_box(sizer, "The spectrum ID:", tooltip=self.uf._doc_args_dict['spectrum_id'])
118
119
120 self.spin_id = self.spin_id_element(sizer, desc="Restrict the error setting to certain spins:")
121
122
123 - def on_display(self):
124 """Update the UI."""
125
126
127 self.spectrum_id.Clear()
128
129
130 if hasattr(cdp, 'spectrum_ids'):
131 for id in cdp.spectrum_ids:
132 self.spectrum_id.Append(str_to_gui(id))
133
134
135 - def on_execute(self):
136 """Execute the user function."""
137
138
139 error = gui_to_float(self.error.GetValue())
140 spectrum_id = gui_to_str(self.spectrum_id.GetValue())
141 spin_id = gui_to_str(self.spin_id.GetValue())
142
143
144 self.execute('spectrum.baseplane_rmsd', error=error, spectrum_id=spectrum_id, spin_id=spin_id)
145
146
147
148 -class Delete_page(UF_page):
149 """The spectrum.read() user function page."""
150
151
152 image_path = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png'
153 uf_path = ['spectrum', 'delete']
154
155 - def add_contents(self, sizer):
156 """Add the spectral data deletion specific GUI elements.
157
158 @param sizer: A sizer object.
159 @type sizer: wx.Sizer instance
160 """
161
162
163 self.spectrum_id = self.combo_box(sizer, "The spectrum ID:", tooltip=self.uf._doc_args_dict['spectrum_id'])
164
165
166 - def on_execute(self):
167 """Execute the user function."""
168
169
170 spectrum_id = gui_to_str(self.spectrum_id.GetValue())
171
172
173 self.execute('spectrum.delete', spectrum_id=spectrum_id)
174
175
176 - def on_display(self):
177 """Clear previous data and update the label lists."""
178
179
180 self.spectrum_id.Clear()
181
182
183 if not hasattr(cdp, 'spectrum_ids'):
184 return
185
186
187 for i in range(len(cdp.spectrum_ids)):
188 self.spectrum_id.Append(str_to_gui(cdp.spectrum_ids[i]))
189
190
191
192 -class Error_analysis_page(UF_page):
193 """The spectrum.error_analysis() user function page."""
194
195
196 image_path = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png'
197 uf_path = ['spectrum', 'error_analysis']
198 height_desc = 550
199
200 - def add_contents(self, sizer):
201 """Add the specific GUI elements.
202
203 @param sizer: A sizer object.
204 @type sizer: wx.Sizer instance
205 """
206
207 - def on_execute(self):
208 """Execute the user function."""
209
210
211 self.execute('spectrum.error_analysis')
212
213
214
216 """The spectrum.integration_points() user function page."""
217
218
219 image_path = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png'
220 uf_path = ['spectrum', 'integration_points']
221
222 - def add_contents(self, sizer):
223 """Add the specific GUI elements.
224
225 @param sizer: A sizer object.
226 @type sizer: wx.Sizer instance
227 """
228
229
230 self.N = self.input_field(sizer, "The number of points:", tooltip=self.uf._doc_args_dict['N'])
231
232
233 self.spectrum_id = self.combo_box(sizer, "The spectrum ID:", tooltip=self.uf._doc_args_dict['spectrum_id'])
234
235
236 self.spin_id = self.spin_id_element(sizer, desc="Restrict setting the number to certain spins:")
237
238
239 - def on_display(self):
240 """Update the UI."""
241
242
243 self.spectrum_id.Clear()
244
245
246 if hasattr(cdp, 'spectrum_ids'):
247 for id in cdp.spectrum_ids:
248 self.spectrum_id.Append(str_to_gui(id))
249
250
251 - def on_execute(self):
252 """Execute the user function."""
253
254
255 N = gui_to_int(self.N.GetValue())
256 spectrum_id = gui_to_str(self.spectrum_id.GetValue())
257 spin_id = gui_to_str(self.spin_id.GetValue())
258
259
260 self.execute('spectrum.integration_points', N=N, spectrum_id=spectrum_id, spin_id=spin_id)
261
262
263
265 """The spectrum.read_intensities() user function page."""
266
267
268 height_desc = 140
269 image_path = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png'
270 uf_path = ['spectrum', 'read_intensities']
271
272 - def add_contents(self, sizer):
273 """Add the specific GUI elements.
274
275 @param sizer: A sizer object.
276 @type sizer: wx.Sizer instance
277 """
278
279
280 self.file = self.file_selection(sizer, "The peak intensity file:", message="Peak intensity file selection", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'], preview=True)
281
282
283 self.spectrum_id = self.input_field(sizer, "The spectrum ID:", tooltip=self.uf._doc_args_dict['spectrum_id'])
284
285
286 self.heteronuc = self.input_field(sizer, "The heternucleus name:", tooltip=self.uf._doc_args_dict['heteronuc'])
287 self.proton = self.input_field(sizer, "The heternucleus name:", tooltip=self.uf._doc_args_dict['proton'])
288 self.heteronuc.SetValue(str_to_gui('N'))
289 self.proton.SetValue(str_to_gui('H'))
290
291
292 self.int_method = self.combo_box(sizer, "The peak integration method:", tooltip=self.uf._doc_args_dict['int_method'], choices=['height', 'point sum', 'other'])
293 self.int_method.SetValue(str_to_gui('height'))
294
295
296 self.int_col = self.input_field(sizer, "The integration column:", tooltip=self.uf._doc_args_dict['int_col'])
297
298
299 self.spin_id = self.spin_id_element(sizer, desc="Restrict data loading to certain spins:")
300
301
302 self.ncproc = self.input_field(sizer, "The Bruker ncproc value:", tooltip=self.uf._doc_args_dict['ncproc'])
303
304
305 self.free_file_format(sizer, data_cols=False, padding=3, spacer=0)
306
307
308 - def on_execute(self):
309 """Execute the user function."""
310
311
312 file = gui_to_str(self.file.GetValue())
313
314
315 spectrum_id = gui_to_str(self.spectrum_id.GetValue())
316 heteronuc = gui_to_str(self.heteronuc.GetValue())
317 proton = gui_to_str(self.proton.GetValue())
318 int_method = gui_to_str(self.int_method.GetValue())
319 ncproc = gui_to_int(self.ncproc.GetValue())
320
321
322 int_col = gui_to_int(self.int_col.GetValue())
323 spin_id_col = gui_to_int(self.spin_id_col.GetValue())
324 mol_name_col = gui_to_int(self.mol_name_col.GetValue())
325 res_num_col = gui_to_int(self.res_num_col.GetValue())
326 res_name_col = gui_to_int(self.res_name_col.GetValue())
327 spin_num_col = gui_to_int(self.spin_num_col.GetValue())
328 spin_name_col = gui_to_int(self.spin_name_col.GetValue())
329
330
331 sep = gui_to_str(self.sep.GetValue())
332 if sep == 'white space':
333 sep = None
334
335
336 spin_id = gui_to_str(self.spin_id.GetValue())
337
338
339 self.execute('spectrum.read_intensities', file=file, spectrum_id=spectrum_id, heteronuc=heteronuc, proton=proton, int_method=int_method, int_col=int_col, spin_id_col=spin_id_col, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col, sep=sep, spin_id=spin_id, ncproc=ncproc)
340
341
342
343 -class Replicated_page(UF_page):
344 """The spectrum.replicated() user function page."""
345
346
347 image_path = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png'
348 uf_path = ['spectrum', 'replicated']
349
350 - def add_contents(self, sizer):
351 """Add the specific GUI elements.
352
353 @param sizer: A sizer object.
354 @type sizer: wx.Sizer instance
355 """
356
357
358 self.spectrum_id_boxes = []
359 self.spectrum_id_boxes.append(self.combo_box(sizer, "The 1st spectrum ID:", tooltip="The ID string of the first of the replicated spectra."))
360 self.spectrum_id_boxes.append(self.combo_box(sizer, "The 2nd spectrum ID:", tooltip="The ID string of the second spectrum which is a replicate of the first spectrum."))
361 self.spectrum_id_boxes.append(self.combo_box(sizer, "The 3rd spectrum ID:", tooltip="The ID string of the third spectrum which is a replicate of the first spectrum."))
362 self.spectrum_id_boxes.append(self.combo_box(sizer, "The 4th spectrum ID:", tooltip="The ID string of the fourth spectrum which is a replicate of the first spectrum."))
363 self.spectrum_id_boxes.append(self.combo_box(sizer, "The 5th spectrum ID:", tooltip="The ID string of the fifth spectrum which is a replicate of the first spectrum."))
364
365
366 - def on_display(self):
367 """Update the UI."""
368
369
370 for i in range(len(self.spectrum_id_boxes)):
371
372 self.spectrum_id_boxes[i].Clear()
373
374
375 if hasattr(cdp, 'spectrum_ids'):
376 for id in cdp.spectrum_ids:
377 self.spectrum_id_boxes[i].Append(str_to_gui(id))
378
379
380 - def on_execute(self):
381 """Execute the user function."""
382
383
384 spectrum_ids = []
385 for i in range(len(self.spectrum_id_boxes)):
386
387 if self.spectrum_id_boxes[i].GetSelection() == -1:
388 continue
389
390
391 val = gui_to_str(self.spectrum_id_boxes[i].GetValue())
392
393
394 if val != None:
395 spectrum_ids.append(val)
396
397
398 if len(spectrum_ids) > 1:
399 self.execute('spectrum.replicated', spectrum_ids=spectrum_ids)
400