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

Source Code for Module gui.user_functions.select

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 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 select user function GUI elements.""" 
 25   
 26  # Python module imports. 
 27  import wx 
 28   
 29  # relax module imports. 
 30  from prompt.select import boolean_doc 
 31   
 32  # GUI module imports. 
 33  from base import UF_base, UF_page 
 34  from gui.misc import gui_to_bool, gui_to_int, gui_to_str, str_to_gui 
 35   
 36   
 37  # The container class. 
38 -class Select(UF_base):
39 """The container class for holding all GUI elements.""" 40
41 - def all(self):
42 """The select.all user function.""" 43 44 # Execute the wizard. 45 wizard = self.create_wizard(size_x=600, size_y=300, name='select.all', uf_page=All_page, apply_button=False) 46 wizard.run()
47 48
49 - def read(self):
50 """The select.read user function.""" 51 52 # Execute the wizard. 53 wizard = self.create_wizard(size_x=900, size_y=700, name='select.read', uf_page=Read_page) 54 wizard.run()
55 56
57 - def reverse(self):
58 """The select.reverse user function.""" 59 60 # Execute the wizard. 61 wizard = self.create_wizard(size_x=700, size_y=400, name='select.reverse', uf_page=Reverse_page, apply_button=False) 62 wizard.run()
63 64
65 - def spin(self):
66 """The select.spin user function.""" 67 68 # Execute the wizard. 69 wizard = self.create_wizard(size_x=700, size_y=500, name='select.spin', uf_page=Spin_page) 70 wizard.run()
71 72 73 74
75 -class All_page(UF_page):
76 """The select.all() user function page.""" 77 78 # Some class variables. 79 uf_path = ['select', 'all'] 80
81 - def add_contents(self, sizer):
82 """Add the sequence specific GUI elements. 83 84 @param sizer: A sizer object. 85 @type sizer: wx.Sizer instance 86 """
87 88
89 - def on_execute(self):
90 """Execute the user function.""" 91 92 # Select all. 93 self.execute('select.all')
94 95 96
97 -class Read_page(UF_page):
98 """The select.read() user function page.""" 99 100 # Some class variables. 101 uf_path = ['select', 'read'] 102 height_desc = 200 103
104 - def add_contents(self, sizer):
105 """Add the sequence specific GUI elements. 106 107 @param sizer: A sizer object. 108 @type sizer: wx.Sizer instance 109 """ 110 111 # Add a file selection. 112 self.file = self.file_selection(sizer, "The selection file:", message="Selection file selection", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file']) 113 114 # The spin ID restriction. 115 self.spin_id = self.spin_id_element(sizer, desc="Restrict data loading to certain spins:") 116 117 # The boolean operator specifying how spins should be selected. 118 self.boolean = self.combo_box(sizer, "Boolean operator:", choices=['OR', 'NOR', 'AND', 'NAND', 'XOR', 'XNOR'], tooltip=boolean_doc[2]) 119 self.boolean.SetValue(str_to_gui('OR')) 120 121 # The change_all flag. 122 self.change_all = self.boolean_selector(sizer, "Change all:", tooltip=self.uf._doc_args_dict['change_all'], default=False) 123 124 # The parameter file settings. 125 self.free_file_format(sizer, data_cols=False, padding=3, spacer=0)
126 127
128 - def on_execute(self):
129 """Execute the user function.""" 130 131 # The file name. 132 file = gui_to_str(self.file.GetValue()) 133 134 # No file. 135 if not file: 136 return 137 138 # Get the column numbers. 139 spin_id_col = gui_to_int(self.spin_id_col.GetValue()) 140 mol_name_col = gui_to_int(self.mol_name_col.GetValue()) 141 res_num_col = gui_to_int(self.res_num_col.GetValue()) 142 res_name_col = gui_to_int(self.res_name_col.GetValue()) 143 spin_num_col = gui_to_int(self.spin_num_col.GetValue()) 144 spin_name_col = gui_to_int(self.spin_name_col.GetValue()) 145 146 # The column separator. 147 sep = str(self.sep.GetValue()) 148 if sep == 'white space': 149 sep = None 150 151 # The spin ID. 152 spin_id = gui_to_str(self.spin_id.GetValue()) 153 154 # The boolean operator and change_all flag. 155 boolean = gui_to_str(self.boolean.GetValue()) 156 change_all = gui_to_bool(self.change_all.GetValue()) 157 158 # Selection. 159 self.execute('select.read', 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, sep=sep, spin_id=spin_id, boolean=boolean, change_all=change_all)
160 161 162
163 -class Reverse_page(UF_page):
164 """The select.reverse() user function page.""" 165 166 # Some class variables. 167 uf_path = ['select', 'reverse'] 168
169 - def add_contents(self, sizer):
170 """Add the sequence specific GUI elements. 171 172 @param sizer: A sizer object. 173 @type sizer: wx.Sizer instance 174 """ 175 176 # The spin ID restriction. 177 self.spin_id = self.spin_id_element(sizer)
178 179
180 - def on_execute(self):
181 """Execute the user function.""" 182 183 # The spin ID. 184 spin_id = gui_to_str(self.spin_id.GetValue()) 185 186 # Select all. 187 self.execute('select.reverse', spin_id=spin_id)
188 189 190
191 -class Spin_page(UF_page):
192 """The select.spin() user function page.""" 193 194 # Some class variables. 195 uf_path = ['select', 'spin'] 196
197 - def add_contents(self, sizer):
198 """Add the sequence specific GUI elements. 199 200 @param sizer: A sizer object. 201 @type sizer: wx.Sizer instance 202 """ 203 204 # The spin ID restriction. 205 self.spin_id = self.spin_id_element(sizer) 206 207 # The boolean operator specifying how spins should be selected. 208 self.boolean = self.combo_box(sizer, "Boolean operator:", choices=['OR', 'NOR', 'AND', 'NAND', 'XOR', 'XNOR'], tooltip=boolean_doc[2]) 209 self.boolean.SetValue(str_to_gui('OR')) 210 211 # The change_all flag. 212 self.change_all = self.boolean_selector(sizer, "Change all:", tooltip=self.uf._doc_args_dict['change_all'])
213 214
215 - def on_execute(self):
216 """Execute the user function.""" 217 218 # The spin ID. 219 spin_id = gui_to_str(self.spin_id.GetValue()) 220 221 # The boolean operator and change_all flag. 222 boolean = gui_to_str(self.boolean.GetValue()) 223 change_all = gui_to_bool(self.change_all.GetValue()) 224 225 # Select all. 226 self.execute('select.spin', spin_id=spin_id, boolean=boolean, change_all=change_all)
227