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