"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gui/components/spectrum.py" between
relax-4.1.3.src.tar.bz2 and relax-5.0.0.src.tar.bz2

About: relax allows the study of molecular dynamics through the analysis of experimental NMR data. Organic molecules, proteins, RNA, DNA, sugars, and other biomolecules are all supported.

spectrum.py  (relax-4.1.3.src.tar.bz2):spectrum.py  (relax-5.0.0.src.tar.bz2)
############################################################################### ###############################################################################
# # # #
# Copyright (C) 2009-2010 Michael Bieri # # Copyright (C) 2009-2010 Michael Bieri #
# Copyright (C) 2009-2014 Edward d'Auvergne # # Copyright (C) 2009-2014,2019 Edward d'Auvergne #
# # # #
# This file is part of the program relax (http://www.nmr-relax.com). # # This file is part of the program relax (http://www.nmr-relax.com). #
# # # #
# This program is free software: you can redistribute it and/or modify # # This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by # # it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or # # the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. # # (at your option) any later version. #
# # # #
# This program is distributed in the hope that it will be useful, # # This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # # but WITHOUT ANY WARRANTY; without even the implied warranty of #
skipping to change at line 31 skipping to change at line 31
############################################################################### ###############################################################################
# Module docstring. # Module docstring.
"""Module containing the classes for GUI components involving spectral data.""" """Module containing the classes for GUI components involving spectral data."""
# Python module imports. # Python module imports.
import wx import wx
import wx.lib.buttons import wx.lib.buttons
# relax module imports. # relax module imports.
import dep_check
from graphics import fetch_icon from graphics import fetch_icon
from gui.components.base_list import Base_list from gui.components.base_list import Base_list
from gui.string_conv import float_to_gui, gui_to_str, str_to_gui from gui.string_conv import float_to_gui, gui_to_str, str_to_gui
from gui.uf_objects import Uf_storage; uf_store = Uf_storage() from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
from lib.compat import u from lib.compat import u
from pipe_control.spectrum import replicated_flags, replicated_ids from pipe_control.spectrum import replicated_flags, replicated_ids
from status import Status; status = Status() from status import Status; status = Status()
from specific_analyses.relax_disp.data import is_cpmg_exp_type, is_r1rho_exp_typ e from specific_analyses.relax_disp.data import is_cpmg_exp_type, is_r1rho_exp_typ e
from user_functions.data import Uf_info; uf_info = Uf_info() from user_functions.data import Uf_info; uf_info = Uf_info()
skipping to change at line 434 skipping to change at line 435
self.element.InsertColumn(index, u("\u03BDCPMG (Hz) or Spin-lock \u03BD1 (Hz)")) self.element.InsertColumn(index, u("\u03BDCPMG (Hz) or Spin-lock \u03BD1 (Hz)"))
# No data. # No data.
if not hasattr(cdp, 'spectrum_ids'): if not hasattr(cdp, 'spectrum_ids'):
return True return True
# Set the values. # Set the values.
for i in range(len(cdp.spectrum_ids)): for i in range(len(cdp.spectrum_ids)):
# Set the CPMG frequency. # Set the CPMG frequency.
if hasattr(cdp, 'cpmg_frqs') and cdp.spectrum_ids[i] in cdp.cpmg_frq s: if hasattr(cdp, 'cpmg_frqs') and cdp.spectrum_ids[i] in cdp.cpmg_frq s:
self.element.SetStringItem(i, index, float_to_gui(cdp.cpmg_frqs[ if dep_check.wx_classic:
cdp.spectrum_ids[i]])) self.element.SetStringItem(i, index, float_to_gui(cdp.cpmg_f
rqs[cdp.spectrum_ids[i]]))
else:
self.element.SetItem(i, index, float_to_gui(cdp.cpmg_frqs[cd
p.spectrum_ids[i]]))
# Set the spin-lock field strength. # Set the spin-lock field strength.
if hasattr(cdp, 'spin_lock_nu1') and cdp.spectrum_ids[i] in cdp.spin _lock_nu1: if hasattr(cdp, 'spin_lock_nu1') and cdp.spectrum_ids[i] in cdp.spin _lock_nu1:
self.element.SetStringItem(i, index, float_to_gui(cdp.spin_lock_ if dep_check.wx_classic:
nu1[cdp.spectrum_ids[i]])) self.element.SetStringItem(i, index, float_to_gui(cdp.spin_l
ock_nu1[cdp.spectrum_ids[i]]))
else:
self.element.SetItem(i, index, float_to_gui(cdp.spin_lock_nu
1[cdp.spectrum_ids[i]]))
# Successful. # Successful.
return True return True
def add_exp_type(self, index): def add_exp_type(self, index):
"""Add the experiment type info to the element. """Add the experiment type info to the element.
@param index: The column index for the data. @param index: The column index for the data.
@type index: int @type index: int
@return: True if the data exists, False otherwise. @return: True if the data exists, False otherwise.
skipping to change at line 466 skipping to change at line 473
if not hasattr(cdp, 'spectrum_ids') or not hasattr(cdp, 'exp_type'): if not hasattr(cdp, 'spectrum_ids') or not hasattr(cdp, 'exp_type'):
return True return True
# Set the values. # Set the values.
for i in range(len(cdp.spectrum_ids)): for i in range(len(cdp.spectrum_ids)):
# No value. # No value.
if cdp.spectrum_ids[i] not in cdp.exp_type: if cdp.spectrum_ids[i] not in cdp.exp_type:
continue continue
# Set the value. # Set the value.
self.element.SetStringItem(i, index, float_to_gui(cdp.exp_type[cdp.s if dep_check.wx_classic:
pectrum_ids[i]])) self.element.SetStringItem(i, index, float_to_gui(cdp.exp_type[c
dp.spectrum_ids[i]]))
else:
self.element.SetItem(i, index, float_to_gui(cdp.exp_type[cdp.spe
ctrum_ids[i]]))
# Successful. # Successful.
return True return True
def add_frqs(self, index): def add_frqs(self, index):
"""Add the spectrometer frequency info to the element. """Add the spectrometer frequency info to the element.
@param index: The column index for the data. @param index: The column index for the data.
@type index: int @type index: int
@return: True if the frequency data exists, False otherwise. @return: True if the frequency data exists, False otherwise.
skipping to change at line 496 skipping to change at line 506
if not hasattr(cdp, 'spectrometer_frq') or not len(cdp.spectrometer_frq) : if not hasattr(cdp, 'spectrometer_frq') or not len(cdp.spectrometer_frq) :
return True return True
# Set the values. # Set the values.
for i in range(len(cdp.spectrum_ids)): for i in range(len(cdp.spectrum_ids)):
# No value. # No value.
if cdp.spectrum_ids[i] not in cdp.spectrometer_frq: if cdp.spectrum_ids[i] not in cdp.spectrometer_frq:
continue continue
# Set the value (in MHz). # Set the value (in MHz).
self.element.SetStringItem(i, index, float_to_gui(cdp.spectrometer_f if dep_check.wx_classic:
rq[cdp.spectrum_ids[i]]/1e6)) self.element.SetStringItem(i, index, float_to_gui(cdp.spectromet
er_frq[cdp.spectrum_ids[i]]/1e6))
else:
self.element.SetItem(i, index, float_to_gui(cdp.spectrometer_frq
[cdp.spectrum_ids[i]]/1e6))
# Successful. # Successful.
return True return True
def add_offset(self, index): def add_offset(self, index):
"""Add the offset info to the element. """Add the offset info to the element.
@param index: The column index for the data. @param index: The column index for the data.
@type index: int @type index: int
@return: True if the data exists, False otherwise. @return: True if the data exists, False otherwise.
skipping to change at line 520 skipping to change at line 533
# Append a column. # Append a column.
self.element.InsertColumn(index, u("Offset \u03C9_rf (ppm)")) self.element.InsertColumn(index, u("Offset \u03C9_rf (ppm)"))
# No data. # No data.
if not hasattr(cdp, 'spectrum_ids'): if not hasattr(cdp, 'spectrum_ids'):
return True return True
# Set the values. # Set the values.
for i in range(len(cdp.spectrum_ids)): for i in range(len(cdp.spectrum_ids)):
if hasattr(cdp, 'spin_lock_offset') and cdp.spectrum_ids[i] in cdp.s pin_lock_offset: if hasattr(cdp, 'spin_lock_offset') and cdp.spectrum_ids[i] in cdp.s pin_lock_offset:
self.element.SetStringItem(i, index, float_to_gui(cdp.spin_lock_ if dep_check.wx_classic:
offset[cdp.spectrum_ids[i]])) self.element.SetStringItem(i, index, float_to_gui(cdp.spin_l
ock_offset[cdp.spectrum_ids[i]]))
else:
self.element.SetItem(i, index, float_to_gui(cdp.spin_lock_of
fset[cdp.spectrum_ids[i]]))
# Successful. # Successful.
return True return True
def generate_popup_menu(self, id=None): def generate_popup_menu(self, id=None):
"""Create the popup menu. """Create the popup menu.
@keyword id: The spectrum ID string for the row that was clicked on. @keyword id: The spectrum ID string for the row that was clicked on.
@type id: str @type id: str
@return: The popup menu. @return: The popup menu.
skipping to change at line 642 skipping to change at line 658
if not hasattr(cdp, 'spectrum_ids'): if not hasattr(cdp, 'spectrum_ids'):
return True return True
# Set the values. # Set the values.
for i in range(len(cdp.spectrum_ids)): for i in range(len(cdp.spectrum_ids)):
# No value. # No value.
if cdp.spectrum_ids[i] not in cdp.spectrum_type: if cdp.spectrum_ids[i] not in cdp.spectrum_type:
continue continue
# Set the value. # Set the value.
self.element.SetStringItem(i, index, str_to_gui(table[cdp.spectrum_t if dep_check.wx_classic:
ype[cdp.spectrum_ids[i]]])) self.element.SetStringItem(i, index, str_to_gui(table[cdp.spectr
um_type[cdp.spectrum_ids[i]]]))
else:
self.element.SetItem(i, index, str_to_gui(table[cdp.spectrum_typ
e[cdp.spectrum_ids[i]]]))
# Successful. # Successful.
return True return True
def relax_times(self, index): def relax_times(self, index):
"""Add the relaxation delay time info to the element. """Add the relaxation delay time info to the element.
@param index: The column index for the data. @param index: The column index for the data.
@type index: int @type index: int
@return: True if relaxation times exist, False otherwise. @return: True if relaxation times exist, False otherwise.
skipping to change at line 674 skipping to change at line 693
if not hasattr(cdp, 'spectrum_ids'): if not hasattr(cdp, 'spectrum_ids'):
return True return True
# Set the values. # Set the values.
for i in range(len(cdp.spectrum_ids)): for i in range(len(cdp.spectrum_ids)):
# No value. # No value.
if cdp.spectrum_ids[i] not in cdp.relax_times: if cdp.spectrum_ids[i] not in cdp.relax_times:
continue continue
# Set the value. # Set the value.
self.element.SetStringItem(i, index, float_to_gui(cdp.relax_times[cd if dep_check.wx_classic:
p.spectrum_ids[i]])) self.element.SetStringItem(i, index, float_to_gui(cdp.relax_time
s[cdp.spectrum_ids[i]]))
else:
self.element.SetItem(i, index, float_to_gui(cdp.relax_times[cdp.
spectrum_ids[i]]))
# Successful. # Successful.
return True return True
def replicates(self, index): def replicates(self, index):
"""Add the replicated spectra info to the element. """Add the replicated spectra info to the element.
@param index: The column index for the data. @param index: The column index for the data.
@type index: int @type index: int
@return: True if relaxation times exist, False otherwise. @return: True if relaxation times exist, False otherwise.
skipping to change at line 722 skipping to change at line 744
text = '' text = ''
for j in range(len(id_list)): for j in range(len(id_list)):
# Add the id. # Add the id.
text = "%s%s" % (text, id_list[j]) text = "%s%s" % (text, id_list[j])
# Separator. # Separator.
if j < len(id_list)-1: if j < len(id_list)-1:
text = "%s, " % text text = "%s, " % text
# Set the value. # Set the value.
self.element.SetStringItem(i, index, str_to_gui(text)) if dep_check.wx_classic:
self.element.SetStringItem(i, index, str_to_gui(text))
else:
self.element.SetItem(i, index, str_to_gui(text))
# Successful. # Successful.
return True return True
def setup(self): def setup(self):
"""Override the base variables.""" """Override the base variables."""
# GUI variables. # GUI variables.
self.title = "Spectra list" self.title = "Spectra list"
self.observer_base_name = "spectra list" self.observer_base_name = "spectra list"
skipping to change at line 784 skipping to change at line 809
self.element.InsertColumn(0, str_to_gui("Spectrum ID")) self.element.InsertColumn(0, str_to_gui("Spectrum ID"))
# Expand the number of rows to match the number of spectrum IDs, and add the IDs. # Expand the number of rows to match the number of spectrum IDs, and add the IDs.
n = 0 n = 0
if hasattr(cdp, 'spectrum_ids'): if hasattr(cdp, 'spectrum_ids'):
# The number of IDs. # The number of IDs.
n = len(cdp.spectrum_ids) n = len(cdp.spectrum_ids)
# Set the IDs. # Set the IDs.
for i in range(n): for i in range(n):
self.element.InsertStringItem(i, str_to_gui(cdp.spectrum_ids[i]) if dep_check.wx_classic:
) self.element.InsertStringItem(i, str_to_gui(cdp.spectrum_ids
[i]))
else:
self.element.InsertItem(i, str_to_gui(cdp.spectrum_ids[i]))
# The NOE spectrum type. # The NOE spectrum type.
if self.noe_spectrum_type(index): if self.noe_spectrum_type(index):
index += 1 index += 1
# The experiment type. # The experiment type.
if self.relax_disp_flag and self.add_exp_type(index): if self.relax_disp_flag and self.add_exp_type(index):
index += 1 index += 1
# The spectrometer frequency. # The spectrometer frequency.
 End of changes. 11 change blocks. 
18 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)