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

Source Code for Module gui.user_functions.relax_data

  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 relaxation data user function GUI elements.""" 
 25   
 26  # Python module imports. 
 27  from string import split 
 28  import wx 
 29   
 30  # relax module imports. 
 31  from generic_fns import pipes 
 32   
 33  # GUI module imports. 
 34  from base import UF_base, UF_page 
 35  from gui.paths import WIZARD_IMAGE_PATH 
 36  from gui.misc import gui_to_float, gui_to_int, gui_to_str, str_to_gui 
 37   
 38   
 39  # The container class. 
40 -class Relax_data(UF_base):
41 """The container class for holding all GUI elements.""" 42
43 - def delete(self, ri_id=None):
44 """The relax_data.delete user function. 45 46 @keyword ri_id: The starting relaxation data ID string. 47 @type ri_id: str 48 """ 49 50 # Create the wizard. 51 wizard, page = self.create_wizard(size_x=700, size_y=400, name='relax_data.delete', uf_page=Delete_page, return_page=True) 52 53 # Default ID. 54 if ri_id: 55 page.ri_id.SetValue(str_to_gui(ri_id)) 56 57 # Execute the wizard. 58 wizard.run()
59 60
61 - def read(self):
62 """The relax_data.read user function.""" 63 64 # Execute the wizard. 65 wizard = self.create_wizard(size_x=1000, size_y=700, name='relax_data.read', uf_page=Read_page) 66 wizard.run()
67 68 69
70 -class Delete_page(UF_page):
71 """The relax_data.read() user function page.""" 72 73 # Some class variables. 74 image_path = WIZARD_IMAGE_PATH + 'fid.png' 75 uf_path = ['relax_data', 'delete'] 76
77 - def add_contents(self, sizer):
78 """Add the relaxation data deletion specific GUI elements. 79 80 @param sizer: A sizer object. 81 @type sizer: wx.Sizer instance 82 """ 83 84 # The ID. 85 self.ri_id = self.combo_box(sizer, "The relaxation data ID:", tooltip=self.uf._doc_args_dict['ri_id'])
86 87
88 - def on_execute(self):
89 """Execute the user function.""" 90 91 # The labels and frq. 92 ri_id = gui_to_str(self.ri_id.GetValue()) 93 94 # Read the relaxation data. 95 self.execute('relax_data.delete', ri_id=ri_id)
96 97
98 - def on_display(self):
99 """Clear previous data and update the label lists.""" 100 101 # Clear the previous data. 102 self.ri_id.Clear() 103 104 # No data, so don't try to fill the combo boxes. 105 if not hasattr(cdp, 'ri_ids'): 106 return 107 108 # The relaxation data IDs. 109 for i in range(len(cdp.ri_ids)): 110 self.ri_id.Append(str_to_gui(cdp.ri_ids[i]))
111 112 113
114 -class Read_page(UF_page):
115 """The relax_data.read() user function page.""" 116 117 # Some class variables. 118 height_desc = 140 119 image_path = WIZARD_IMAGE_PATH + 'fid.png' 120 uf_path = ['relax_data', 'read'] 121
122 - def add_contents(self, sizer):
123 """Add the relaxation data reading specific GUI elements. 124 125 @param sizer: A sizer object. 126 @type sizer: wx.Sizer instance 127 """ 128 129 # Add a file selection. 130 self.file = self.file_selection(sizer, "The relaxation data file:", message="Relaxation data file selection", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file']) 131 132 # The labels. 133 self.ri_id = self.input_field(sizer, "The relaxation data ID:", tooltip=self.uf._doc_args_dict['ri_id']) 134 self.ri_type = self.combo_box(sizer, "The relaxation data type:", choices=['R1', 'R2', 'NOE'], tooltip=self.uf._doc_args_dict['ri_type']) 135 136 # The frequency. 137 self.frq = self.input_field(sizer, "The exact spectrometer frequency in Hz:", tooltip=self.uf._doc_args_dict['frq']) 138 139 # The spin ID restriction. 140 self.spin_id = self.spin_id_element(sizer, desc="Restrict data loading to certain spins:") 141 142 # The parameter file settings. 143 self.free_file_format(sizer, data_cols=True, padding=3, spacer=0)
144 145
146 - def on_execute(self):
147 """Execute the user function.""" 148 149 # The labels and frq. 150 ri_id = gui_to_str(self.ri_id.GetValue()) 151 ri_type = gui_to_str(self.ri_type.GetValue()) 152 frq = gui_to_float(self.frq.GetValue()) 153 154 # The file name. 155 file = gui_to_str(self.file.GetValue()) 156 157 # No file. 158 if not file: 159 return 160 161 # Get the column numbers. 162 spin_id_col = gui_to_int(self.spin_id_col.GetValue()) 163 mol_name_col = gui_to_int(self.mol_name_col.GetValue()) 164 res_num_col = gui_to_int(self.res_num_col.GetValue()) 165 res_name_col = gui_to_int(self.res_name_col.GetValue()) 166 spin_num_col = gui_to_int(self.spin_num_col.GetValue()) 167 spin_name_col = gui_to_int(self.spin_name_col.GetValue()) 168 data_col = gui_to_int(self.data_col.GetValue()) 169 err_col = gui_to_int(self.err_col.GetValue()) 170 171 # The column separator. 172 sep = str(self.sep.GetValue()) 173 if sep == 'white space': 174 sep = None 175 176 # The spin ID. 177 spin_id = gui_to_str(self.spin_id.GetValue()) 178 179 # Read the relaxation data. 180 self.execute('relax_data.read', ri_id=ri_id, ri_type=ri_type, frq=frq, file=file, spin_id_col=spin_id_col, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col, data_col=data_col, error_col=err_col, sep=sep, spin_id=spin_id)
181