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 BMRB export wizard."""
25
26
27 import wx
28
29
30 from generic_fns.mol_res_spin import molecule_loop
31 from generic_fns.pipes import cdp_name, pipe_names, switch
32 from graphics import IMAGE_PATH, fetch_icon
33 from status import Status; status = Status()
34
35
36 from gui.components.citations import Citations
37 from gui.components.molecule import Molecule
38 from gui.components.relax_data_meta import Relax_data_meta_list
39 from gui.components.scripts import Scripts
40 from gui.components.software import Software
41 from gui.message import Missing_data
42 from gui.fonts import font
43 from gui.icons import relax_icons
44 from gui.input_elements.value import Value
45 from gui.misc import add_border
46 from gui.string_conv import gui_to_str, str_to_gui
47 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
48
49
51 """The BMRB export window."""
52
54 """Set up the export window.
55
56 @param gui: The GUI object.
57 @type gui: wx.Frame instance
58 """
59
60
61 style = wx.DEFAULT_FRAME_STYLE
62 if not status.debug and status.wx_info["os"] != 'darwin':
63 style = style | wx.MAXIMIZE
64
65
66 super(Export_bmrb_window, self).__init__(gui, -1, style=style)
67
68
69 self.size = (1200, 900)
70 self.size_min = (900, 700)
71 self.border = 5
72 self.spacer = 10
73 self.button_size = (200, 40)
74 self.button_spacing = 10
75 self.main_spacing = 20
76
77
78 sizer = self.setup_frame()
79
80
81 self.add_header(sizer)
82
83
84 sizer.AddSpacer(10)
85
86
87 self.add_pipe(sizer)
88
89
90 sizer.AddSpacer(self.main_spacing)
91
92
93 self.relax_data = Relax_data_meta_list(parent=self.main_panel, box=sizer, id='BMRB export', proportion=2)
94
95
96 sizer.AddSpacer(self.main_spacing)
97
98
99 self.molecule = Molecule(parent=self.main_panel, box=sizer, id='BMRB export', proportion=1)
100
101
102 sizer.AddSpacer(self.main_spacing)
103
104
105 sub_sizer = wx.BoxSizer(wx.HORIZONTAL)
106
107
108 self.software = Software(parent=self.main_panel, box=sub_sizer, id='BMRB export', proportion=1)
109
110
111 sub_sizer.AddSpacer(self.main_spacing)
112
113
114 self.scripts = Scripts(parent=self.main_panel, box=sub_sizer, id='BMRB export', proportion=1)
115
116
117 sub_sizer.AddSpacer(self.main_spacing)
118
119
120 self.citation = Citations(parent=self.main_panel, box=sub_sizer, id='BMRB export', proportion=1)
121
122
123 sizer.Add(sub_sizer, 2, wx.ALL|wx.EXPAND, 0)
124
125
126 sizer.AddSpacer(10)
127
128
129 self.add_buttons(sizer)
130
131
132 if status.show_gui:
133 self.Show()
134
135
137 """Cancel the export.
138
139 @keyword event: The wx event.
140 @type event: wx event
141 """
142
143
144 self.Close()
145
146
148 """Write out the NMR-STAR formatted data.
149
150 @keyword event: The wx event.
151 @type event: wx event
152 """
153
154
155 missing = self.is_complete()
156
157
158 if len(missing):
159 Missing_data(missing, parent=self)
160 return
161
162
163 uf_store['bmrb.write'](wx_parent=self, wx_wizard_sync=True, wx_wizard_modal=True)
164
165
166 self.Close()
167
168
170 """Preview the NMR-STAR formatted data.
171
172 @keyword event: The wx event.
173 @type event: wx event
174 """
175
176
177 uf_store['bmrb.display'](wx_parent=self)
178
179
223
224
226 """Build and add the header to the sizer.
227
228 @param sizer: The sizer element to pack the header into.
229 @type sizer: wx.Sizer instance
230 """
231
232
233 sub_sizer = wx.BoxSizer(wx.HORIZONTAL)
234
235
236 sub_sizer.AddStretchSpacer(3)
237
238
239 logo = wx.StaticBitmap(self.main_panel, -1, wx.Bitmap(IMAGE_PATH+"bmrb_100x100.png", wx.BITMAP_TYPE_ANY))
240 sub_sizer.Add(logo, 0, wx.TOP|wx.ALIGN_CENTER_HORIZONTAL, 0)
241
242
243 sub_sizer.AddStretchSpacer()
244
245
246 text_sizer = wx.BoxSizer(wx.VERTICAL)
247
248
249 text = wx.StaticText(self.main_panel, -1, 'Data export for BMRB deposition', style=wx.ALIGN_LEFT)
250 text.SetFont(font.title)
251 text_sizer.Add(text, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
252
253
254 text_sizer.AddSpacer(15)
255
256
257 main_text = 'This wizard will help in executing all of the relevant user functions required to convert the contents of the selected data pipe to the NMR-STAR format for deposition within the BioMagResBank. Note that this is currently only for the deposition of model-free analysis results or simple NMR relaxation data.'
258 text = wx.StaticText(self.main_panel, -1, main_text, style=wx.ALIGN_LEFT)
259 text.Wrap(600)
260 text.SetFont(font.normal)
261 text_sizer.Add(text, 0, 0, 0)
262
263
264 sub_sizer.Add(text_sizer, 0, 0, 0)
265
266
267 sub_sizer.AddStretchSpacer()
268
269
270 logo = wx.StaticBitmap(self.main_panel, -1, wx.Bitmap(IMAGE_PATH+"bmrb_100x100.png", wx.BITMAP_TYPE_ANY))
271 sub_sizer.Add(logo, 0, wx.TOP|wx.ALIGN_CENTER_HORIZONTAL, 0)
272
273
274 sub_sizer.AddStretchSpacer(3)
275
276
277 sizer.Add(sub_sizer, 0, wx.ALL|wx.EXPAND, 0)
278
279
280 sizer.AddSpacer(10)
281 sizer.Add(wx.StaticLine(self.main_panel, -1), 0, wx.EXPAND|wx.ALL, 0)
282 sizer.AddSpacer(10)
283
284
286 """Build and add the data pipe selection element.
287
288 @param sizer: The sizer element to pack the buttons into.
289 @type sizer: wx.Sizer instance
290 """
291
292
293 pipe_sizer = wx.BoxSizer(wx.HORIZONTAL)
294 sizer.Add(pipe_sizer, 0, wx.ALIGN_LEFT, 0)
295
296
297 text = wx.StaticText(self.main_panel, -1, ' The data pipe to export: ', style=wx.ALIGN_LEFT)
298 tooltip = "The name of the data pipe to export to NMR-STAR format for BMRB export."
299 text.SetFont(font.normal)
300 text.SetToolTipString(tooltip)
301 pipe_sizer.Add(text, 0, wx.ALIGN_CENTER_VERTICAL, 0)
302
303
304 pipe_sizer.AddSpacer(20)
305
306
307 self.pipe_name = wx.ComboBox(self.main_panel, -1, "", style=wx.CB_DROPDOWN|wx.CB_READONLY, choices=[])
308 self.pipe_name.SetToolTipString(tooltip)
309 self.Bind(wx.EVT_COMBOBOX, self.update_pipes, self.pipe_name)
310 pipe_sizer.Add(self.pipe_name, 0, wx.ALIGN_CENTER_VERTICAL, 0)
311
312
313 self.update_pipes()
314
315
317 """Event handler for the close window action.
318
319 @param event: The wx event.
320 @type event: wx event
321 """
322
323
324 self.observer_register(remove=True)
325
326
327 event.Skip()
328
329
331 """Determine if the data input is complete.
332
333 @return: A list of all the missing components.
334 @rtype: list of str
335 """
336
337
338 missing = []
339
340
341 if hasattr(cdp, 'ri_ids'):
342
343 for i in range(len(cdp.ri_ids)):
344
345 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'peak_intensity_type') or not cdp.ri_ids[i] in cdp.exp_info.peak_intensity_type.keys():
346 missing.append("The peak intensity type for the relaxation data ID '%s'." % cdp.ri_ids[i])
347
348
349 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'temp_calibration') or not cdp.ri_ids[i] in cdp.exp_info.temp_calibration.keys():
350 missing.append("The temperature calibration method for the relaxation data ID '%s'." % cdp.ri_ids[i])
351
352
353 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'temp_control') or not cdp.ri_ids[i] in cdp.exp_info.temp_control.keys():
354 missing.append("The temperature control method for the relaxation data ID '%s'." % cdp.ri_ids[i])
355
356
357
358 for mol, mol_id in molecule_loop(return_id=True):
359
360 if mol.name == None:
361 missing.append("The name of the molecule for %s." % mol_id)
362 continue
363
364
365 if not hasattr(mol, 'type') or mol.type == None:
366 missing.append("The type of the molecule %s." % mol_id)
367
368
369 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'thiol_state'):
370 missing.append("The thiol state of the molecule %s." % mol_id)
371
372
373 return missing
374
375
398
399
401 """Set up the relax controller frame.
402 @return: The sizer object.
403 @rtype: wx.Sizer instance
404 """
405
406
407 self.SetTitle("BMRB export window")
408
409
410 self.SetIcons(relax_icons)
411
412
413 self.main_panel = wx.Panel(self, -1)
414
415
416 main_sizer = wx.BoxSizer(wx.VERTICAL)
417 self.main_panel.SetSizer(main_sizer)
418
419
420 sizer = add_border(main_sizer, border=self.border, packing=wx.VERTICAL)
421
422
423 self.Bind(wx.EVT_CLOSE, self.handler_close)
424
425
426 self.SetSize(self.size)
427 self.SetMinSize(self.size_min)
428
429
430 self.Centre()
431
432
433 return sizer
434
435
437 """Update the spin view data pipe selector.
438
439 @keyword event: The wx event.
440 @type event: wx event
441 """
442
443
444 wx.BeginBusyCursor()
445
446
447 pipe_switch = False
448
449
450 if event:
451
452 pipe = gui_to_str(self.pipe_name.GetString(event.GetSelection()))
453
454
455 if pipe != cdp_name():
456 pipe_switch = True
457 else:
458 pipe = cdp_name()
459 if not pipe:
460 pipe = ''
461
462
463 self.pipe_name.Clear()
464
465
466 for name in pipe_names():
467 self.pipe_name.Append(str_to_gui(name))
468
469
470 if pipe_switch:
471 switch(pipe)
472
473
474 self.pipe_name.SetValue(str_to_gui(pipe))
475
476
477 if wx.IsBusy():
478 wx.EndBusyCursor()
479