1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The pymol user function definitions for interacting with PyMOL."""
24
25
26 from os import sep
27 import dep_check
28 if dep_check.wx_module:
29 from wx import FD_OPEN, FD_SAVE
30 else:
31 FD_OPEN = -1
32 FD_SAVE = -1
33
34
35 import colour
36 from graphics import WIZARD_IMAGE_PATH
37 from pipe_control import pymol_control
38 from specific_analyses.model_free.uf import classic_style_doc
39 from user_functions.data import Uf_info; uf_info = Uf_info()
40 from user_functions.objects import Desc_container
41 from user_functions.wildcards import WILDCARD_PYMOL_MACRO, WILDCARD_STRUCT_PDB_ALL
42
43
44
45 uf_class = uf_info.add_class('pymol')
46 uf_class.title = "Class for interfacing with PyMOL."
47 uf_class.menu_text = "&pymol"
48 uf_class.gui_icon = "relax.pymol_icon"
49
50
51
52 uf = uf_info.add_uf('pymol.cartoon')
53 uf.title = "Apply the PyMOL cartoon style and colour by secondary structure."
54 uf.title_short = "PyMOL cartoon style application."
55
56 uf.desc.append(Desc_container())
57 uf.desc[-1].add_paragraph("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:")
58 uf.desc[-1].add_list_element("cmd.hide('everything', file)")
59 uf.desc[-1].add_list_element("cmd.show('cartoon', file)")
60 uf.desc[-1].add_list_element("util.cbss(file, 'red', 'yellow', 'green')")
61 uf.desc[-1].add_paragraph("where file is the file name without the '.pdb' extension.")
62
63 uf.desc.append(Desc_container("Prompt examples"))
64 uf.desc[-1].add_paragraph("To apply this user function, type:")
65 uf.desc[-1].add_prompt("relax> pymol.cartoon()")
66 uf.backend = pymol_control.cartoon
67 uf.menu_text = "cart&oon"
68 uf.wizard_size = (700, 500)
69 uf.wizard_height_desc = 450
70 uf.wizard_apply_button = False
71 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
72
73
74
75 uf = uf_info.add_uf('pymol.clear_history')
76 uf.title = "Clear the PyMOL command history."""
77 uf.title_short = "Clear PyMOL history."""
78
79 uf.desc.append(Desc_container())
80 uf.desc[-1].add_paragraph("This will clear the Pymol history from memory.")
81 uf.backend = pymol_control.pymol_obj.clear_history
82 uf.menu_text = "clear_&history"
83 uf.wizard_size = (600, 350)
84 uf.wizard_apply_button = False
85 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
86
87
88
89 uf = uf_info.add_uf('pymol.command')
90 uf.title = "Execute a user supplied PyMOL command."
91 uf.title_short = "PyMOL command execution."
92 uf.add_keyarg(
93 name = "command",
94 py_type = "str",
95 desc_short = "PyMOL command",
96 desc = "The PyMOL command to execute."
97 )
98
99 uf.desc.append(Desc_container())
100 uf.desc[-1].add_paragraph("This allows PyMOL commands to be passed to the program. This can be useful for automation or scripting.")
101
102 uf.desc.append(Desc_container("Prompt examples"))
103 uf.desc[-1].add_paragraph("To reinitialise the PyMOL instance, type:")
104 uf.desc[-1].add_prompt("relax> pymol.command(\"reinitialise\")")
105 uf.backend = pymol_control.command
106 uf.menu_text = "&command"
107 uf.gui_icon = "oxygen.actions.edit-rename"
108 uf.wizard_size = (700, 400)
109 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
110
111
112
113 uf = uf_info.add_uf('pymol.cone_pdb')
114 uf.title = "Display the cone PDB geometric object."
115 uf.title_short = "Cone PDB geometric object display."
116 uf.add_keyarg(
117 name = "file",
118 py_type = "str",
119 arg_type = "file sel",
120 desc_short = "file name",
121 desc = "The name of the PDB file containing the cone geometric object.",
122 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
123 wiz_filesel_style = FD_OPEN
124 )
125
126 uf.desc.append(Desc_container())
127 uf.desc[-1].add_paragraph("The PDB file containing the geometric object must be created using the complementary n_state_model.cone_pdb user function.")
128 uf.desc[-1].add_paragraph("The cone PDB file is read in using the command:")
129 uf.desc[-1].add_list_element("load file")
130 uf.desc[-1].add_paragraph("The average CoM-pivot point vector, the residue 'AVE' is displayed using the commands:")
131 uf.desc[-1].add_list_element("select resn AVE")
132 uf.desc[-1].add_list_element("show sticks, 'sele'")
133 uf.desc[-1].add_list_element("color blue, 'sele'")
134 uf.desc[-1].add_paragraph("The cone object, the residue 'CON', is displayed using the commands:")
135 uf.desc[-1].add_list_element("select resn CON")
136 uf.desc[-1].add_list_element("hide ('sele')")
137 uf.desc[-1].add_list_element("show sticks, 'sele'")
138 uf.desc[-1].add_list_element("color white, 'sele'")
139 uf.backend = pymol_control.cone_pdb
140 uf.menu_text = "cone_&pdb"
141 uf.wizard_height_desc = 500
142 uf.wizard_size = (900, 700)
143 uf.wizard_apply_button = False
144 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
145
146
147
148 uf = uf_info.add_uf('pymol.frame_order')
149 uf.title = "Display the frame order results from the frame_order.pdb_model and frame_order.simulate user functions."
150 uf.title_short = "Frame order results display."
151 uf.add_keyarg(
152 name = "ave_pos",
153 default = "ave_pos",
154 py_type = "str",
155 arg_type = "str",
156 desc_short = "average structure file root",
157 desc = "The file root of the 3D structure PDB file for the molecular structure with the moving domains shifted to the average position.",
158 can_be_none = True
159 )
160 uf.add_keyarg(
161 name = "rep",
162 default = "frame_order",
163 py_type = "str",
164 arg_type = "str",
165 desc_short = "PDB representation file root",
166 desc = "The file root of the PDB file for the geometric object representation of the frame order dynamics.",
167 can_be_none = True
168 )
169 uf.add_keyarg(
170 name = "sim",
171 default = "simulation.pdb.gz",
172 py_type = "str",
173 arg_type = "file sel",
174 desc_short = "Brownian simulation file",
175 desc = "The full name the Brownian simulation PDB file.",
176 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
177 wiz_filesel_style = FD_OPEN,
178 wiz_filesel_preview = False,
179 can_be_none = True
180 )
181 uf.add_keyarg(
182 name = "dir",
183 py_type = "str",
184 arg_type = "dir",
185 desc_short = "directory name",
186 desc = "The directory where the files are located.",
187 can_be_none = True
188 )
189
190 uf.desc.append(Desc_container())
191 uf.desc[-1].add_paragraph("This user function is designed to be combined with the frame_order.pdb_model and frame_order.simulate user functions. It will take the two PDB representations created by frame_order.pdb_model, the molecular structure with the averaged domain positions and the frame order dynamics representation files, and the Brownian simulation PDB file and display them in PyMOL. Rather than loading the three representations into PyMOL manually, this user function will change the representation to improve visualisation.")
192 uf.desc[-1].add_paragraph("For the PDB files, if the file roots are left to the defaults then the following files will be loaded:")
193 uf.desc[-1].add_item_list_element("Average position", "The default is to load the 'ave_pos.pdb' and 'ave_pos_sim.pdb' files.")
194 uf.desc[-1].add_item_list_element("Frame order motional representation", "The is to load the 'frame_order.pdb', 'frame_order_A.pdb', 'frame_order_B.pdb', 'frame_order_sim.pdb', 'frame_order_sim_A.pdb' and 'frame_order_sim_B.pdb' files, if present.")
195 uf.desc[-1].add_item_list_element("Brownian simulation", "The default is to load the 'simulation.pdb.gz' file.")
196 uf.desc[-1].add_paragraph("The user function will not only search for these files, but also all *.gz and *.bz2 versions of the average position and frame order representations. This is to support all output files from the frame_order.pdb_model user function.")
197 uf.backend = pymol_control.frame_order
198 uf.menu_text = "&frame_order"
199 uf.gui_icon = "relax.frame_order"
200 uf.wizard_height_desc = 400
201 uf.wizard_size = (1000, 700)
202 uf.wizard_apply_button = False
203 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
204
205
206
207 uf = uf_info.add_uf('pymol.macro_apply')
208 uf.title = "Execute PyMOL macros."
209 uf.title_short = "PyMOL macro execution."
210 uf.display = True
211 uf.add_keyarg(
212 name = "data_type",
213 py_type = "str",
214 desc_short = "data type",
215 desc = "The data type to map to the structure."
216 )
217 uf.add_keyarg(
218 name = "style",
219 default = "classic",
220 py_type = "str",
221 desc_short = "style",
222 desc = "The style of the macro.",
223 wiz_element_type = "combo",
224 wiz_combo_choices = ["classic"],
225 wiz_read_only = True,
226 )
227 uf.add_keyarg(
228 name = "colour_start_name",
229 py_type = "str",
230 desc_short = "starting colour (by name)",
231 desc = "The name of the starting colour of the linear colour gradient. This can be either one of the X11 or one of the Molmol colour names listed in the description. If this is set, then the starting colour RGB colour array cannot be given.",
232 can_be_none = True
233 )
234 uf.add_keyarg(
235 name = "colour_start_rgb",
236 py_type = "num_list",
237 dim = 3,
238 desc_short = "starting colour (RGB colour array)",
239 desc = "The starting colour of the linear colour gradient. This is an RGB colour array with values ranging from 0 to 1. If this is set, then the starting colour name cannot be given.",
240 can_be_none = True
241 )
242 uf.add_keyarg(
243 name = "colour_end_name",
244 py_type = "str",
245 desc_short = "ending colour (by name)",
246 desc = "The name of the ending colour of the linear colour gradient. This can be either one of the X11 or one of the Molmol colour names listed in the description. If this is set, then the ending colour RGB colour array cannot be given.",
247 can_be_none = True
248 )
249 uf.add_keyarg(
250 name = "colour_end_rgb",
251 py_type = "num_list",
252 dim = 3,
253 desc_short = "ending colour (RGB colour array)",
254 desc = "The ending colour of the linear colour gradient. This is an RGB colour array with values ranging from 0 to 1. If this is set, then the ending colour name cannot be given.",
255 can_be_none = True
256 )
257 uf.add_keyarg(
258 name = "colour_list",
259 py_type = "str",
260 desc_short = "colour list",
261 desc = "The colour list to search for the colour names. This can be either 'molmol' or 'x11'.",
262 wiz_element_type = "combo",
263 wiz_combo_choices = ["molmol", "x11"],
264 wiz_read_only = True,
265 can_be_none = True
266 )
267
268 uf.desc.append(Desc_container())
269 uf.desc[-1].add_paragraph("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.")
270 uf.desc.append(colour._linear_gradient_doc)
271 uf.desc.append(classic_style_doc)
272 uf.desc.append(colour.__molmol_colours_doc__)
273 uf.desc.append(colour.__x11_colours_doc__)
274
275 uf.desc.append(Desc_container("Prompt examples"))
276 uf.desc[-1].add_paragraph("To map the order parameter values, S2, onto the structure using the classic style, type:")
277 uf.desc[-1].add_prompt("relax> pymol.macro_apply('s2')")
278 uf.desc[-1].add_prompt("relax> pymol.macro_apply(data_type='s2')")
279 uf.desc[-1].add_prompt("relax> pymol.macro_apply(data_type='s2', style=\"classic\")")
280 uf.backend = pymol_control.macro_apply
281 uf.menu_text = "¯o_apply"
282 uf.gui_icon = "relax.pymol_icon"
283 uf.wizard_height_desc = 400
284 uf.wizard_size = (1000, 750)
285 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
286
287
288
289 uf = uf_info.add_uf('pymol.macro_run')
290 uf.title = "Open and execute the PyMOL macro file."
291 uf.title_short = "PyMOL macro file execution."
292 uf.display = True
293 uf.add_keyarg(
294 name = "file",
295 py_type = "str",
296 arg_type = "file sel",
297 desc_short = "file name",
298 desc = "The name of the PyMOL macro file.",
299 wiz_filesel_wildcard = WILDCARD_PYMOL_MACRO,
300 wiz_filesel_style = FD_OPEN
301 )
302 uf.add_keyarg(
303 name = "dir",
304 default = "pymol",
305 py_type = "str",
306 arg_type = "dir",
307 desc_short = "directory name",
308 desc = "The directory name.",
309 can_be_none = True
310 )
311
312 uf.desc.append(Desc_container())
313 uf.desc[-1].add_paragraph("This user function is for opening and running a PyMOL macro located within a text file.")
314
315 uf.desc.append(Desc_container("Prompt examples"))
316 uf.desc[-1].add_paragraph("To execute the macro file 's2.pml' located in the directory 'pymol', type:")
317 uf.desc[-1].add_prompt("relax> pymol.macro_run(file='s2.pml')")
318 uf.desc[-1].add_prompt("relax> pymol.macro_run(file='s2.pml', dir='pymol')")
319 uf.backend = pymol_control.macro_run
320 uf.menu_text = "macro_&run"
321 uf.gui_icon = "oxygen.actions.document-open"
322 uf.wizard_size = (700, 400)
323 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
324
325
326
327 uf = uf_info.add_uf('pymol.macro_write')
328 uf.title = "Create PyMOL macros."
329 uf.title_short = "PyMOL macro creation."
330 uf.add_keyarg(
331 name = "data_type",
332 py_type = "str",
333 desc_short = "data type",
334 desc = "The data type to map to the structure."
335 )
336 uf.add_keyarg(
337 name = "style",
338 default = "classic",
339 py_type = "str",
340 desc_short = "style",
341 desc = "The style of the macro.",
342 wiz_element_type = "combo",
343 wiz_combo_choices = ["classic"],
344 wiz_read_only = True,
345 )
346 uf.add_keyarg(
347 name = "colour_start_name",
348 py_type = "str",
349 desc_short = "starting colour (by name)",
350 desc = "The name of the starting colour of the linear colour gradient. This can be either one of the X11 or one of the Molmol colour names listed in the description. If this is set, then the starting colour RGB colour array cannot be given.",
351 can_be_none = True
352 )
353 uf.add_keyarg(
354 name = "colour_start_rgb",
355 py_type = "num_list",
356 dim = 3,
357 desc_short = "starting colour (RGB colour array)",
358 desc = "The starting colour of the linear colour gradient. This is an RGB colour array with values ranging from 0 to 1. If this is set, then the starting colour name cannot be given.",
359 can_be_none = True
360 )
361 uf.add_keyarg(
362 name = "colour_end_name",
363 py_type = "str",
364 desc_short = "ending colour (by name)",
365 desc = "The name of the ending colour of the linear colour gradient. This can be either one of the X11 or one of the Molmol colour names listed in the description. If this is set, then the ending colour RGB colour array cannot be given.",
366 can_be_none = True
367 )
368 uf.add_keyarg(
369 name = "colour_end_rgb",
370 py_type = "num_list",
371 dim = 3,
372 desc_short = "ending colour (RGB colour array)",
373 desc = "The ending colour of the linear colour gradient. This is an RGB colour array with values ranging from 0 to 1. If this is set, then the ending colour name cannot be given.",
374 can_be_none = True
375 )
376 uf.add_keyarg(
377 name = "colour_list",
378 py_type = "str",
379 desc_short = "colour list",
380 desc = "The colour list to search for the colour names. This can be either 'molmol' or 'x11'.",
381 wiz_element_type = "combo",
382 wiz_combo_choices = ["molmol", "x11"],
383 wiz_read_only = True,
384 can_be_none = True
385 )
386 uf.add_keyarg(
387 name = "file",
388 py_type = "str",
389 arg_type = "file sel",
390 desc_short = "file name",
391 desc = "The optional name of the file.",
392 wiz_filesel_wildcard = WILDCARD_PYMOL_MACRO,
393 wiz_filesel_style = FD_SAVE,
394 can_be_none = True
395 )
396 uf.add_keyarg(
397 name = "dir",
398 default = "pymol",
399 py_type = "str",
400 arg_type = "dir",
401 desc_short = "directory name",
402 desc = "The optional directory to save the file to.",
403 can_be_none = True
404 )
405 uf.add_keyarg(
406 name = "force",
407 default = False,
408 py_type = "bool",
409 desc_short = "force flag",
410 desc = "A flag which, if set to True, will cause the file to be overwritten."
411 )
412
413 uf.desc.append(Desc_container())
414 uf.desc[-1].add_paragraph("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.")
415 uf.desc.append(colour._linear_gradient_doc)
416 uf.desc.append(classic_style_doc)
417 uf.desc.append(colour.__molmol_colours_doc__)
418 uf.desc.append(colour.__x11_colours_doc__)
419
420 uf.desc.append(Desc_container("Prompt examples"))
421 uf.desc[-1].add_paragraph("To create a PyMOL macro mapping the order parameter values, S2, onto the structure using the classic style, type:")
422 uf.desc[-1].add_prompt("relax> pymol.macro_write('s2')")
423 uf.desc[-1].add_prompt("relax> pymol.macro_write(data_type='s2')")
424 uf.desc[-1].add_prompt("relax> pymol.macro_write(data_type='s2', style=\"classic\", file='s2.pml', dir='pymol')")
425 uf.backend = pymol_control.macro_write
426 uf.menu_text = "macro_&write"
427 uf.gui_icon = "oxygen.actions.document-save"
428 uf.wizard_height_desc = 330
429 uf.wizard_size = (1000, 750)
430 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
431
432
433
434 uf = uf_info.add_uf('pymol.tensor_pdb')
435 uf.title = "Display the diffusion tensor PDB geometric object over the loaded PDB."
436 uf.title_short = "Diffusion tensor and structure display."
437 uf.add_keyarg(
438 name = "file",
439 py_type = "str_or_inst",
440 arg_type = "file sel",
441 desc_short = "file name",
442 desc = "The name of the PDB file containing the tensor geometric object.",
443 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
444 wiz_filesel_style = FD_OPEN
445 )
446
447 uf.desc.append(Desc_container())
448 uf.desc[-1].add_paragraph("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.")
449 uf.desc[-1].add_paragraph("The tensor PDB file is read in using the command:")
450 uf.desc[-1].add_list_element("load file")
451 uf.desc[-1].add_paragraph("The centre of mass residue 'COM' is displayed using the commands:")
452 uf.desc[-1].add_list_element("select resn COM")
453 uf.desc[-1].add_list_element("show dots, 'sele'")
454 uf.desc[-1].add_list_element("color blue, 'sele'")
455 uf.desc[-1].add_paragraph("The axes of the diffusion tensor, the residue 'AXS', is displayed using the commands:")
456 uf.desc[-1].add_list_element("select resn AXS")
457 uf.desc[-1].add_list_element("hide ('sele')")
458 uf.desc[-1].add_list_element("show sticks, 'sele'")
459 uf.desc[-1].add_list_element("color cyan, 'sele'")
460 uf.desc[-1].add_list_element("label 'sele', name")
461 uf.desc[-1].add_paragraph("The simulation axes, the residues 'SIM', are displayed using the commands:")
462 uf.desc[-1].add_list_element("select resn SIM")
463 uf.desc[-1].add_list_element("colour cyan, 'sele'")
464 uf.backend = pymol_control.tensor_pdb
465 uf.menu_text = "&tensor_pdb"
466 uf.wizard_height_desc = 550
467 uf.wizard_size = (1000, 750)
468 uf.wizard_apply_button = False
469 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
470
471
472
473 uf = uf_info.add_uf('pymol.vector_dist')
474 uf.title = "Display the PDB file representation of the XH vector distribution."
475 uf.title_short = "XH vector distribution display."
476 uf.add_keyarg(
477 name = "file",
478 default = "XH_dist.pdb",
479 py_type = "str",
480 arg_type = "file sel",
481 desc_short = "file name",
482 desc = "The name of the PDB file containing the vector distribution.",
483 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
484 wiz_filesel_style = FD_OPEN
485 )
486
487 uf.desc.append(Desc_container())
488 uf.desc[-1].add_paragraph("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.")
489 uf.desc[-1].add_paragraph("The vector distribution PDB file is read in using the command:")
490 uf.desc[-1].add_list_element("load file")
491 uf.backend = pymol_control.vector_dist
492 uf.menu_text = "vector_&dist"
493 uf.wizard_size = (800, 500)
494 uf.wizard_height_desc = 450
495 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
496
497
498 uf = uf_info.add_uf('pymol.view')
499 uf.title = "View the collection of molecules from the loaded PDB file."
500 uf.title_short = "Molecule viewing."
501
502 uf.desc.append(Desc_container())
503 uf.desc[-1].add_paragraph("This will simply launch Pymol.")
504
505 uf.desc.append(Desc_container("Prompt examples"))
506 uf.desc[-1].add_prompt("relax> pymol.view()")
507 uf.backend = pymol_control.view
508 uf.menu_text = "&view"
509 uf.wizard_size = (600, 350)
510 uf.wizard_apply_button = False
511 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
512