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 import wx
29
30
31 import colour
32 from generic_fns import pymol_control
33 from graphics import WIZARD_IMAGE_PATH
34 from specific_fns.model_free.pymol import Pymol
35 from user_functions.data import Uf_info; uf_info = Uf_info()
36 from user_functions.objects import Desc_container
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 py_type = "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 py_type = "str",
114 arg_type = "file sel",
115 desc_short = "file name",
116 desc = "The name of the PDB file containing the cone geometric object.",
117 wiz_filesel_wildcard = "PDB files (*.pdb)|*.pdb;*.PDB",
118 wiz_filesel_style = wx.FD_OPEN
119 )
120
121 uf.desc.append(Desc_container())
122 uf.desc[-1].add_paragraph("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.")
123 uf.desc[-1].add_paragraph("The cone PDB file is read in using the command:")
124 uf.desc[-1].add_list_element("load file")
125 uf.desc[-1].add_paragraph("The average CoM-pivot point vector, the residue 'AVE' is displayed using the commands:")
126 uf.desc[-1].add_list_element("select resn AVE")
127 uf.desc[-1].add_list_element("show sticks, 'sele'")
128 uf.desc[-1].add_list_element("color blue, 'sele'")
129 uf.desc[-1].add_paragraph("The cone object, the residue 'CON', is displayed using the commands:")
130 uf.desc[-1].add_list_element("select resn CON")
131 uf.desc[-1].add_list_element("hide ('sele')")
132 uf.desc[-1].add_list_element("show sticks, 'sele'")
133 uf.desc[-1].add_list_element("color white, 'sele'")
134 uf.backend = pymol_control.cone_pdb
135 uf.menu_text = "cone_&pdb"
136 uf.wizard_height_desc = 500
137 uf.wizard_size = (900, 700)
138 uf.wizard_apply_button = False
139 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
140
141
142
143 uf = uf_info.add_uf('pymol.macro_apply')
144 uf.title = "Execute PyMOL macros."
145 uf.title_short = "PyMOL macro execution."
146 uf.display = True
147 uf.add_keyarg(
148 name = "data_type",
149 py_type = "str",
150 desc_short = "data type",
151 desc = "The data type to map to the structure."
152 )
153 uf.add_keyarg(
154 name = "style",
155 default = "classic",
156 py_type = "str",
157 desc_short = "style",
158 desc = "The style of the macro.",
159 wiz_element_type = "combo",
160 wiz_combo_choices = ["classic"],
161 wiz_read_only = True,
162 )
163 uf.add_keyarg(
164 name = "colour_start_name",
165 py_type = "str",
166 desc_short = "starting colour (by name)",
167 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.",
168 can_be_none = True
169 )
170 uf.add_keyarg(
171 name = "colour_start_rgb",
172 py_type = "num_list",
173 dim = 3,
174 desc_short = "starting colour (RGB colour array)",
175 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.",
176 can_be_none = True
177 )
178 uf.add_keyarg(
179 name = "colour_end_name",
180 py_type = "str",
181 desc_short = "ending colour (by name)",
182 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.",
183 can_be_none = True
184 )
185 uf.add_keyarg(
186 name = "colour_end_rgb",
187 py_type = "num_list",
188 dim = 3,
189 desc_short = "ending colour (RGB colour array)",
190 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.",
191 can_be_none = True
192 )
193 uf.add_keyarg(
194 name = "colour_list",
195 py_type = "str",
196 desc_short = "colour list",
197 desc = "The colour list to search for the colour names. This can be either 'molmol' or 'x11'.",
198 wiz_element_type = "combo",
199 wiz_combo_choices = ["molmol", "x11"],
200 wiz_read_only = True,
201 can_be_none = True
202 )
203
204 uf.desc.append(Desc_container())
205 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.")
206 uf.desc.append(colour._linear_gradient_doc)
207 uf.desc.append(Pymol.classic_style_doc)
208 uf.desc.append(colour.__molmol_colours_doc__)
209 uf.desc.append(colour.__x11_colours_doc__)
210
211 uf.desc.append(Desc_container("Prompt examples"))
212 uf.desc[-1].add_paragraph("To map the order parameter values, S2, onto the structure using the classic style, type:")
213 uf.desc[-1].add_prompt("relax> pymol.macro_apply('s2')")
214 uf.desc[-1].add_prompt("relax> pymol.macro_apply(data_type='s2')")
215 uf.desc[-1].add_prompt("relax> pymol.macro_apply(data_type='s2', style=\"classic\")")
216 uf.backend = pymol_control.macro_apply
217 uf.menu_text = "¯o_apply"
218 uf.gui_icon = "relax.pymol_icon"
219 uf.wizard_height_desc = 400
220 uf.wizard_size = (1000, 750)
221 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
222
223
224
225 uf = uf_info.add_uf('pymol.macro_run')
226 uf.title = "Open and execute the PyMOL macro file."
227 uf.title_short = "PyMOL macro file execution."
228 uf.display = True
229 uf.add_keyarg(
230 name = "file",
231 py_type = "str",
232 arg_type = "file sel",
233 desc_short = "file name",
234 desc = "The name of the PyMOL macro file.",
235 wiz_filesel_wildcard = "PyMOL macro files (*.pml)|*.pml;*.PML",
236 wiz_filesel_style = wx.FD_OPEN
237 )
238 uf.add_keyarg(
239 name = "dir",
240 default = "pymol",
241 py_type = "str",
242 arg_type = "dir",
243 desc_short = "directory name",
244 desc = "The directory name.",
245 can_be_none = True
246 )
247
248 uf.desc.append(Desc_container())
249 uf.desc[-1].add_paragraph("This user function is for opening and running a PyMOL macro located within a text file.")
250
251 uf.desc.append(Desc_container("Prompt examples"))
252 uf.desc[-1].add_paragraph("To execute the macro file 's2.pml' located in the directory 'pymol', type:")
253 uf.desc[-1].add_prompt("relax> pymol.macro_run(file='s2.pml')")
254 uf.desc[-1].add_prompt("relax> pymol.macro_run(file='s2.pml', dir='pymol')")
255 uf.backend = pymol_control.macro_run
256 uf.menu_text = "macro_&run"
257 uf.gui_icon = "oxygen.actions.document-open"
258 uf.wizard_size = (700, 400)
259 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
260
261
262
263 uf = uf_info.add_uf('pymol.macro_write')
264 uf.title = "Create PyMOL macros."
265 uf.title_short = "PyMOL macro creation."
266 uf.add_keyarg(
267 name = "data_type",
268 py_type = "str",
269 desc_short = "data type",
270 desc = "The data type to map to the structure."
271 )
272 uf.add_keyarg(
273 name = "style",
274 default = "classic",
275 py_type = "str",
276 desc_short = "style",
277 desc = "The style of the macro.",
278 wiz_element_type = "combo",
279 wiz_combo_choices = ["classic"],
280 wiz_read_only = True,
281 )
282 uf.add_keyarg(
283 name = "colour_start_name",
284 py_type = "str",
285 desc_short = "starting colour (by name)",
286 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.",
287 can_be_none = True
288 )
289 uf.add_keyarg(
290 name = "colour_start_rgb",
291 py_type = "num_list",
292 dim = 3,
293 desc_short = "starting colour (RGB colour array)",
294 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.",
295 can_be_none = True
296 )
297 uf.add_keyarg(
298 name = "colour_end_name",
299 py_type = "str",
300 desc_short = "ending colour (by name)",
301 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.",
302 can_be_none = True
303 )
304 uf.add_keyarg(
305 name = "colour_end_rgb",
306 py_type = "num_list",
307 dim = 3,
308 desc_short = "ending colour (RGB colour array)",
309 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.",
310 can_be_none = True
311 )
312 uf.add_keyarg(
313 name = "colour_list",
314 py_type = "str",
315 desc_short = "colour list",
316 desc = "The colour list to search for the colour names. This can be either 'molmol' or 'x11'.",
317 wiz_element_type = "combo",
318 wiz_combo_choices = ["molmol", "x11"],
319 wiz_read_only = True,
320 can_be_none = True
321 )
322 uf.add_keyarg(
323 name = "file",
324 py_type = "str",
325 arg_type = "file sel",
326 desc_short = "file name",
327 desc = "The optional name of the file.",
328 wiz_filesel_wildcard = "PyMOL macro files (*.pml)|*.pml;*.PML",
329 wiz_filesel_style = wx.FD_SAVE,
330 can_be_none = True
331 )
332 uf.add_keyarg(
333 name = "dir",
334 default = "pymol",
335 py_type = "str",
336 arg_type = "dir",
337 desc_short = "directory name",
338 desc = "The optional directory to save the file to.",
339 can_be_none = True
340 )
341 uf.add_keyarg(
342 name = "force",
343 default = False,
344 py_type = "bool",
345 desc_short = "force flag",
346 desc = "A flag which, if set to True, will cause the file to be overwritten."
347 )
348
349 uf.desc.append(Desc_container())
350 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.")
351 uf.desc.append(colour._linear_gradient_doc)
352 uf.desc.append(Pymol.classic_style_doc)
353 uf.desc.append(colour.__molmol_colours_doc__)
354 uf.desc.append(colour.__x11_colours_doc__)
355
356 uf.desc.append(Desc_container("Prompt examples"))
357 uf.desc[-1].add_paragraph("To create a PyMOL macro mapping the order parameter values, S2, onto the structure using the classic style, type:")
358 uf.desc[-1].add_prompt("relax> pymol.macro_write('s2')")
359 uf.desc[-1].add_prompt("relax> pymol.macro_write(data_type='s2')")
360 uf.desc[-1].add_prompt("relax> pymol.macro_write(data_type='s2', style=\"classic\", file='s2.pml', dir='pymol')")
361 uf.backend = pymol_control.macro_write
362 uf.menu_text = "macro_&write"
363 uf.gui_icon = "oxygen.actions.document-save"
364 uf.wizard_height_desc = 330
365 uf.wizard_size = (1000, 750)
366 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
367
368
369
370 uf = uf_info.add_uf('pymol.tensor_pdb')
371 uf.title = "Display the diffusion tensor PDB geometric object over the loaded PDB."
372 uf.title_short = "Diffusion tensor and structure display."
373 uf.add_keyarg(
374 name = "file",
375 py_type = "str_or_inst",
376 arg_type = "file sel",
377 desc_short = "file name",
378 desc = "The name of the PDB file containing the tensor geometric object.",
379 wiz_filesel_wildcard = "PDB files (*.pdb)|*.pdb;*.PDB",
380 wiz_filesel_style = wx.FD_OPEN
381 )
382
383 uf.desc.append(Desc_container())
384 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.")
385 uf.desc[-1].add_paragraph("The tensor PDB file is read in using the command:")
386 uf.desc[-1].add_list_element("load file")
387 uf.desc[-1].add_paragraph("The centre of mass residue 'COM' is displayed using the commands:")
388 uf.desc[-1].add_list_element("select resn COM")
389 uf.desc[-1].add_list_element("show dots, 'sele'")
390 uf.desc[-1].add_list_element("color blue, 'sele'")
391 uf.desc[-1].add_paragraph("The axes of the diffusion tensor, the residue 'AXS', is displayed using the commands:")
392 uf.desc[-1].add_list_element("select resn AXS")
393 uf.desc[-1].add_list_element("hide ('sele')")
394 uf.desc[-1].add_list_element("show sticks, 'sele'")
395 uf.desc[-1].add_list_element("color cyan, 'sele'")
396 uf.desc[-1].add_list_element("label 'sele', name")
397 uf.desc[-1].add_paragraph("The simulation axes, the residues 'SIM', are displayed using the commands:")
398 uf.desc[-1].add_list_element("select resn SIM")
399 uf.desc[-1].add_list_element("colour cyan, 'sele'")
400 uf.backend = pymol_control.tensor_pdb
401 uf.menu_text = "&tensor_pdb"
402 uf.wizard_height_desc = 550
403 uf.wizard_size = (1000, 750)
404 uf.wizard_apply_button = False
405 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
406
407
408
409 uf = uf_info.add_uf('pymol.vector_dist')
410 uf.title = "Display the PDB file representation of the XH vector distribution."
411 uf.title_short = "XH vector distribution display."
412 uf.add_keyarg(
413 name = "file",
414 default = "XH_dist.pdb",
415 py_type = "str",
416 arg_type = "file sel",
417 desc_short = "file name",
418 desc = "The name of the PDB file containing the vector distribution.",
419 wiz_filesel_wildcard = "PDB files (*.pdb)|*.pdb;*.PDB",
420 wiz_filesel_style = wx.FD_OPEN
421 )
422
423 uf.desc.append(Desc_container())
424 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.")
425 uf.desc[-1].add_paragraph("The vector distribution PDB file is read in using the command:")
426 uf.desc[-1].add_list_element("load file")
427 uf.backend = pymol_control.vector_dist
428 uf.menu_text = "vector_&dist"
429 uf.wizard_size = (800, 500)
430 uf.wizard_height_desc = 450
431 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
432
433
434 uf = uf_info.add_uf('pymol.view')
435 uf.title = "View the collection of molecules from the loaded PDB file."
436 uf.title_short = "Molecule viewing."
437
438 uf.desc.append(Desc_container())
439 uf.desc[-1].add_paragraph("This will simply launch Pymol.")
440
441 uf.desc.append(Desc_container("Prompt examples"))
442 uf.desc[-1].add_prompt("relax> pymol.view()")
443 uf.backend = pymol_control.view
444 uf.menu_text = "&view"
445 uf.wizard_size = (600, 350)
446 uf.wizard_apply_button = False
447 uf.wizard_image = WIZARD_IMAGE_PATH + 'pymol' + sep + 'pymol.png'
448