1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the 'pymol' user function class for interacting with PyMOL."""
25 __docformat__ = 'plaintext'
26
27
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
46
47
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
69 if self._exec_info.intro:
70 text = self._exec_info.ps3 + "pymol.clear_history()"
71 print(text)
72
73
74 pymol_control.clear_history()
75
76
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
97
98
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
127
128
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
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
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
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
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'):
221
222
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
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
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
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
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
313
314
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
361
362
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
379
380 if self._exec_info.intro:
381 text = self._exec_info.ps3 + "pymol.view()"
382 print(text)
383
384
385 pymol_control.view()
386
387
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