Package prompt :: Module pymol_control
[hide private]
[frames] | no frames]

Source Code for Module prompt.pymol_control

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-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  """Module containing the 'pymol' user function class for interacting with PyMOL.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # relax module imports. 
 28  from base_class import User_fn_class, _build_doc 
 29  import arg_check 
 30  import colour 
 31  from generic_fns import pymol_control 
 32  from specific_fns.model_free.pymol import Pymol 
 33   
 34   
35 -class Pymol(User_fn_class):
36 """Class for interfacing with PyMOL.""" 37
38 - def cartoon(self):
39 # Function intro text. 40 if self._exec_info.intro: 41 text = self._exec_info.ps3 + "pymol.cartoon()" 42 print(text) 43 44 # Execute the functional code. 45 pymol_control.cartoon()
46 47 # The function doc info. 48 cartoon._doc_title = "Apply the PyMOL cartoon style and colour by secondary structure." 49 cartoon._doc_title_short = "PyMOL cartoon style application." 50 cartoon._doc_desc = """ 51 This applies the PyMOL cartoon style which is equivalent to hiding everything and clicking on show cartoon. It also colours the cartoon with red helices, yellow strands, and green loops. The following commands are executed: 52 53 cmd.hide('everything', file) 54 cmd.show('cartoon', file) 55 util.cbss(file, 'red', 'yellow', 'green') 56 57 where file is the file name without the '.pdb' extension. 58 """ 59 cartoon._doc_examples = """ 60 To apply this user function, type: 61 62 relax> pymol.cartoon() 63 """ 64 _build_doc(cartoon) 65 66
67 - def clear_history(self):
68 # Function intro text. 69 if self._exec_info.intro: 70 text = self._exec_info.ps3 + "pymol.clear_history()" 71 print(text) 72 73 # Execute the functional code. 74 pymol_control.clear_history()
75 76 # The function doc info. 77 clear_history._doc_title = "Clear the PyMOL command history.""" 78 clear_history._doc_title_short = "Clear PyMOL history.""" 79 clear_history._doc_desc = """ 80 This will clear the Pymol history from memory. 81 """ 82 _build_doc(clear_history) 83 84
85 - def command(self, command=None):
86 # Function intro text. 87 if self._exec_info.intro: 88 text = self._exec_info.ps3 + "pymol.command(" 89 text = text + "command=" + repr(command) + ")" 90 print(text) 91 92 # The argument checks. 93 arg_check.is_str(command, 'PyMOL command') 94 95 # Execute the functional code. 96 pymol_control.command(command=command)
97 98 # The function doc info. 99 command._doc_title = "Execute a user supplied PyMOL command." 100 command._doc_title_short = "PyMOL command execution." 101 command._doc_args = [ 102 ["command", "The PyMOL command to execute."] 103 ] 104 command._doc_desc = """ 105 This allows PyMOL commands to be passed to the program. This can be useful for automation or scripting. 106 """ 107 command._doc_examples = """ 108 To reinitialise the PyMOL instance, type: 109 110 relax> pymol.command("reinitialise") 111 """ 112 _build_doc(command) 113 114
115 - def cone_pdb(self, file=None):
116 # Function intro text. 117 if self._exec_info.intro: 118 text = self._exec_info.ps3 + "pymol.cone_pdb(" 119 text = text + "file=" + repr(file) + ")" 120 print(text) 121 122 # The argument checks. 123 arg_check.is_str(file, 'file name') 124 125 # Execute the functional code. 126 pymol_control.cone_pdb(file=file)
127 128 # The function doc info. 129 cone_pdb._doc_title = "Display the cone PDB geometric object." 130 cone_pdb._doc_title_short = "Cone PDB geometric object display." 131 cone_pdb._doc_args = [ 132 ["file", "The name of the PDB file containing the cone geometric object."] 133 ] 134 cone_pdb._doc_desc = """ 135 The PDB file containing the geometric object must be created using the complementary frame_order.cone_pdb or n_state_model.cone_pdb user functions. 136 137 The cone PDB file is read in using the command: 138 139 load file 140 141 The average CoM-pivot point vector, the residue 'AVE' is displayed using the commands: 142 143 select resn AVE 144 show sticks, 'sele' 145 color blue, 'sele' 146 147 The cone object, the residue 'CON', is displayed using the commands: 148 149 select resn CON 150 hide ('sele') 151 show sticks, 'sele' 152 color white, 'sele' 153 """ 154 _build_doc(cone_pdb) 155 156
157 - def macro_apply(self, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None):
158 # Function intro text. 159 if self._exec_info.intro: 160 text = self._exec_info.ps3 + "pymol.macro_apply(" 161 text = text + "data_type=" + repr(data_type) 162 text = text + ", style=" + repr(style) 163 text = text + ", colour_start=" + repr(colour_start) 164 text = text + ", colour_end=" + repr(colour_end) 165 text = text + ", colour_list=" + repr(colour_list) + ")" 166 print(text) 167 168 # The argument checks. 169 arg_check.is_str(data_type, 'data type') 170 arg_check.is_str(style, 'style') 171 arg_check.is_str_or_num_list(colour_start, 'starting colour of the linear gradient', size=3, can_be_none=True) 172 arg_check.is_str_or_num_list(colour_end, 'ending colour of the linear gradient', size=3, can_be_none=True) 173 arg_check.is_str(colour_list, 'colour list', can_be_none=True) 174 175 # Execute the functional code. 176 pymol_control.macro_apply(data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list)
177 178 # The function doc info. 179 macro_apply._doc_title = "Execute PyMOL macros." 180 macro_apply._doc_title_short = "PyMOL macro execution." 181 macro_apply._doc_args = [ 182 ["data_type", "The data type to map to the structure."], 183 ["style", "The style of the macro."], 184 ["colour_start", "The starting colour, either an array or string, of the linear colour gradient."], 185 ["colour_end", "The ending colour, either an array or string, of the linear colour gradient."], 186 ["colour_list", "The list of colours to match the start and end strings."] 187 ] 188 macro_apply._doc_desc = """ 189 This allows spin specific values to be mapped to a structure through PyMOL macros. Currently only the 'classic' style, which is described below, is available. 190 """ 191 macro_apply._doc_examples = """ 192 To map the order parameter values, S2, onto the structure using the classic style, type: 193 194 relax> pymol.macro_apply('s2') 195 relax> pymol.macro_apply(data_type='s2') 196 relax> pymol.macro_apply(data_type='s2', style="classic") 197 """ 198 macro_apply._doc_additional = [ 199 colour._linear_gradient_doc, 200 Pymol.classic_style_doc, 201 colour.__molmol_colours_prompt_doc__, 202 colour.__x11_colours_prompt_doc__ 203 ] 204 _build_doc(macro_apply) 205 206
207 - def macro_run(self, file=None, dir='pymol'):
208 # Function intro text. 209 if self._exec_info.intro: 210 text = self._exec_info.ps3 + "pymol.macro_run(" 211 text = text + "file=" + repr(file) 212 text = text + ", dir=" + repr(dir) + ")" 213 print(text) 214 215 # The argument checks. 216 arg_check.is_str(file, 'file name') 217 arg_check.is_str(dir, 'directory name', can_be_none=True) 218 219 # Execute the functional code. 220 pymol_control.macro_run(file=file, dir=dir)
221 222 # The function doc info. 223 macro_run._doc_title = "Open and execute the PyMOL macro file." 224 macro_run._doc_title_short = "PyMOL macro file execution." 225 macro_run._doc_args = [ 226 ["file", "The name of the PyMOL macro file."], 227 ["dir", "The directory name."], 228 ] 229 macro_run._doc_desc = """ 230 This user function is for opening and running a PyMOL macro located within a text file. 231 """ 232 macro_run._doc_examples = """ 233 To execute the macro file 's2.pml' located in the directory 'pymol', type: 234 235 relax> pymol.macro_run(file='s2.pml') 236 relax> pymol.macro_run(file='s2.pml', dir='pymol') 237 """ 238 _build_doc(macro_run) 239 240
241 - def macro_write(self, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None, file=None, dir='pymol', force=False):
242 # Function intro text. 243 if self._exec_info.intro: 244 text = self._exec_info.ps3 + "pymol.macro_write(" 245 text = text + "data_type=" + repr(data_type) 246 text = text + ", style=" + repr(style) 247 text = text + ", colour_start=" + repr(colour_start) 248 text = text + ", colour_end=" + repr(colour_end) 249 text = text + ", colour_list=" + repr(colour_list) 250 text = text + ", file=" + repr(file) 251 text = text + ", dir=" + repr(dir) 252 text = text + ", force=" + repr(force) + ")" 253 print(text) 254 255 # The argument checks. 256 arg_check.is_str(data_type, 'data type') 257 arg_check.is_str(style, 'style') 258 arg_check.is_str_or_num_list(colour_start, 'starting colour of the linear gradient', size=3, can_be_none=True) 259 arg_check.is_str_or_num_list(colour_end, 'ending colour of the linear gradient', size=3, can_be_none=True) 260 arg_check.is_str(colour_list, 'colour list', can_be_none=True) 261 arg_check.is_str_or_inst(file, 'file name', can_be_none=True) 262 arg_check.is_str(dir, 'directory name', can_be_none=True) 263 arg_check.is_bool(force, 'force flag') 264 265 # Execute the functional code. 266 pymol_control.macro_write(data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list, file=file, dir=dir, force=force)
267 268 # The function doc info. 269 macro_write._doc_title = "Create PyMOL macros." 270 macro_write._doc_title_short = "PyMOL macro creation." 271 macro_write._doc_args = [ 272 ["data_type", "The data type to map to the structure."], 273 ["style", "The style of the macro."], 274 ["colour_start", "The starting colour, either an array or string, of the linear colour gradient."], 275 ["colour_end", "The ending colour, either an array or string, of the linear colour gradient."], 276 ["colour_list", "The list of colours to match the start and end strings."], 277 ["file", "The optional name of the file."], 278 ["dir", "The optional directory to save the file to."], 279 ["force", "A flag which, if set to True, will cause the file to be overwritten."] 280 ] 281 macro_write._doc_desc = """ 282 This allows residues specific values to be mapped to a structure through the creation of a PyMOL macro which can be executed in PyMOL by clicking on 'File, Macro, Execute User...'. Currently only the 'classic' style, which is described below, is available. 283 """ 284 macro_write._doc_examples = """ 285 To create a PyMOL macro mapping the order parameter values, S2, onto the structure using 286 the classic style, type: 287 288 relax> pymol.macro_write('s2') 289 relax> pymol.macro_write(data_type='s2') 290 relax> pymol.macro_write(data_type='s2', style="classic", file='s2.pml', dir='pymol') 291 """ 292 macro_write._doc_additional = [ 293 colour._linear_gradient_doc, 294 Pymol.classic_style_doc, 295 colour.__molmol_colours_prompt_doc__, 296 colour.__x11_colours_prompt_doc__ 297 ] 298 _build_doc(macro_write) 299 300
301 - def tensor_pdb(self, file=None):
302 # Function intro text. 303 if self._exec_info.intro: 304 text = self._exec_info.ps3 + "pymol.tensor_pdb(" 305 text = text + "file=" + repr(file) + ")" 306 print(text) 307 308 # The argument checks. 309 arg_check.is_str_or_inst(file, 'file name') 310 311 # Execute the functional code. 312 pymol_control.tensor_pdb(file=file)
313 314 # The function doc info. 315 tensor_pdb._doc_title = "Display the diffusion tensor PDB geometric object over the loaded PDB." 316 tensor_pdb._doc_title_short = "Diffusion tensor and structure display." 317 tensor_pdb._doc_args = [ 318 ["file", "The name of the PDB file containing the tensor geometric object."] 319 ] 320 tensor_pdb._doc_desc = """ 321 In executing this user function, a PDB file must have previously been loaded into this data pipe a geometric object or polygon representing the Brownian rotational diffusion tensor will be overlain with the loaded PDB file and displayed within PyMOL. The PDB file containing the geometric object must be created using the complementary structure.create_diff_tensor_pdb user function. 322 323 The tensor PDB file is read in using the command: 324 325 load file 326 327 The centre of mass residue 'COM' is displayed using the commands: 328 329 select resn COM 330 show dots, 'sele' 331 color blue, 'sele' 332 333 The axes of the diffusion tensor, the residue 'AXS', is displayed using the commands: 334 335 select resn AXS 336 hide ('sele') 337 show sticks, 'sele' 338 color cyan, 'sele' 339 label 'sele', name 340 341 The simulation axes, the residues 'SIM', are displayed using the commands: 342 343 select resn SIM 344 colour cyan, 'sele' 345 """ 346 _build_doc(tensor_pdb) 347 348
349 - def vector_dist(self, file='XH_dist.pdb'):
350 # Function intro text. 351 if self._exec_info.intro: 352 text = self._exec_info.ps3 + "pymol.vector_dist(" 353 text = text + "file=" + repr(file) + ")" 354 print(text) 355 356 # The argument checks. 357 arg_check.is_str(file, 'file name') 358 359 # Execute the functional code. 360 pymol_control.vector_dist(file=file)
361 362 # The function doc info. 363 vector_dist._doc_title = "Display the PDB file representation of the XH vector distribution." 364 vector_dist._doc_title_short = "XH vector distribution display." 365 vector_dist._doc_args = [ 366 ["file", "The name of the PDB file containing the vector distribution."] 367 ] 368 vector_dist._doc_desc = """ 369 A PDB file of the macromolecule must have previously been loaded as the vector distribution will be overlain with the macromolecule within PyMOL. The PDB file containing the vector distribution must be created using the complementary structure.create_vector_dist user function. 370 371 The vector distribution PDB file is read in using the command: 372 373 load file 374 """ 375 _build_doc(vector_dist) 376 377
378 - def view(self):
379 # Function intro text. 380 if self._exec_info.intro: 381 text = self._exec_info.ps3 + "pymol.view()" 382 print(text) 383 384 # Execute the functional code. 385 pymol_control.view()
386 387 # The function doc info. 388 view._doc_title = "View the collection of molecules from the loaded PDB file." 389 view._doc_title_short = "Molecule viewing." 390 view._doc_desc = """ 391 This will simply launch Pymol. 392 """ 393 view._doc_examples = """ 394 relax> pymol.view() 395 """ 396 _build_doc(view)
397