Package gui :: Package components :: Module spectrum
[hide private]
[frames] | no frames]

Source Code for Module gui.components.spectrum

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2009-2011 Michael Bieri                                       # 
  4  # Copyright (C) 2010-2014 Edward d'Auvergne                                   # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Module containing the classes for GUI components involving spectral data.""" 
 25   
 26  # Python module imports. 
 27  import wx 
 28  import wx.lib.buttons 
 29   
 30  # relax module imports. 
 31  from graphics import fetch_icon 
 32  from gui.components.base_list import Base_list 
 33  from gui.string_conv import float_to_gui, gui_to_str, str_to_gui 
 34  from gui.uf_objects import Uf_storage; uf_store = Uf_storage() 
 35  from lib.compat import u 
 36  from pipe_control.spectrum import replicated_flags, replicated_ids 
 37  from status import Status; status = Status() 
 38  from specific_analyses.relax_disp.data import is_cpmg_exp_type, is_r1rho_exp_type 
 39  from user_functions.data import Uf_info; uf_info = Uf_info() 
 40   
 41   
 42  # Some IDs for the menu entries. 
 43  MENU_SPECTRUM_BASEPLANE_RMSD = wx.NewId() 
 44  MENU_SPECTRUM_DELETE = wx.NewId() 
 45  MENU_SPECTRUM_INTEGRATION_POINTS = wx.NewId() 
 46  MENU_SPECTRUM_REPLICATED = wx.NewId() 
 47  MENU_RELAX_DISP_EXP_TYPE = wx.NewId() 
 48  MENU_RELAX_FIT_RELAX_TIME = wx.NewId() 
 49  MENU_RELAX_DISP_RELAX_TIME = wx.NewId() 
 50  MENU_SPECTROMETER_FRQ = wx.NewId() 
 51  MENU_RELAX_DISP_SPIN_LOCK_FIELD = wx.NewId() 
 52  MENU_RELAX_DISP_SPIN_LOCK_OFFSET = wx.NewId() 
 53  MENU_RELAX_DISP_CPMG_SETUP = wx.NewId() 
 54   
 55   
