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 user function."
150 uf.title_short = "Frame order results display."
151 uf.add_keyarg(
152 name = "ave_pos_file",
153 default = "ave_pos.pdb",
154 py_type = "str",
155 arg_type = "file sel",
156 desc_short = "average structure file name",
157 desc = "The name of the 3D structure PDB file for the molecular structure with the moving domains shifted to the average position.",
158 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
159 wiz_filesel_style = FD_OPEN,
160 can_be_none = True
161 )
162 uf.add_keyarg(
163 name = "rep_file",
164 default = "frame_order.pdb",
165 py_type = "str",
166 arg_type = "file sel",
167 desc_short = "PDB representation file name",
168 desc = "The name of the PDB file for the geometric object representation of the frame order dynamics.",
169 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
170 wiz_filesel_style = FD_OPEN,
171 can_be_none = True
172 )
173 uf.add_keyarg(
174 name = "dist_file",
175 default = "domain_distribution.pdb",
176 py_type = "str",
177 arg_type = "file sel",
178 desc_short = "distribution file name",
179 desc = "The name of the file which will contain multiple models spanning the full dynamics distribution of the frame order model.",
180 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
181 wiz_filesel_style = FD_OPEN,
182 can_be_none = True
183 )
184 uf.add_keyarg(
185 name = "dir",
186 py_type = "str",
187 arg_type = "dir",
188 desc_short = "directory name",
189 desc = "The directory where the file is to be located.",
190 can_be_none = True
191 )
192
193 uf.desc.append(Desc_container())
194 uf.desc[-1].add_paragraph("This user function is designed to be combined with the frame_order.pdb_model user function. It will take the three PDB files created by frame_order.pdb_model - the molecular structure with the averaged domain positions, the frame order dynamics representation file, and the moving domain distribution file - and display them in PyMOL. Rather than loading the three files into PyMOL manually, this user function will change the representation to significantly improve the visualisation.")
195 uf.backend = pymol_control.frame_order
196 uf.menu_text = "&frame_order"
197 uf.gui_icon = "relax.frame_order"
198 uf.wizard_size = (900, 600)
199 uf.wizard_apply_button = False
200 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
201
202
203
204 uf = uf_info.add_uf('pymol.macro_apply')
205 uf.title = "Execute PyMOL macros."
206 uf.title_short = "PyMOL macro execution."
207 uf.display = True
208 uf.add_keyarg(
209 name = "data_type",
210 py_type = "str",
211 desc_short = "data type",
212 desc = "The data type to map to the structure."
213 )
214 uf.add_keyarg(
215 name = "style",
216 default = "classic",
217 py_type = "str",
218 desc_short = "style",
219 desc = "The style of the macro.",
220 wiz_element_type = "combo",
221 wiz_combo_choices = ["classic"],
222 wiz_read_only = True,
223 )
224 uf.add_keyarg(
225 name = "colour_start_name",
226 py_type = "str",
227 desc_short = "starting colour (by name)",
228 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.",
229 can_be_none = True
230 )
231 uf.add_keyarg(
232 name = "colour_start_rgb",
233 py_type = "num_list",
234 dim = 3,
235 desc_short = "starting colour (RGB colour array)",
236 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.",
237 can_be_none = True
238 )
239 uf.add_keyarg(
240 name = "colour_end_name",
241 py_type = "str",
242 desc_short = "ending colour (by name)",
243 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.",
244 can_be_none = True
245 )
246 uf.add_keyarg(
247 name = "colour_end_rgb",
248 py_type = "num_list",
249 dim = 3,
250 desc_short = "ending colour (RGB colour array)",
251 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.",
252 can_be_none = True
253 )
254 uf.add_keyarg(
255 name = "colour_list",
256 py_type = "str",
257 desc_short = "colour list",
258 desc = "The colour list to search for the colour names. This can be either 'molmol' or 'x11'.",
259 wiz_element_type = "combo",
260 wiz_combo_choices = ["molmol", "x11"],
261 wiz_read_only = True,
262 can_be_none = True
263 )
264
265 uf.desc.append(Desc_container())
266 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.")
267 uf.desc.append(colour._linear_gradient_doc)
268 uf.desc.append(classic_style_doc)
269 uf.desc.append(colour.__molmol_colours_doc__)
270 uf.desc.append(colour.__x11_colours_doc__)
271
272 uf.desc.append(Desc_container("Prompt examples"))
273 uf.desc[-1].add_paragraph("To map the order parameter values, S2, onto the structure using the classic style, type:")
274 uf.desc[-1].add_prompt("relax> pymol.macro_apply('s2')")
275 uf.desc[-1].add_prompt("relax> pymol.macro_apply(data_type='s2')")
276 uf.desc[-1].add_prompt("relax> pymol.macro_apply(data_type='s2', style=\"classic\")")
277 uf.backend = pymol_control.macro_apply
278 uf.menu_text = "¯o_apply"
279 uf.gui_icon = "relax.pymol_icon"
280 uf.wizard_height_desc = 400
281 uf.wizard_size = (1000, 750)
282 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
283
284
285
286 uf = uf_info.add_uf('pymol.macro_run')
287 uf.title = "Open and execute the PyMOL macro file."
288 uf.title_short = "PyMOL macro file execution."
289 uf.display = True
290 uf.add_keyarg(
291 name = "file",
292 py_type = "str",
293 arg_type = "file sel",
294 desc_short = "file name",
295 desc = "The name of the PyMOL macro file.",
296 wiz_filesel_wildcard = WILDCARD_PYMOL_MACRO,
297 wiz_filesel_style = FD_OPEN
298 )
299 uf.add_keyarg(
300 name = "dir",
301 default = "pymol",
302 py_type = "str",
303 arg_type = "dir",
304 desc_short = "directory name",
305 desc = "The directory name.",
306 can_be_none = True
307 )
308
309 uf.desc.append(Desc_container())
310 uf.desc[-1].add_paragraph("This user function is for opening and running a PyMOL macro located within a text file.")
311
312 uf.desc.append(Desc_container("Prompt examples"))
313 uf.desc[-1].add_paragraph("To execute the macro file 's2.pml' located in the directory 'pymol', type:")
314 uf.desc[-1].add_prompt("relax> pymol.macro_run(file='s2.pml')")
315 uf.desc[-1].add_prompt("relax> pymol.macro_run(file='s2.pml', dir='pymol')")
316 uf.backend = pymol_control.macro_run
317 uf.menu_text = "macro_&run"
318 uf.gui_icon = "oxygen.actions.document-open"
319 uf.wizard_size = (700, 400)
320 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
321
322
323
324 uf = uf_info.add_uf('pymol.macro_write')
325 uf.title = "Create PyMOL macros."
326 uf.title_short = "PyMOL macro creation."
327 uf.add_keyarg(
328 name = "data_type",
329 py_type = "str",
330 desc_short = "data type",
331 desc = "The data type to map to the structure."
332 )
333 uf.add_keyarg(
334 name = "style",
335 default = "classic",
336 py_type = "str",
337 desc_short = "style",
338 desc = "The style of the macro.",
339 wiz_element_type = "combo",
340 wiz_combo_choices = ["classic"],
341 wiz_read_only = True,
342 )
343 uf.add_keyarg(
344 name = "colour_start_name",
345 py_type = "str",
346 desc_short = "starting colour (by name)",
347 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.",
348 can_be_none = True
349 )
350 uf.add_keyarg(
351 name = "colour_start_rgb",
352 py_type = "num_list",
353 dim = 3,
354 desc_short = "starting colour (RGB colour array)",
355 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.",
356 can_be_none = True
357 )
358 uf.add_keyarg(
359 name = "colour_end_name",
360 py_type = "str",
361 desc_short = "ending colour (by name)",
362 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.",
363 can_be_none = True
364 )
365 uf.add_keyarg(
366 name = "colour_end_rgb",
367 py_type = "num_list",
368 dim = 3,
369 desc_short = "ending colour (RGB colour array)",
370 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.",
371 can_be_none = True
372 )
373 uf.add_keyarg(
374 name = "colour_list",
375 py_type = "str",
376 desc_short = "colour list",
377 desc = "The colour list to search for the colour names. This can be either 'molmol' or 'x11'.",
378 wiz_element_type = "combo",
379 wiz_combo_choices = ["molmol", "x11"],
380 wiz_read_only = True,
381 can_be_none = True
382 )
383 uf.add_keyarg(
384 name = "file",
385 py_type = "str",
386 arg_type = "file sel",
387 desc_short = "file name",
388 desc = "The optional name of the file.",
389 wiz_filesel_wildcard = WILDCARD_PYMOL_MACRO,
390 wiz_filesel_style = FD_SAVE,
391 can_be_none = True
392 )
393 uf.add_keyarg(
394 name = "dir",
395 default = "pymol",
396 py_type = "str",
397 arg_type = "dir",
398 desc_short = "directory name",
399 desc = "The optional directory to save the file to.",
400 can_be_none = True
401 )
402 uf.add_keyarg(
403 name = "force",
404 default = False,
405 py_type = "bool",
406 desc_short = "force flag",
407 desc = "A flag which, if set to True, will cause the file to be overwritten."
408 )
409
410 uf.desc.append(Desc_container())
411 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.")
412 uf.desc.append(colour._linear_gradient_doc)
413 uf.desc.append(classic_style_doc)
414 uf.desc.append(colour.__molmol_colours_doc__)
415 uf.desc.append(colour.__x11_colours_doc__)
416
417 uf.desc.append(Desc_container("Prompt examples"))
418 uf.desc[-1].add_paragraph("To create a PyMOL macro mapping the order parameter values, S2, onto the structure using the classic style, type:")
419 uf.desc[-1].add_prompt("relax> pymol.macro_write('s2')")
420 uf.desc[-1].add_prompt("relax> pymol.macro_write(data_type='s2')")
421 uf.desc[-1].add_prompt("relax> pymol.macro_write(data_type='s2', style=\"classic\", file='s2.pml', dir='pymol')")
422 uf.backend = pymol_control.macro_write
423 uf.menu_text = "macro_&write"
424 uf.gui_icon = "oxygen.actions.document-save"
425 uf.wizard_height_desc = 330
426 uf.wizard_size = (1000, 750)
427 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
428
429
430
431 uf = uf_info.add_uf('pymol.tensor_pdb')
432 uf.title = "Display the diffusion tensor PDB geometric object over the loaded PDB."
433 uf.title_short = "Diffusion tensor and structure display."
434 uf.add_keyarg(
435 name = "file",
436 py_type = "str_or_inst",
437 arg_type = "file sel",
438 desc_short = "file name",
439 desc = "The name of the PDB file containing the tensor geometric object.",
440 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
441 wiz_filesel_style = FD_OPEN
442 )
443
444 uf.desc.append(Desc_container())
445 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.")
446 uf.desc[-1].add_paragraph("The tensor PDB file is read in using the command:")
447 uf.desc[-1].add_list_element("load file")
448 uf.desc[-1].add_paragraph("The centre of mass residue 'COM' is displayed using the commands:")
449 uf.desc[-1].add_list_element("select resn COM")
450 uf.desc[-1].add_list_element("show dots, 'sele'")
451 uf.desc[-1].add_list_element("color blue, 'sele'")
452 uf.desc[-1].add_paragraph("The axes of the diffusion tensor, the residue 'AXS', is displayed using the commands:")
453 uf.desc[-1].add_list_element("select resn AXS")
454 uf.desc[-1].add_list_element("hide ('sele')")
455 uf.desc[-1].add_list_element("show sticks, 'sele'")
456 uf.desc[-1].add_list_element("color cyan, 'sele'")
457 uf.desc[-1].add_list_element("label 'sele', name")
458 uf.desc[-1].add_paragraph("The simulation axes, the residues 'SIM', are displayed using the commands:")
459 uf.desc[-1].add_list_element("select resn SIM")
460 uf.desc[-1].add_list_element("colour cyan, 'sele'")
461 uf.backend = pymol_control.tensor_pdb
462 uf.menu_text = "&tensor_pdb"
463 uf.wizard_height_desc = 550
464 uf.wizard_size = (1000, 750)
465 uf.wizard_apply_button = False
466 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
467
468
469
470 uf = uf_info.add_uf('pymol.vector_dist')
471 uf.title = "Display the PDB file representation of the XH vector distribution."
472 uf.title_short = "XH vector distribution display."
473 uf.add_keyarg(
474 name = "file",
475 default = "XH_dist.pdb",
476 py_type = "str",
477 arg_type = "file sel",
478 desc_short = "file name",
479 desc = "The name of the PDB file containing the vector distribution.",
480 wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL,
481 wiz_filesel_style = FD_OPEN
482 )
483
484 uf.desc.append(Desc_container())
485 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.")
486 uf.desc[-1].add_paragraph("The vector distribution PDB file is read in using the command:")
487 uf.desc[-1].add_list_element("load file")
488 uf.backend = pymol_control.vector_dist
489 uf.menu_text = "vector_&dist"
490 uf.wizard_size = (800, 500)
491 uf.wizard_height_desc = 450
492 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
493
494
495 uf = uf_info.add_uf('pymol.view')
496 uf.title = "View the collection of molecules from the loaded PDB file."
497 uf.title_short = "Molecule viewing."
498
499 uf.desc.append(Desc_container())
500 uf.desc[-1].add_paragraph("This will simply launch Pymol.")
501
502 uf.desc.append(Desc_container("Prompt examples"))
503 uf.desc[-1].add_prompt("relax> pymol.view()")
504 uf.backend = pymol_control.view
505 uf.menu_text = "&view"
506 uf.wizard_size = (600, 350)
507 uf.wizard_apply_button = False
508 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
509