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

Source Code for Module gui.user_functions.pymol

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2011-2012 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 pymol user function GUI elements.""" 
 25   
 26  # Python module imports. 
 27  from os import sep 
 28  import wx 
 29   
 30  # GUI module imports. 
 31  from base import UF_base, UF_page 
 32  from gui.paths import WIZARD_IMAGE_PATH 
 33  from gui.misc import gui_to_bool, gui_to_float, gui_to_int, gui_to_str, str_to_gui 
 34   
 35   
 36  # The container class. 
37 -class Pymol(UF_base):
38 """The container class for holding all GUI elements.""" 39
40 - def clear_history(self):
41 """The pymol.clear_history user function.""" 42 43 # Execute the wizard. 44 wizard = self.create_wizard(size_x=600, size_y=300, name='pymol.clear_history', uf_page=Clear_history_page, apply_button=False) 45 wizard.run()
46 47
48 - def command(self):
49 """The pymol.command user function.""" 50 51 # Execute the wizard. 52 wizard = self.create_wizard(size_x=700, size_y=400, name='pymol.command', uf_page=Command_page) 53 wizard.run()
54 55
56 - def macro_apply(self):
57 """The pymol.macro_apply user function.""" 58 59 # Execute the wizard. 60 wizard = self.create_wizard(size_x=1000, size_y=750, name='pymol.macro_apply', uf_page=Macro_apply_page) 61 wizard.run()
62 63
64 - def macro_run(self, file=None):
65 """The pymol.macro_run user function. 66 67 @keyword file: The macro file to start the user function with. 68 @type file: str 69 """ 70 71 # Create the wizard. 72 wizard, page = self.create_wizard(size_x=800, size_y=400, name='pymol.macro_run', uf_page=Macro_run_page, return_page=True) 73 74 # Default file name. 75 if file: 76 page.file.SetValue(str_to_gui(file)) 77 78 # Execute the wizard. 79 wizard.run()
80 81
82 - def macro_write(self):
83 """The pymol.macro_write user function.""" 84 85 # Execute the wizard. 86 wizard = self.create_wizard(size_x=1000, size_y=750, name='pymol.macro_write', uf_page=Macro_write_page) 87 wizard.run()
88 89
90 - def ribbon(self):
91 """The pymol.ribbon user function.""" 92 93 # Execute the wizard. 94 wizard = self.create_wizard(size_x=700, size_y=400, name='pymol.ribbon', uf_page=Ribbon_page, apply_button=False) 95 wizard.run()
96 97
98 - def tensor_pdb(self):
99 """The pymol.tensor_pdb user function.""" 100 101 # Execute the wizard. 102 wizard = self.create_wizard(size_x=1000, size_y=700, name='pymol.tensor_pdb', uf_page=Tensor_pdb_page, apply_button=False) 103 wizard.run()
104 105
106 - def view(self):
107 """The pymol.view user function.""" 108 109 # Execute the wizard. 110 wizard = self.create_wizard(size_x=600, size_y=300, name='pymol.view', uf_page=View_page, apply_button=False) 111 wizard.run()
112 113 114
115 -class Clear_history_page(UF_page):
116 """The pymol.clear_history() user function page.""" 117 118 # Some class variables. 119 image_path = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png' 120 uf_path = ['pymol', 'clear_history'] 121
122 - def add_contents(self, sizer):
123 """Add the specific GUI elements. 124 125 @param sizer: A sizer object. 126 @type sizer: wx.Sizer instance 127 """
128 129
130 - def on_execute(self):
131 """Execute the user function.""" 132 133 # Execute the user function. 134 self.execute('pymol.clear_history')
135 136 137
138 -class Command_page(UF_page):
139 """The pymol.command() user function page.""" 140 141 # Some class variables. 142 image_path = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png' 143 uf_path = ['pymol', 'command'] 144
145 - def add_contents(self, sizer):
146 """Add the specific GUI elements. 147 148 @param sizer: A sizer object. 149 @type sizer: wx.Sizer instance 150 """ 151 152 # The command. 153 self.command = self.input_field(sizer, "The PyMOL command:", tooltip=self.uf._doc_args_dict['command'])
154 155
156 - def on_execute(self):
157 """Execute the user function.""" 158 159 # Get the values. 160 command = gui_to_str(self.command.GetValue()) 161 162 # Execute the user function. 163 self.execute('pymol.command', command=command)
164 165 166
167 -class Macro_apply_page(UF_page):
168 """The pymol.macro_apply() user function page.""" 169 170 # Some class variables. 171 image_path = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png' 172 uf_path = ['pymol', 'macro_apply'] 173 height_desc = 450 174
175 - def add_contents(self, sizer):
176 """Add the specific GUI elements. 177 178 @param sizer: A sizer object. 179 @type sizer: wx.Sizer instance 180 """ 181 182 # The data type. 183 self.data_type = self.combo_box(sizer, "The data type:", choices=['s2', 's2f', 's2s', 'amp_fast', 'amp_slow', 'te', 'tf', 'ts', 'time_fast', 'time_slow', 'rex'], tooltip=self.uf._doc_args_dict['data_type']) 184 185 # The style. 186 self.style = self.input_field(sizer, "The style:", tooltip=self.uf._doc_args_dict['style']) 187 self.style.SetValue(str_to_gui("classic")) 188 189 # The starting colour. 190 self.colour_start = self.input_field(sizer, "The starting colour:", tooltip=self.uf._doc_args_dict['colour_start']) 191 192 # The ending colour. 193 self.colour_end = self.input_field(sizer, "The ending colour:", tooltip=self.uf._doc_args_dict['colour_end']) 194 195 # The colour list. 196 self.colour_list = self.input_field(sizer, "The colour list:", tooltip=self.uf._doc_args_dict['colour_list'])
197 198
199 - def on_execute(self):
200 """Execute the user function.""" 201 202 # Get the values. 203 data_type = gui_to_str(self.data_type.GetValue()) 204 style = gui_to_str(self.style.GetValue()) 205 colour_start = gui_to_str(self.colour_start.GetValue()) 206 colour_end = gui_to_str(self.colour_end.GetValue()) 207 colour_list = gui_to_str(self.colour_list.GetValue()) 208 209 # Execute the user function. 210 self.execute('pymol.macro_apply', data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list)
211 212 213
214 -class Ribbon_page(UF_page):
215 """The pymol.ribbon() user function page.""" 216 217 # Some class variables. 218 image_path = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png' 219 uf_path = ['pymol', 'ribbon'] 220
221 - def add_contents(self, sizer):
222 """Add the specific GUI elements. 223 224 @param sizer: A sizer object. 225 @type sizer: wx.Sizer instance 226 """
227 228
229 - def on_execute(self):
230 """Execute the user function.""" 231 232 # Execute the user function. 233 self.execute('pymol.ribbon')
234 235 236
237 -class Macro_run_page(UF_page):
238 """The pymol.macro_run() user function page.""" 239 240 # Some class variables. 241 image_path = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png' 242 uf_path = ['pymol', 'macro_run'] 243
244 - def add_contents(self, sizer):
245 """Add the specific GUI elements. 246 247 @param sizer: A sizer object. 248 @type sizer: wx.Sizer instance 249 """ 250 251 # Add a file selection. 252 self.file = self.file_selection(sizer, "The macro file:", message="PyMOL macro file selection", wildcard="PyMOL macro files (*.pml)|*.pml;*.PML", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
253 254
255 - def on_execute(self):
256 """Execute the user function.""" 257 258 # The file name. 259 file = gui_to_str(self.file.GetValue()) 260 if not file: 261 return 262 263 # Execute the user function. 264 self.execute('pymol.macro_run', file=file, dir=None)
265 266 267
268 -class Macro_write_page(UF_page):
269 """The pymol.macro_write() user function page.""" 270 271 # Some class variables. 272 image_path = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png' 273 uf_path = ['pymol', 'macro_write'] 274 height_desc = 400 275
276 - def add_contents(self, sizer):
277 """Add the specific GUI elements. 278 279 @param sizer: A sizer object. 280 @type sizer: wx.Sizer instance 281 """ 282 283 # Add a file selection. 284 self.file = self.file_selection(sizer, "The macro file:", message="PyMOL macro file selection", wildcard="PyMOL macro files (*.pml)|*.pml;*.PML", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file']) 285 286 # The force flag. 287 self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force'], default=True) 288 289 # The data type. 290 self.data_type = self.combo_box(sizer, "The data type:", choices=['s2', 's2f', 's2s', 'amp_fast', 'amp_slow', 'te', 'tf', 'ts', ' time_fast', 'time_slow', 'rex'], tooltip=self.uf._doc_args_dict['data_type']) 291 292 # The style. 293 self.style = self.input_field(sizer, "The style:", tooltip=self.uf._doc_args_dict['style']) 294 self.style.SetValue(str_to_gui("classic")) 295 296 # The starting colour. 297 self.colour_start = self.input_field(sizer, "The starting colour:", tooltip=self.uf._doc_args_dict['colour_start']) 298 299 # The ending colour. 300 self.colour_end = self.input_field(sizer, "The ending colour:", tooltip=self.uf._doc_args_dict['colour_end']) 301 302 # The colour list. 303 self.colour_list = self.input_field(sizer, "The colour list:", tooltip=self.uf._doc_args_dict['colour_list'])
304 305
306 - def on_execute(self):
307 """Execute the user function.""" 308 309 # The file name. 310 file = gui_to_str(self.file.GetValue()) 311 312 # Force flag. 313 force = gui_to_bool(self.force.GetValue()) 314 315 # Get the values. 316 data_type = gui_to_str(self.data_type.GetValue()) 317 style = gui_to_str(self.style.GetValue()) 318 colour_start = gui_to_str(self.colour_start.GetValue()) 319 colour_end = gui_to_str(self.colour_end.GetValue()) 320 colour_list = gui_to_str(self.colour_list.GetValue()) 321 322 # Execute the user function. 323 self.execute('pymol.macro_write', data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list, file=file, dir=None, force=force)
324 325 326
327 -class Tensor_pdb_page(UF_page):
328 """The pymol.tensor_pdb() user function page.""" 329 330 # Some class variables. 331 image_path = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png' 332 uf_path = ['pymol', 'tensor_pdb'] 333 height_desc = 450 334
335 - def add_contents(self, sizer):
336 """Add the specific GUI elements. 337 338 @param sizer: A sizer object. 339 @type sizer: wx.Sizer instance 340 """ 341 342 # Add a file selection. 343 self.file = self.file_selection(sizer, "The tensor PDB file:", message="Tensor PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
344 345
346 - def on_execute(self):
347 """Execute the user function.""" 348 349 # The file name. 350 file = gui_to_str(self.file.GetValue()) 351 352 # No file. 353 if not file: 354 return 355 356 # Execute the user function. 357 self.execute('pymol.tensor_pdb', file=file)
358 359 360
361 -class View_page(UF_page):
362 """The pymol.view() user function page.""" 363 364 # Some class variables. 365 image_path = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png' 366 uf_path = ['pymol', 'view'] 367
368 - def add_contents(self, sizer):
369 """Add the specific GUI elements. 370 371 @param sizer: A sizer object. 372 @type sizer: wx.Sizer instance 373 """
374 375
376 - def on_execute(self):
377 """Execute the user function.""" 378 379 # Execute the user function. 380 self.execute('pymol.view')
381