56 -class Spectra_list(Base_list):
57 """The GUI element for listing loaded spectral data.""" 58
59 - def __init__(self, gui=None, parent=None, box=None, id=None, fn_add=None, proportion=0, button_placement='default', noe_flag=False, relax_fit_flag=False, relax_disp_flag=False):
60 """Build the spectral list GUI element. 61 62 @keyword gui: The main GUI object. 63 @type gui: wx.Frame instance 64 @keyword parent: The parent GUI element that this is to be attached to (the panel object). 65 @type parent: wx object 66 @keyword data: The data storage container. 67 @type data: class instance 68 @keyword box: The vertical box sizer to pack this GUI component into. 69 @type box: wx.BoxSizer instance 70 @keyword id: A unique identification string. This is used to register the update method with the GUI user function observer object. 71 @type id: str 72 @keyword fn_add: The function to execute when clicking on the 'Add' button. 73 @type fn_add: func 74 @keyword proportion: The window proportion parameter. 75 @type proportion: bool 76 @keyword button_placement: Override the button visibility and placement. The value of 'default' will leave the buttons at the default setting. The value of 'top' will place the buttons at the top, 'bottom' will place them at the bottom, and None will turn off the buttons. 77 @type button_placement: str or None 78 @keyword noe_flag: A flag which when True will enable the steady-state NOE portions of the wizard. 79 @type noe_flag: bool 80 @keyword relax_fit_flag: A flag which when True will enable the relaxation curve-fitting portions of the wizard. 81 @type relax_fit_flag: bool 82 @keyword relax_disp_flag: A flag which when True will enable the relaxation dispersion portions of the wizard. 83 @type relax_disp_flag: bool 84 """ 85 86 # Store the arguments. 87 self.fn_add = fn_add 88 self.noe_flag = noe_flag 89 self.relax_fit_flag = relax_fit_flag 90 self.relax_disp_flag = relax_disp_flag 91 92 # Initialise the base class. 93 super(Spectra_list, self).__init__(gui=gui, parent=parent, box=box, id=id, proportion=proportion, button_placement=button_placement)
94 95
96 - def action_relax_disp_cpmg_setup(self, event=None, item=None):
97 """Launch the relax_disp.cpmg_setup user function. 98 99 @keyword event: The wx event. 100 @type event: wx event 101 @keyword item: This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs. 102 @type item: None or int 103 """ 104 105 # The current selection. 106 if item == None: 107 item = self.element.GetFirstSelected() 108 109 # The spectrum ID. 110 id = gui_to_str(self.element.GetItemText(item)) 111 112 # The current frequency. 113 frq = None 114 frq_flag = False 115 if hasattr(cdp, 'cpmg_frqs') and id in cdp.cpmg_frqs: 116 frq = cdp.cpmg_frqs[id] 117 frq_flag = True 118 119 # The current ncyc_even flag. 120 even = True 121 even_flag = False 122 if hasattr(cdp, 'ncyc_even') and id in cdp.ncyc_even: 123 even = cdp.ncyc_even[id] 124 even_flag = True 125 126 # Launch the dialog. 127 if frq_flag: 128 uf_store['relax_disp.cpmg_setup'](spectrum_id=id, cpmg_frq=frq, ncyc_even=even) 129 else: 130 uf_store['relax_disp.cpmg_setup'](spectrum_id=id, ncyc_even=even)
131 132
133 - def action_relax_disp_exp_type(self, event=None, item=None):
134 """Launch the relax_disp.exp_type user function. 135 136 @keyword event: The wx event. 137 @type event: wx event 138 @keyword item: This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs. 139 @type item: None or int 140 """ 141 142 # The current selection. 143 if item == None: 144 item = self.element.GetFirstSelected() 145 146 # The spectrum ID. 147 id = gui_to_str(self.element.GetItemText(item)) 148 149 # The current type. 150 exp_type = None 151 if hasattr(cdp, 'exp_type') and id in cdp.exp_type: 152 exp_type = cdp.exp_type[id] 153 154 # Launch the dialog. 155 if exp_type == None: 156 uf_store['relax_disp.exp_type'](spectrum_id=id) 157 else: 158 uf_store['relax_disp.exp_type'](spectrum_id=id, exp_type=exp_type)
159 160
161 - def action_relax_disp_relax_time(self, event=None, item=None):
162 """Launch the relax_disp.relax_time user function. 163 164 @keyword event: The wx event. 165 @type event: wx event 166 @keyword item: This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs. 167 @type item: None or int 168 """ 169 170 # The current selection. 171 if item == None: 172 item = self.element.GetFirstSelected() 173 174 # The spectrum ID. 175 id = gui_to_str(self.element.GetItemText(item)) 176 177 # The current time. 178 time = None 179 if hasattr(cdp, 'relax_times') and id in cdp.relax_times: 180 time = cdp.relax_times[id] 181 182 # Launch the dialog. 183 if time == None: 184 uf_store['relax_disp.relax_time'](spectrum_id=id) 185 else: 186 uf_store['relax_disp.relax_time'](time=time, spectrum_id=id)
187 188
189 - def action_relax_disp_spin_lock_field(self, event=None, item=None):
190 """Launch the relax_disp.spin_lock_field user function. 191 192 @keyword event: The wx event. 193 @type event: wx event 194 @keyword item: This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs. 195 @type item: None or int 196 """ 197 198 # The current selection. 199 if item == None: 200 item = self.element.GetFirstSelected() 201 202 # The spectrum ID. 203 id = gui_to_str(self.element.GetItemText(item)) 204 205 # The spin-lock. 206 nu1 = None 207 nu1_flag = False 208 if hasattr(cdp, 'spin_lock_nu1') and id in cdp.spin_lock_nu1: 209 nu1 = cdp.spin_lock_nu1[id] 210 nu1_flag = True 211 212 # Launch the dialog. 213 if nu1_flag: 214 uf_store['relax_disp.spin_lock_field'](field=nu1, spectrum_id=id) 215 else: 216 uf_store['relax_disp.spin_lock_field'](spectrum_id=id)
217 218
219 - def action_relax_disp_spin_lock_offset(self, event=None, item=None):
220 """Launch the relax_disp.spin_lock_offset user function. 221 222 @keyword event: The wx event. 223 @type event: wx event 224 @keyword item: This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs. 225 @type item: None or int 226 """ 227 228 # The current selection. 229 if item == None: 230 item = self.element.GetFirstSelected() 231 232 # The spectrum ID. 233 id = gui_to_str(self.element.GetItemText(item)) 234 235 # The offset. 236 offset = None 237 offset_flag = False 238 if hasattr(cdp, 'spin_lock_offset') and id in cdp.spin_lock_offset: 239 offset = cdp.spin_lock_offset[id] 240 offset_flag = True 241 242 # Launch the dialog. 243 if offset_flag: 244 uf_store['relax_disp.spin_lock_offset'](offset=offset, spectrum_id=id) 245 else: 246 uf_store['relax_disp.spin_lock_offset'](spectrum_id=id)
247 248
249 - def action_relax_fit_relax_time(self, event=None, item=None):
250 """Launch the relax_fit.relax_time user function. 251 252 @keyword event: The wx event. 253 @type event: wx event 254 @keyword item: This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs. 255 @type item: None or int 256 """ 257 258 # The current selection. 259 if item == None: 260 item = self.element.GetFirstSelected() 261 262 # The spectrum ID. 263 id = gui_to_str(self.element.GetItemText(item)) 264 265 # The current time. 266 time = None 267 if hasattr(cdp, 'relax_times') and id in cdp.relax_times: 268 time = cdp.relax_times[id] 269 270 # Launch the dialog. 271 if time == None: 272 uf_store['relax_fit.relax_time'](spectrum_id=id) 273 else: 274 uf_store['relax_fit.relax_time'](time=time, spectrum_id=id)
275 276
277 - def action_spectrometer_frq(self, event=None, item=None):
278 """Launch the spectrometer.frequency user function. 279 280 @keyword event: The wx event. 281 @type event: wx event 282 @keyword item: This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs. 283 @type item: None or int 284 """ 285 286 # The current selection. 287 if item == None: 288 item = self.element.GetFirstSelected() 289 290 # The spectrum ID. 291 id = gui_to_str(self.element.GetItemText(item)) 292 293 # The current frequency. 294 frq = None 295 if hasattr(cdp, 'spectrometer_frq') and id in cdp.spectrometer_frq: 296 frq = cdp.spectrometer_frq[id] 297 298 # Launch the dialog. 299 if frq == None: 300 uf_store['spectrometer.frequency'](id=id) 301 else: 302 uf_store['spectrometer.frequency'](frq=frq, id=id)
303 304
305 - def action_spectrum_baseplane_rmsd(self, event):
306 """Launch the spectrum.baseplane_rmsd user function. 307 308 @param event: The wx event. 309 @type event: wx event 310 """ 311 312 # The current selection. 313 item = self.element.GetFirstSelected() 314 315 # The spectrum ID. 316 id = gui_to_str(self.element.GetItemText(item)) 317 318 # Launch the dialog. 319 uf_store['spectrum.baseplane_rmsd'](spectrum_id=id)
320 321
322 - def action_spectrum_delete(self, event):
323 """Launch the spectrum.delete user function. 324 325 @param event: The wx event. 326 @type event: wx event 327 """ 328 329 # The current selection. 330 item = self.element.GetFirstSelected() 331 332 # No selection. 333 if item == -1: 334 id = None 335 336 # Selected item. 337 else: 338 # The spectrum ID. 339 id = gui_to_str(self.element.GetItemText(item)) 340 341 # Launch the dialog. 342 uf_store['spectrum.delete'](spectrum_id=id)
343 344
345 - def action_spectrum_error_analysis(self, event):
346 """Launch the spectrum.error_analysis user function. 347 348 @param event: The wx event. 349 @type event: wx event 350 """ 351 352 # The first item selected. 353 item = self.element.GetFirstSelected() 354 355 # Loop over the additional selections. 356 ids = [] 357 while True: 358 # No selection. 359 if item == -1: 360 break 361 362 # Add the ID string to the list. 363 ids.append(gui_to_str(self.element.GetItemText(item))) 364 365 # Get the next selected item. 366 item = self.element.GetNextSelected(item) 367 368 # No selected items. 369 if not len(ids): 370 ids = None 371 372 # Launch the dialog. 373 uf_store['spectrum.error_analysis'](subset=ids, wx_wizard_modal=True) 374 375 # Display the relax controller, and go to the end of the log window. 376 self.gui.show_controller(None) 377 self.gui.controller.log_panel.on_goto_end(None)
378 379
380 - def action_spectrum_integration_points(self, event):
381 """Launch the spectrum.integration_points user function. 382 383 @param event: The wx event. 384 @type event: wx event 385 """ 386 387 # The current selection. 388 item = self.element.GetFirstSelected() 389 390 # The spectrum ID. 391 id = gui_to_str(self.element.GetItemText(item)) 392 393 # Launch the dialog. 394 uf_store['spectrum.integration_points'](spectrum_id=id)
395 396
397 - def action_spectrum_replicated(self, event):
398 """Launch the spectrum.replicated user function. 399 400 @param event: The wx event. 401 @type event: wx event 402 """ 403 404 # The current selection. 405 item = self.element.GetFirstSelected() 406 407 # The spectrum ID. 408 id = gui_to_str(self.element.GetItemText(item)) 409 410 # The current replicates. 411 replicates = replicated_ids(id) 412 413 # Launch the dialog. 414 if replicates == []: 415 uf_store['spectrum.replicated'](spectrum_ids=id) 416 else: 417 uf_store['spectrum.replicated'](spectrum_ids=replicates)
418 419
420 - def add_disp_point(self, index):
421 """Add the dispersion point info to the element. 422 423 This is either the CPMG pulse frequency or the spin-lock field strength. Both share the same column. 424 425 @param index: The column index for the data. 426 @type index: int 427 @return: True if the data exists, False otherwise. 428 @rtype: bool 429 """ 430 431 # Append a column. 432 self.element.InsertColumn(index, u("\u03BDCPMG (Hz) or Spin-lock \u03BD1 (Hz)")) 433 434 # No data. 435 if not hasattr(cdp, 'spectrum_ids'): 436 return True 437 438 # Set the values. 439 for i in range(len(cdp.spectrum_ids)): 440 # Set the CPMG frequency. 441 if hasattr(cdp, 'cpmg_frqs') and cdp.spectrum_ids[i] in cdp.cpmg_frqs: 442 self.element.SetStringItem(i, index, float_to_gui(cdp.cpmg_frqs[cdp.spectrum_ids[i]])) 443 444 # Set the spin-lock field strength. 445 if hasattr(cdp, 'spin_lock_nu1') and cdp.spectrum_ids[i] in cdp.spin_lock_nu1: 446 self.element.SetStringItem(i, index, float_to_gui(cdp.spin_lock_nu1[cdp.spectrum_ids[i]])) 447 448 # Successful. 449 return True
450 451
452 - def add_exp_type(self, index):
453 """Add the experiment type info to the element. 454 455 @param index: The column index for the data. 456 @type index: int 457 @return: True if the data exists, False otherwise. 458 @rtype: bool 459 """ 460 461 # Append a column. 462 self.element.InsertColumn(index, u("Experiment type")) 463 464 # No data. 465 if not hasattr(cdp, 'spectrum_ids') or not hasattr(cdp, 'exp_type'): 466 return True 467 468 # Set the values. 469 for i in range(len(cdp.spectrum_ids)): 470 # No value. 471 if cdp.spectrum_ids[i] not in cdp.exp_type: 472 continue 473 474 # Set the value. 475 self.element.SetStringItem(i, index, float_to_gui(cdp.exp_type[cdp.spectrum_ids[i]])) 476 477 # Successful. 478 return True
479 480
481 - def add_frqs(self, index):
482 """Add the spectrometer frequency info to the element. 483 484 @param index: The column index for the data. 485 @type index: int 486 @return: True if the frequency data exists, False otherwise. 487 @rtype: bool 488 """ 489 490 # Append a column. 491 self.element.InsertColumn(index, u("\u03C9H (MHz)")) 492 493 # No data. 494 if not hasattr(cdp, 'spectrum_ids'): 495 return True 496 if not hasattr(cdp, 'spectrometer_frq') or not len(cdp.spectrometer_frq): 497 return True 498 499 # Set the values. 500 for i in range(len(cdp.spectrum_ids)): 501 # No value. 502 if cdp.spectrum_ids[i] not in cdp.spectrometer_frq: 503 continue 504 505 # Set the value (in MHz). 506 self.element.SetStringItem(i, index, float_to_gui(cdp.spectrometer_frq[cdp.spectrum_ids[i]]/1e6)) 507 508 # Successful. 509 return True
510 511
512 - def add_offset(self, index):
513 """Add the offset info to the element. 514 515 @param index: The column index for the data. 516 @type index: int 517 @return: True if the data exists, False otherwise. 518 @rtype: bool 519 """ 520 521 # Append a column. 522 self.element.InsertColumn(index, u("Offset \u03C9_rf (ppm)")) 523 524 # No data. 525 if not hasattr(cdp, 'spectrum_ids'): 526 return True 527 528 # Set the values. 529 for i in range(len(cdp.spectrum_ids)): 530 if hasattr(cdp, 'spin_lock_offset') and cdp.spectrum_ids[i] in cdp.spin_lock_offset: 531 self.element.SetStringItem(i, index, float_to_gui(cdp.spin_lock_offset[cdp.spectrum_ids[i]])) 532 533 # Successful. 534 return True
535 536
537 - def generate_popup_menu(self, id=None):
538 """Create the popup menu. 539 540 @keyword id: The spectrum ID string for the row that was clicked on. 541 @type id: str 542 @return: The popup menu. 543 @rtype: list of dict of wxID, str, str, method 544 """ 545 546 # The right click popup menu. 547 popup_menus = [ 548 { 549 'id': MENU_SPECTRUM_BASEPLANE_RMSD, 550 'text': "Set the &baseplane RMSD", 551 'icon': fetch_icon(uf_info.get_uf('spectrum.baseplane_rmsd').gui_icon), 552 'method': self.action_spectrum_baseplane_rmsd 553 }, { 554 'id': MENU_SPECTRUM_DELETE, 555 'text': "&Delete the peak intensities", 556 'icon': fetch_icon(uf_info.get_uf('spectrum.delete').gui_icon), 557 'method': self.action_spectrum_delete 558 }, { 559 'id': MENU_SPECTRUM_INTEGRATION_POINTS, 560 'text': "Set the number of integration &points", 561 'icon': fetch_icon(uf_info.get_uf('spectrum.integration_points').gui_icon), 562 'method': self.action_spectrum_integration_points 563 }, { 564 'id': MENU_SPECTRUM_REPLICATED, 565 'text': "Specify which spectra are &replicated", 566 'icon': fetch_icon(uf_info.get_uf('spectrum.replicated').gui_icon), 567 'method': self.action_spectrum_replicated 568 } 569 ] 570 if self.relax_disp_flag: 571 popup_menus.append({ 572 'id': MENU_RELAX_DISP_EXP_TYPE, 573 'text': "Set the &experiment type", 574 'icon': None, 575 'method': self.action_relax_disp_exp_type 576 }) 577 if self.relax_fit_flag: 578 popup_menus.append({ 579 'id': MENU_RELAX_FIT_RELAX_TIME, 580 'text': "Set the relaxation &time", 581 'icon': fetch_icon(uf_info.get_uf('relax_fit.relax_time').gui_icon), 582 'method': self.action_relax_fit_relax_time 583 }) 584 if self.relax_disp_flag: 585 popup_menus.append({ 586 'id': MENU_RELAX_DISP_RELAX_TIME, 587 'text': "Set the relaxation &time", 588 'icon': fetch_icon(uf_info.get_uf('relax_disp.relax_time').gui_icon), 589 'method': self.action_relax_disp_relax_time 590 }) 591 popup_menus.append({ 592 'id': MENU_SPECTROMETER_FRQ, 593 'text': "Set the spectrometer &frequency", 594 'icon': fetch_icon("relax.spectrometer"), 595 'method': self.action_spectrometer_frq 596 }) 597 if self.relax_disp_flag and is_r1rho_exp_type(id): 598 popup_menus.append({ 599 'id': MENU_RELAX_DISP_SPIN_LOCK_FIELD, 600 'text': u("Set the spin-&lock field strength \u03BD1"), 601 'icon': fetch_icon("relax.relax_disp"), 602 'method': self.action_relax_disp_spin_lock_field 603 }) 604 popup_menus.append({ 605 'id': MENU_RELAX_DISP_SPIN_LOCK_OFFSET, 606 'text': u("Set the spin-&lock offset \u03C9_rf"), 607 'icon': fetch_icon("relax.relax_disp"), 608 'method': self.action_relax_disp_spin_lock_offset 609 }) 610 if self.relax_disp_flag and is_cpmg_exp_type(id): 611 popup_menus.append({ 612 'id': MENU_RELAX_DISP_CPMG_SETUP, 613 'text': u("Set the &CPMG pulse sequence information"), 614 'icon': fetch_icon("relax.relax_disp"), 615 'method': self.action_relax_disp_cpmg_setup 616 }) 617 618 # Return the menu. 619 return popup_menus
620 621
622 - def noe_spectrum_type(self, index):
623 """Add the NOE spectral type info to the element. 624 625 @param index: The column index for the data. 626 @type index: int 627 @return: True if a spectrum type exists, False otherwise. 628 @rtype: bool 629 """ 630 631 # No type info. 632 if not hasattr(cdp, 'spectrum_type') or not len(cdp.spectrum_type): 633 return False 634 635 # Append a column. 636 self.element.InsertColumn(index, str_to_gui("NOE spectrum type")) 637 638 # Translation table. 639 table = { 640 'sat': 'Saturated', 641 'ref': 'Reference' 642 } 643 644 # No data. 645 if not hasattr(cdp, 'spectrum_ids'): 646 return True 647 648 # Set the values. 649 for i in range(len(cdp.spectrum_ids)): 650 # No value. 651 if cdp.spectrum_ids[i] not in cdp.spectrum_type: 652 continue 653 654 # Set the value. 655 self.element.SetStringItem(i, index, str_to_gui(table[cdp.spectrum_type[cdp.spectrum_ids[i]]])) 656 657 # Successful. 658 return True
659 660
661 - def relax_times(self, index):
662 """Add the relaxation delay time info to the element. 663 664 @param index: The column index for the data. 665 @type index: int 666 @return: True if relaxation times exist, False otherwise. 667 @rtype: bool 668 """ 669 670 # No type info. 671 if not hasattr(cdp, 'relax_times') or not len(cdp.relax_times): 672 return False 673 674 # Append a column. 675 self.element.InsertColumn(index, str_to_gui("Delay times (s)")) 676 677 # No data. 678 if not hasattr(cdp, 'spectrum_ids'): 679 return True 680 681 # Set the values. 682 for i in range(len(cdp.spectrum_ids)): 683 # No value. 684 if cdp.spectrum_ids[i] not in cdp.relax_times: 685 continue 686 687 # Set the value. 688 self.element.SetStringItem(i, index, float_to_gui(cdp.relax_times[cdp.spectrum_ids[i]])) 689 690 # Successful. 691 return True
692 693
694 - def replicates(self, index):
695 """Add the replicated spectra info to the element. 696 697 @param index: The column index for the data. 698 @type index: int 699 @return: True if relaxation times exist, False otherwise. 700 @rtype: bool 701 """ 702 703 # No type info. 704 if not hasattr(cdp, 'replicates') or not len(cdp.replicates): 705 return False 706 707 # Replicated spectra. 708 repl = replicated_flags() 709 710 # Append a column. 711 self.element.InsertColumn(index, str_to_gui("Replicate IDs")) 712 713 # No data. 714 if not hasattr(cdp, 'spectrum_ids'): 715 return True 716 717 # Set the values. 718 for i in range(len(cdp.spectrum_ids)): 719 # No replicates. 720 if not repl[cdp.spectrum_ids[i]]: 721 continue 722 723 # The replicated spectra. 724 id_list = replicated_ids(cdp.spectrum_ids[i]) 725 726 # Convert to a string. 727 text = '' 728 for j in range(len(id_list)): 729 # Add the id. 730 text = "%s%s" % (text, id_list[j]) 731 732 # Separator. 733 if j < len(id_list)-1: 734 text = "%s, " % text 735 736 # Set the value. 737 self.element.SetStringItem(i, index, str_to_gui(text)) 738 739 # Successful. 740 return True
741 742
743 - def setup(self):
744 """Override the base variables.""" 745 746 # GUI variables. 747 self.title = "Spectra list" 748 self.observer_base_name = "spectra list" 749 750 # The column titles. 751 self.columns = [] 752 753 # Button set up. 754 self.button_placement = 'top' 755 self.button_size = (170, 40) 756 self.button_info = [ 757 { 758 'object': 'button_add', 759 'label': ' Add', 760 'icon': fetch_icon('oxygen.actions.list-add-relax-blue', "22x22"), 761 'method': self.fn_add, 762 'tooltip': "Read a spectral data file." 763 }, { 764 'object': 'button_delete', 765 'label': ' Delete', 766 'icon': fetch_icon('oxygen.actions.list-remove', "22x22"), 767 'method': self.action_spectrum_delete, 768 'tooltip': "Delete loaded relaxation data from the relax data store." 769 }, { 770 'object': 'button_error_analysis', 771 'label': ' Error analysis', 772 'icon': fetch_icon('oxygen.categories.applications-education', "22x22"), 773 'method': self.action_spectrum_error_analysis, 774 'tooltip': "Perform a peak intensity error analysis on the currently loaded data or data subsets. Select a subset of the spectra below to perform the error analysis only on this subset." 775 } 776 ]
777 778
779 - def update_data(self):
780 """Method called from self.build_element_safe() to update the list data.""" 781 782 # Initialise the column index for the data. 783 index = 1 784 785 # Delete the rows and columns. 786 self.element.DeleteAllItems() 787 self.element.DeleteAllColumns() 788 789 # Initialise to a single column. 790 self.element.InsertColumn(0, str_to_gui("Spectrum ID")) 791 792 # Expand the number of rows to match the number of spectrum IDs, and add the IDs. 793 n = 0 794 if hasattr(cdp, 'spectrum_ids'): 795 # The number of IDs. 796 n = len(cdp.spectrum_ids) 797 798 # Set the IDs. 799 for i in range(n): 800 self.element.InsertStringItem(i, str_to_gui(cdp.spectrum_ids[i])) 801 802 # The NOE spectrum type. 803 if self.noe_spectrum_type(index): 804 index += 1 805 806 # The experiment type. 807 if self.relax_disp_flag and self.add_exp_type(index): 808 index += 1 809 810 # The spectrometer frequency. 811 if self.relax_disp_flag and self.add_frqs(index): 812 index += 1 813 814 # The spin-lock field strength or CPMG pulse frequency. 815 if self.relax_disp_flag and self.add_disp_point(index): 816 index += 1 817 818 # The offset. 819 if self.relax_disp_flag and self.add_offset(index): 820 index += 1 821 822 # The relaxation times. 823 if (self.relax_fit_flag or self.relax_disp_flag) and self.relax_times(index): 824 index += 1 825 826 # The replicated spectra. 827 if self.replicates(index): 828 index += 1
829