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

Source Code for Module gui.user_functions.structure

  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 structure 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.pipes import cdp_name, pipe_names 
 33   
 34  # GUI module imports. 
 35  from base import UF_base, UF_page 
 36  from gui.misc import float_to_gui, gui_to_bool, gui_to_float, gui_to_int, gui_to_int_or_list, gui_to_str, gui_to_str_or_list, str_to_gui 
 37  from gui.paths import WIZARD_IMAGE_PATH 
 38   
 39   
 40  # The container class. 
41 -class Structure(UF_base):
42 """The container class for holding all GUI elements.""" 43
44 - def create_diff_tensor_pdb(self):
45 """The structure.create_diff_tensor_pdb user function.""" 46 47 # Create and execute the wizard. 48 wizard = self.create_wizard(size_x=900, size_y=800, name='structure.create_diff_tensor_pdb', uf_page=Create_diff_tensor_pdb_page) 49 wizard.run()
50 51
52 - def create_vector_dist(self):
53 """The structure.create_vector_dist user function.""" 54 55 # Create and execute the wizard. 56 wizard = self.create_wizard(size_x=800, size_y=700, name='structure.create_vector_dist', uf_page=Create_vector_dist_page) 57 wizard.run()
58 59
60 - def delete(self):
61 """The structure.delete user function.""" 62 63 # Create and execute the wizard. 64 wizard = self.create_wizard(size_x=600, size_y=400, name='structure.delete', uf_page=Delete_page) 65 wizard.run()
66 67
68 - def get_pos(self):
69 """The structure.get_pos user function.""" 70 71 # Create and execute the wizard. 72 wizard = self.create_wizard(size_x=800, size_y=600, name='structure.get_pos', uf_page=Get_pos_page) 73 wizard.run()
74 75
76 - def load_spins(self):
77 """The structure.load_spins user function.""" 78 79 # Create and execute the wizard. 80 wizard = self.create_wizard(size_x=800, size_y=600, name='structure.load_spins', uf_page=Load_spins_page) 81 wizard.run()
82 83
84 - def read_pdb(self):
85 """The structure.read_pdb user function.""" 86 87 # Create and execute the wizard. 88 wizard = self.create_wizard(size_x=800, size_y=600, name='structure.read_pdb', uf_page=Read_pdb_page) 89 wizard.run()
90 91
92 - def read_xyz(self):
93 """The structure.read_xyz user function.""" 94 95 # Create and execute the wizard. 96 wizard = self.create_wizard(size_x=800, size_y=600, name='structure.read_xyz', uf_page=Read_xyz_page) 97 wizard.run()
98 99
100 - def write_pdb(self):
101 """The structure.write_pdb user function.""" 102 103 # Create and execute the wizard. 104 wizard = self.create_wizard(size_x=800, size_y=600, name='structure.write_pdb', uf_page=Write_pdb_page) 105 wizard.run()
106 107
108 - def vectors(self):
109 """The structure.vectors user function.""" 110 111 # Create the wizard. 112 wizard = self.create_wizard(size_x=800, size_y=600, name='structure.vectors', uf_page=Vectors_page) 113 wizard.run()
114 115 116
117 -class Create_diff_tensor_pdb_page(UF_page):
118 """The structure.create_diff_tensor_pdb() user function page.""" 119 120 # Some class variables. 121 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'create_diff_tensor_pdb.png' 122 uf_path = ['structure', 'create_diff_tensor_pdb'] 123 height_desc = 400 124
125 - def add_contents(self, sizer):
126 """Add the structure specific GUI elements. 127 128 @param sizer: A sizer object. 129 @type sizer: wx.Sizer instance 130 """ 131 132 # The scale arg. 133 self.scale = self.input_field(sizer, "Scaling factor:", tooltip=self.uf._doc_args_dict['scale']) 134 self.scale.SetValue(float_to_gui(1.8e-6)) 135 136 # Add a file selection. 137 self.file = self.file_selection(sizer, "The PDB file:", message="PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file']) 138 139 # The force flag. 140 self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force'], default=False)
141 142
143 - def on_execute(self):
144 """Execute the user function.""" 145 146 # The file name. 147 file = gui_to_str(self.file.GetValue()) 148 if not file: 149 return 150 151 # Force flag. 152 force = gui_to_bool(self.force.GetValue()) 153 154 # The scaling. 155 scale = gui_to_float(self.scale.GetValue()) 156 157 # Delete all structures. 158 self.execute('structure.create_diff_tensor_pdb', scale=scale, file=file, force=force)
159 160 161
162 -class Create_vector_dist_page(UF_page):
163 """The structure.create_vector_dist() user function page.""" 164 165 # Some class variables. 166 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'create_vector_dist.png' 167 uf_path = ['structure', 'create_vector_dist'] 168
169 - def add_contents(self, sizer):
170 """Add the structure specific GUI elements. 171 172 @param sizer: A sizer object. 173 @type sizer: wx.Sizer instance 174 """ 175 176 # The length arg. 177 self.length = self.input_field(sizer, "Vector length:", tooltip=self.uf._doc_args_dict['length']) 178 self.length.SetValue(float_to_gui(2e-9)) 179 180 # Add a file selection. 181 self.file = self.file_selection(sizer, "The PDB file:", message="PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file']) 182 183 # The symmetry flag. 184 self.symmetry = self.boolean_selector(sizer, "Symmetry flag:", tooltip=self.uf._doc_args_dict['symmetry'], default=True) 185 186 # The force flag. 187 self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force'], default=False)
188 189
190 - def on_execute(self):
191 """Execute the user function.""" 192 193 # The file name. 194 file = gui_to_str(self.file.GetValue()) 195 if not file: 196 return 197 198 # Force flag. 199 force = gui_to_bool(self.force.GetValue()) 200 201 # The scaling. 202 length = gui_to_float(self.length.GetValue()) 203 204 # Delete all structures. 205 self.execute('structure.create_vector_dist', length=length, file=file, symmetry=symmetry, force=force)
206 207 208
209 -class Delete_page(UF_page):
210 """The structure.delete() user function page.""" 211 212 # Some class variables. 213 uf_path = ['structure', 'delete'] 214
215 - def add_contents(self, sizer):
216 """Add the structure specific GUI elements. 217 218 @param sizer: A sizer object. 219 @type sizer: wx.Sizer instance 220 """
221 222
223 - def on_execute(self):
224 """Execute the user function.""" 225 226 # Delete all structures. 227 self.execute('structure.delete')
228 229 230
231 -class Get_pos_page(UF_page):
232 """The structure.get_pos() user function page.""" 233 234 # Some class variables. 235 uf_path = ['structure', 'get_pos'] 236 height_desc = 300 237
238 - def add_contents(self, sizer):
239 """Add the structure specific GUI elements. 240 241 @param sizer: A sizer object. 242 @type sizer: wx.Sizer instance 243 """ 244 245 # The spin_id arg. 246 self.spin_id = self.spin_id_element(sizer, default='@N') 247 248 # The ave_pos arg. 249 self.ave_pos = self.boolean_selector(sizer, "Average the atom position across models:", tooltip=self.uf._doc_args_dict['ave_pos'], default=True)
250 251
252 - def on_execute(self):
253 """Execute the user function.""" 254 255 # The args. 256 spin_id = gui_to_str(self.spin_id.GetValue()) 257 ave_pos = gui_to_bool(self.ave_pos.GetValue()) 258 259 # Delete all structures. 260 self.execute('structure.get_pos', spin_id=spin_id, ave_pos=ave_pos)
261 262 263
264 -class Load_spins_page(UF_page):
265 """The structure.load_spins() user function page.""" 266 267 # Some class variables. 268 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'load_spins.png' 269 uf_path = ['structure', 'load_spins'] 270
271 - def add_contents(self, sizer):
272 """Add the structure specific GUI elements. 273 274 @param sizer: A sizer object. 275 @type sizer: wx.Sizer instance 276 """ 277 278 # The spin_id arg. 279 self.spin_id = self.spin_id_element(sizer, default='@N') 280 281 # The ave_pos arg. 282 self.ave_pos = self.boolean_selector(sizer, "Average the atom position across models:", tooltip=self.uf._doc_args_dict['ave_pos'], default=True)
283 284
285 - def on_execute(self):
286 """Execute the user function.""" 287 288 # The args. 289 spin_id = gui_to_str(self.spin_id.GetValue()) 290 ave_pos = gui_to_bool(self.ave_pos.GetValue()) 291 292 # Execute the user function. 293 self.execute('structure.load_spins', spin_id=spin_id, ave_pos=ave_pos)
294 295 296
297 -class Read_pdb_page(UF_page):
298 """The structure.read_pdb() user function page.""" 299 300 # Some class variables. 301 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'read_pdb.png' 302 uf_path = ['structure', 'read_pdb'] 303
304 - def add_contents(self, sizer):
305 """Add the structure specific GUI elements. 306 307 @param sizer: A sizer object. 308 @type sizer: wx.Sizer instance 309 """ 310 311 # Add a file selection. 312 self.file = self.file_selection(sizer, "The PDB file:", message="PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file']) 313 314 # The read_mol arg. 315 self.read_mol = self.input_field(sizer, "Read molecule number:", tooltip=self.uf._doc_args_dict['read_mol']) 316 317 # The set_mol_name arg. 318 self.set_mol_name = self.input_field(sizer, "Set the molecule name:", tooltip=self.uf._doc_args_dict['set_mol_name']) 319 320 # The read_model arg. 321 self.read_model = self.input_field(sizer, "Read model number:", tooltip=self.uf._doc_args_dict['read_model']) 322 323 # The set_model_num arg. 324 self.set_model_num = self.input_field(sizer, "Set the model number:", tooltip=self.uf._doc_args_dict['set_model_num']) 325 326 # The PDB reader (default to internal). 327 self.parser = self.combo_box(sizer, "The PDB parser:", choices=['internal', 'scientific'], tooltip=self.uf._doc_args_dict['parser']) 328 self.parser.SetValue(str_to_gui('internal'))
329 330
331 - def on_execute(self):
332 """Execute the user function.""" 333 334 # The args. 335 file = gui_to_str(self.file.GetValue()) 336 read_mol = gui_to_int_or_list(self.read_mol.GetValue()) 337 set_mol_name = gui_to_str_or_list(self.set_mol_name.GetValue()) 338 read_model = gui_to_int_or_list(self.read_model.GetValue()) 339 set_model_num = gui_to_int_or_list(self.set_model_num.GetValue()) 340 parser = gui_to_str(self.parser.GetValue()) 341 342 # Execute the user function. 343 self.execute('structure.read_pdb', file=file, read_mol=read_mol, set_mol_name=set_mol_name, read_model=read_model, set_model_num=set_model_num, parser=parser)
344 345 346
347 -class Read_xyz_page(UF_page):
348 """The structure.read_xyz() user function page.""" 349 350 # Some class variables. 351 #image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'read_xyz.png' 352 uf_path = ['structure', 'read_xyz'] 353
354 - def add_contents(self, sizer):
355 """Add the structure specific GUI elements. 356 357 @param sizer: A sizer object. 358 @type sizer: wx.Sizer instance 359 """ 360 361 # Add a file selection. 362 self.file = self.file_selection(sizer, "The XYZ file:", message="XYZ file selection", wildcard="XYZ files (*.xyz)|*.xyz;*.XYZ", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file']) 363 364 # The read_mol arg. 365 self.read_mol = self.input_field(sizer, "Read molecule number:", tooltip=self.uf._doc_args_dict['read_mol']) 366 367 # The set_mol_name arg. 368 self.set_mol_name = self.input_field(sizer, "Set the molecule name:", tooltip=self.uf._doc_args_dict['set_mol_name']) 369 370 # The read_model arg. 371 self.read_model = self.input_field(sizer, "Read model number:", tooltip=self.uf._doc_args_dict['read_model']) 372 373 # The set_model_num arg. 374 self.set_model_num = self.input_field(sizer, "Set the model number:", tooltip=self.uf._doc_args_dict['set_model_num'])
375 376
377 - def on_execute(self):
378 """Execute the user function.""" 379 380 # The args. 381 file = gui_to_str(self.file.GetValue()) 382 read_mol = gui_to_int_or_list(self.read_mol.GetValue()) 383 set_mol_name = gui_to_str_or_list(self.set_mol_name.GetValue()) 384 read_model = gui_to_int_or_list(self.read_model.GetValue()) 385 set_model_num = gui_to_int_or_list(self.set_model_num.GetValue()) 386 387 # Execute the user function. 388 self.execute('structure.read_xyz', file=file, read_mol=read_mol, set_mol_name=set_mol_name, read_model=read_model, set_model_num=set_model_num)
389 390 391
392 -class Write_pdb_page(UF_page):
393 """The structure.write_pdb() user function page.""" 394 395 # Some class variables. 396 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'write_pdb.png' 397 uf_path = ['structure', 'write_pdb'] 398
399 - def add_contents(self, sizer):
400 """Add the structure specific GUI elements. 401 402 @param sizer: A sizer object. 403 @type sizer: wx.Sizer instance 404 """ 405 406 # Add a file selection. 407 self.file = self.file_selection(sizer, "The PDB file:", message="PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file']) 408 409 # The model_num arg. 410 self.model_num = self.input_field(sizer, "Only write model number:", tooltip=self.uf._doc_args_dict['model_num'])
411 412
413 - def on_execute(self):
414 """Execute the user function.""" 415 416 # The args. 417 file = gui_to_str(self.file.GetValue()) 418 model_num = gui_to_str(self.model_num.GetValue()) 419 420 # Execute the user function. 421 self.execute('structure.write_pdb', file=file, model_num=model_num)
422 423 424
425 -class Vectors_page(UF_page):
426 """The structure.vectors() user function page.""" 427 428 # Some class variables. 429 uf_path = ['structure', 'vectors'] 430
431 - def add_contents(self, sizer):
432 """Add the structure specific GUI elements. 433 434 @param sizer: A sizer object. 435 @type sizer: wx.Sizer instance 436 """ 437 438 # The attached atom. 439 self.attached = self.input_field(sizer, "The attached atom:", tooltip=self.uf._doc_args_dict['attached']) 440 self.attached.SetValue(str_to_gui("H")) 441 442 # The spin_id arg. 443 self.spin_id = self.spin_id_element(sizer, desc='Restrict vector loading to the spins:') 444 445 # The model. 446 self.model = self.input_field(sizer, "The model:", tooltip=self.uf._doc_args_dict['model']) 447 448 # The verbosity level. 449 self.verbosity = self.spin_control(sizer, "The verbosity level:", default=1, min=0, tooltip=self.uf._doc_args_dict['verbosity']) 450 451 # The average. 452 self.ave = self.boolean_selector(sizer, "Average the vector across models:", tooltip=self.uf._doc_args_dict['ave'], default=True) 453 454 # The unit flag. 455 self.unit = self.boolean_selector(sizer, "Calculate unit vectors:", tooltip=self.uf._doc_args_dict['unit'], default=True)
456 457
458 - def on_execute(self):
459 """Execute the user function.""" 460 461 # The args. 462 attached = gui_to_str(self.attached.GetValue()) 463 spin_id = gui_to_str(self.spin_id.GetValue()) 464 model = gui_to_int(self.model.GetValue()) 465 verbosity = gui_to_int(self.verbosity.GetValue()) 466 ave = gui_to_bool(self.ave.GetValue()) 467 unit = gui_to_bool(self.unit.GetValue()) 468 469 # Execute the user function. 470 self.execute('structure.vectors', attached=attached, spin_id=spin_id, model=model, verbosity=verbosity, ave=ave, unit=unit)
471