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