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