Package gui :: Package user_functions :: Module noe
[hide private]
[frames] | no frames]

Source Code for Module gui.user_functions.noe

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2010-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """The noe user function GUI elements.""" 
 25   
 26  # Python module imports. 
 27  from os import sep 
 28  from string import split 
 29  import wx 
 30   
 31  # relax module imports. 
 32  from generic_fns import pipes 
 33   
 34  # GUI module imports. 
 35  from base import UF_base, UF_page 
 36  from gui.paths import ANALYSIS_IMAGE_PATH 
 37  from gui.misc import gui_to_float, gui_to_int, gui_to_str, str_to_gui 
 38   
 39   
 40  # The container class. 
41 -class Noe(UF_base):
42 """The container class for holding all GUI elements.""" 43
44 - def read_restraints(self):
45 """The noe.read_restraints user function.""" 46 47 # Execute the wizard. 48 wizard = self.create_wizard(size_x=800, size_y=600, name='noe.read_restraints', uf_page=Read_restraints_page) 49 wizard.run()
50 51
52 - def spectrum_type(self):
53 """The noe.spectrum_type user function.""" 54 55 # Execute the wizard. 56 wizard = self.create_wizard(size_x=800, size_y=600, name='noe.spectrum_type', uf_page=Spectrum_type_page) 57 wizard.run()
58 59 60
61 -class Read_restraints_page(UF_page):
62 """The noe.read_restraints() user function page.""" 63 64 # Some class variables. 65 image_path = ANALYSIS_IMAGE_PATH + 'noe_200x200.png' 66 uf_path = ['noe', 'read_restraints'] 67
68 - def add_contents(self, sizer):
69 """Add the page specific GUI elements. 70 71 @param sizer: A sizer object. 72 @type sizer: wx.Sizer instance 73 """ 74 75 # Add a file selection. 76 self.file = self.file_selection(sizer, "The restraint file:", message="Restraint file selection", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file']) 77 78 # The columns. 79 self.proton1_col = self.input_field(sizer, "The 1st proton column:", tooltip=self.uf._doc_args_dict['proton1_col']) 80 self.proton2_col = self.input_field(sizer, "The 2nd proton column:", tooltip=self.uf._doc_args_dict['proton2_col']) 81 self.lower_col = self.input_field(sizer, "The lower bound column:", tooltip=self.uf._doc_args_dict['lower_col']) 82 self.upper_col = self.input_field(sizer, "The upper bound column:", tooltip=self.uf._doc_args_dict['upper_col']) 83 84 # The column separator. 85 self.sep = self.combo_box(sizer, "Column separator:", ["white space", ",", ";", ":", ""], read_only=False) 86 87 # Spacing. 88 sizer.AddStretchSpacer()
89 90
91 - def on_execute(self):
92 """Execute the user function.""" 93 94 # The file name. 95 file = gui_to_str(self.file.GetValue()) 96 97 # No file. 98 if not file: 99 return 100 101 # Get the column numbers. 102 proton1_col = gui_to_int(self.proton1_col.GetValue()) 103 proton2_col = gui_to_int(self.proton2_col.GetValue()) 104 lower_col = gui_to_int(self.lower_col.GetValue()) 105 upper_col = gui_to_int(self.upper_col.GetValue()) 106 107 # The column separator. 108 sep = str(self.sep.GetValue()) 109 if sep == 'white space': 110 sep = None 111 112 # Read the NOESY data. 113 self.execute('noe.read_restraints', file=file, proton1_col=proton1_col, proton2_col=proton2_col, lower_col=lower_col, upper_col=upper_col, sep=sep)
114 115 116
117 -class Spectrum_type_page(UF_page):
118 """The noe.spectrum_type() user function page.""" 119 120 # Some class variables. 121 image_path = ANALYSIS_IMAGE_PATH + 'noe_200x200.png' 122 uf_path = ['noe', 'spectrum_type'] 123
124 - def add_contents(self, sizer):
125 """Add the page specific GUI elements. 126 127 @param sizer: A sizer object. 128 @type sizer: wx.Sizer instance 129 """ 130 131 # The spectrum type. 132 self.spectrum_type = self.combo_box(sizer, "The spectrum type:", tooltip=self.uf._doc_args_dict['spectrum_type'], choices=['Saturated spectrum', 'Reference spectrum']) 133 self.spectrum_type.SetClientData(0, 'sat') 134 self.spectrum_type.SetClientData(1, 'ref') 135 136 # The spectrum ID. 137 self.spectrum_id = self.combo_box(sizer, "The spectrum ID:", tooltip=self.uf._doc_args_dict['spectrum_id']) 138 139 # Spacing. 140 sizer.AddStretchSpacer()
141 142
143 - def on_execute(self):
144 """Execute the user function.""" 145 146 # The values. 147 spectrum_type = gui_to_str(self.spectrum_type.GetClientData(self.spectrum_type.GetSelection())) 148 149 # The spectrum ID. 150 spectrum_id = gui_to_str(self.spectrum_id.GetValue()) 151 152 # Read the relaxation data. 153 self.execute('noe.spectrum_type', spectrum_type=spectrum_type, spectrum_id=spectrum_id)
154 155
156 - def on_display(self):
157 """Clear previous data and update the spectrum ID list.""" 158 159 # Clear the previous data. 160 self.spectrum_id.Clear() 161 162 # No data, so don't try to fill the combo box. 163 if not hasattr(cdp, 'spectrum_ids'): 164 return 165 166 # The spectrum IDs. 167 for i in range(len(cdp.spectrum_ids)): 168 self.spectrum_id.Append(str_to_gui(cdp.spectrum_ids[i]))
169