1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The molmol user function definitions for interacting with Molmol."""
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 molmol
38 from specific_analyses.model_free.molmol import Molmol
39 from user_functions.data import Uf_info; uf_info = Uf_info()
40 from user_functions.objects import Desc_container
41
42
43
44 uf_class = uf_info.add_class('molmol')
45 uf_class.title = "Class for interfacing with Molmol."
46 uf_class.menu_text = "&molmol"
47 uf_class.gui_icon = "relax.molmol"
48
49
50
51 uf = uf_info.add_uf('molmol.clear_history')
52 uf.title = "Clear the Molmol command history."
53 uf.title_short = "Clear Molmol history."""
54
55 uf.desc.append(Desc_container())
56 uf.desc[-1].add_paragraph("This will clear the Molmol history from memory.")
57 uf.backend = molmol.molmol_obj.clear_history
58 uf.menu_text = "clear_&history"
59 uf.wizard_size = (600, 300)
60 uf.wizard_apply_button = False
61 uf.wizard_image = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png'
62
63
64
65 uf = uf_info.add_uf('molmol.command')
66 uf.title = "Execute a user supplied Molmol command."
67 uf.title_short = "Molmol command execution."
68 uf.add_keyarg(
69 name = "command",
70 py_type = "str",
71 desc_short = "Molmol command",
72 desc = "The Molmol command to execute."
73 )
74
75 uf.desc.append(Desc_container())
76 uf.desc[-1].add_paragraph("This allows Molmol commands to be passed to the program. This can be useful for automation or scripting.")
77
78 uf.desc.append(Desc_container("Prompt examples"))
79 uf.desc[-1].add_paragraph("To reinitialise the Molmol instance, type:")
80 uf.desc[-1].add_prompt("relax> molmol.command(\"InitAll yes\")")
81 uf.backend = molmol.command
82 uf.menu_text = "&command"
83 uf.gui_icon = "oxygen.actions.edit-rename"
84 uf.wizard_size = (700, 400)
85 uf.wizard_image = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png'
86
87
88
89 uf = uf_info.add_uf('molmol.macro_apply')
90 uf.title = "Execute Molmol macros."
91 uf.title_short = "Molmol macro execution."
92 uf.display = True
93 uf.add_keyarg(
94 name = "data_type",
95 py_type = "str",
96 desc_short = "data type",
97 desc = "The data type to map to the structure."
98 )
99 uf.add_keyarg(
100 name = "style",
101 default = "classic",
102 py_type = "str",
103 desc_short = "style",
104 desc = "The style of the macro.",
105 wiz_element_type = "combo",
106 wiz_combo_choices = ["classic"],
107 wiz_read_only = True
108 )
109 uf.add_keyarg(
110 name = "colour_start_name",
111 py_type = "str",
112 desc_short = "starting colour (by name)",
113 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.",
114 can_be_none = True
115 )
116 uf.add_keyarg(
117 name = "colour_start_rgb",
118 py_type = "num_list",
119 dim = 3,
120 desc_short = "starting colour (RGB colour array)",
121 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.",
122 can_be_none = True
123 )
124 uf.add_keyarg(
125 name = "colour_end_name",
126 py_type = "str",
127 desc_short = "ending colour (by name)",
128 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.",
129 can_be_none = True
130 )
131 uf.add_keyarg(
132 name = "colour_end_rgb",
133 py_type = "num_list",
134 dim = 3,
135 desc_short = "ending colour (RGB colour array)",
136 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.",
137 can_be_none = True
138 )
139 uf.add_keyarg(
140 name = "colour_list",
141 py_type = "str",
142 desc_short = "colour list",
143 desc = "The colour list to search for the colour names. This can be either 'molmol' or 'x11'.",
144 wiz_element_type = "combo",
145 wiz_combo_choices = ["molmol", "x11"],
146 wiz_read_only = True,
147 can_be_none = True
148 )
149
150 uf.desc.append(Desc_container())
151 uf.desc[-1].add_paragraph("This allows spin specific values to be mapped to a structure through Molmol macros. Currently only the 'classic' style, which is described below, is available.")
152 uf.desc.append(colour._linear_gradient_doc)
153 uf.desc.append(Molmol.classic_style_doc)
154 uf.desc.append(colour.__molmol_colours_doc__)
155 uf.desc.append(colour.__x11_colours_doc__)
156
157 uf.desc.append(Desc_container("Prompt examples"))
158 uf.desc[-1].add_paragraph("To map the order parameter values, S2, onto the structure using the classic style, type:")
159 uf.desc[-1].add_prompt("relax> molmol.macro_apply('s2')")
160 uf.desc[-1].add_prompt("relax> molmol.macro_apply(data_type='s2')")
161 uf.desc[-1].add_prompt("relax> molmol.macro_apply(data_type='s2', style=\"classic\")")
162 uf.backend = molmol.macro_apply
163 uf.menu_text = "¯o_apply"
164 uf.gui_icon = "relax.molmol"
165 uf.wizard_size = (1000, 750)
166 uf.wizard_height_desc = 400
167 uf.wizard_image = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png'
168
169
170
171 uf = uf_info.add_uf('molmol.macro_run')
172 uf.title = "Open and execute the Molmol macro file."
173 uf.title_short = "Molmol macro file execution."
174 uf.display = True
175 uf.add_keyarg(
176 name = "file",
177 py_type = "str",
178 arg_type = "file sel",
179 desc_short = "Molmol macro file",
180 desc = "The name of the Molmol macro file.",
181 wiz_filesel_wildcard = "Molmol macro files (*.mac)|*.mac;*.MAC",
182 wiz_filesel_style = FD_OPEN
183 )
184 uf.add_keyarg(
185 name = "dir",
186 default = "molmol",
187 py_type = "str",
188 arg_type = "dir",
189 desc_short = "directory name",
190 desc = "The directory name.",
191 can_be_none = True
192 )
193
194 uf.desc.append(Desc_container())
195 uf.desc[-1].add_paragraph("This user function is for opening and running a Molmol macro located within a text file.")
196
197 uf.desc.append(Desc_container("Prompt examples"))
198 uf.desc[-1].add_paragraph("To execute the macro file 's2.mac' located in the directory 'molmol', type:")
199 uf.desc[-1].add_prompt("relax> molmol.macro_run(file='s2.mac')")
200 uf.desc[-1].add_prompt("relax> molmol.macro_run(file='s2.mac', dir='molmol')")
201 uf.backend = molmol.macro_run
202 uf.menu_text = "macro_&run"
203 uf.gui_icon = "oxygen.actions.document-open"
204 uf.wizard_size = (700, 400)
205 uf.wizard_image = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png'
206
207
208
209 uf = uf_info.add_uf('molmol.macro_write')
210 uf.title = "Create Molmol macros."
211 uf.title_short = "Molmol macro creation."
212 uf.add_keyarg(
213 name = "data_type",
214 py_type = "str",
215 desc_short = "data type",
216 desc = "The data type to map to the structure."
217 )
218 uf.add_keyarg(
219 name = "style",
220 default = "classic",
221 py_type = "str",
222 desc_short = "style",
223 desc = "The style of the macro.",
224 wiz_element_type = "combo",
225 wiz_combo_choices = ["classic"],
226 wiz_read_only = True,
227 )
228 uf.add_keyarg(
229 name = "colour_start_name",
230 py_type = "str",
231 desc_short = "starting colour (by name)",
232 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.",
233 can_be_none = True
234 )
235 uf.add_keyarg(
236 name = "colour_start_rgb",
237 py_type = "num_list",
238 dim = 3,
239 desc_short = "starting colour (RGB colour array)",
240 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.",
241 can_be_none = True
242 )
243 uf.add_keyarg(
244 name = "colour_end_name",
245 py_type = "str",
246 desc_short = "ending colour (by name)",
247 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.",
248 can_be_none = True
249 )
250 uf.add_keyarg(
251 name = "colour_end_rgb",
252 py_type = "num_list",
253 dim = 3,
254 desc_short = "ending colour (RGB colour array)",
255 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.",
256 can_be_none = True
257 )
258 uf.add_keyarg(
259 name = "colour_list",
260 py_type = "str",
261 desc_short = "colour list",
262 desc = "The colour list to search for the colour names. This can be either 'molmol' or 'x11'.",
263 wiz_element_type = "combo",
264 wiz_combo_choices = ["molmol", "x11"],
265 wiz_read_only = True,
266 can_be_none = True
267 )
268 uf.add_keyarg(
269 name = "file",
270 py_type = "str",
271 arg_type = "file sel",
272 desc_short = "file name",
273 desc = "The optional name of the file.",
274 wiz_filesel_wildcard = "Molmol macro files (*.mac)|*.mac;*.MAC",
275 wiz_filesel_style = FD_SAVE,
276 can_be_none = True
277 )
278 uf.add_keyarg(
279 name = "dir",
280 default = "molmol",
281 py_type = "str",
282 arg_type = "dir",
283 desc_short = "directory name",
284 desc = "The optional directory to save the file to.",
285 can_be_none = True
286 )
287 uf.add_keyarg(
288 name = "force",
289 default = False,
290 py_type = "bool",
291 desc_short = "force flag",
292 desc = "A flag which, if set to True, will cause the file to be overwritten."
293 )
294
295 uf.desc.append(Desc_container())
296 uf.desc[-1].add_paragraph("This allows residues specific values to be mapped to a structure through the creation of a Molmol '*.mac' macro which can be executed in Molmol by clicking on 'File, Macro, Execute User...'. Currently only the 'classic' style, which is described below, is available.")
297 uf.desc.append(colour._linear_gradient_doc)
298 uf.desc.append(Molmol.classic_style_doc)
299 uf.desc.append(colour.__molmol_colours_doc__)
300 uf.desc.append(colour.__x11_colours_doc__)
301
302 uf.desc.append(Desc_container("Prompt examples"))
303 uf.desc[-1].add_paragraph("To create a Molmol macro mapping the order parameter values, S2, onto the structure using the classic style, type:")
304 uf.desc[-1].add_prompt("relax> molmol.macro_write('s2')")
305 uf.desc[-1].add_prompt("relax> molmol.macro_write(data_type='s2')")
306 uf.desc[-1].add_prompt("relax> molmol.macro_write(data_type='s2', style=\"classic\", file='s2.mac', dir='molmol')")
307 uf.backend = molmol.macro_write
308 uf.menu_text = "macro_&write"
309 uf.gui_icon = "oxygen.actions.document-save"
310 uf.wizard_size = (1000, 750)
311 uf.wizard_height_desc = 350
312 uf.wizard_image = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png'
313
314
315
316 uf = uf_info.add_uf('molmol.ribbon')
317 uf.title = "Apply the Molmol ribbon style."
318 uf.title_short = "Molmol ribbon style application."
319
320 uf.desc.append(Desc_container())
321 uf.desc[-1].add_paragraph("This applies the Molmol ribbon style which is equivalent to clicking on 'ribbon' in the Molmol side menu. To do this, the following commands are executed:")
322 uf.desc[-1].add_list_element("CalcAtom 'H'")
323 uf.desc[-1].add_list_element("CalcAtom 'HN'")
324 uf.desc[-1].add_list_element("CalcSecondary")
325 uf.desc[-1].add_list_element("XMacStand ribbon.mac")
326
327 uf.desc.append(Desc_container("Prompt examples"))
328 uf.desc[-1].add_paragraph("To apply the ribbon style to the PDB file loaded, type:")
329 uf.desc[-1].add_prompt("relax> molmol.ribbon()")
330 uf.backend = molmol.ribbon
331 uf.menu_text = "ri&bbon"
332 uf.wizard_size = (700, 500)
333 uf.wizard_height_desc = 450
334 uf.wizard_apply_button = False
335 uf.wizard_image = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png'
336
337
338
339 uf = uf_info.add_uf('molmol.tensor_pdb')
340 uf.title = "Display the diffusion tensor PDB geometric object over the loaded PDB."
341 uf.title_short = "Diffusion tensor and structure display."
342 uf.add_keyarg(
343 name = "file",
344 py_type = "str_or_inst",
345 arg_type = "file sel",
346 desc_short = "file name",
347 desc = "The name of the PDB file containing the tensor geometric object.",
348 wiz_filesel_wildcard = "PDB files (*.pdb)|*.pdb;*.PDB",
349 wiz_filesel_style = FD_OPEN
350 )
351
352 uf.desc.append(Desc_container())
353 uf.desc[-1].add_paragraph("In executing this user function, a PDB file must have previously been loaded , a geometric object or polygon representing the Brownian rotational diffusion tensor will be overlain with the loaded PDB file and displayed within Molmol. The PDB file containing the geometric object must be created using the complementary structure.create_diff_tensor_pdb user function.")
354 uf.desc[-1].add_paragraph("To display the diffusion tensor, the multiple commands will be executed. To overlay the structure with the diffusion tensor, everything will be selected and reoriented and moved to their original PDB frame positions:")
355 uf.desc[-1].add_list_element("SelectAtom ''")
356 uf.desc[-1].add_list_element("SelectBond ''")
357 uf.desc[-1].add_list_element("SelectAngle ''")
358 uf.desc[-1].add_list_element("SelectDist ''")
359 uf.desc[-1].add_list_element("SelectPrim ''")
360 uf.desc[-1].add_list_element("RotateInit")
361 uf.desc[-1].add_list_element("MoveInit")
362 uf.desc[-1].add_paragraph("Next the tensor PDB file is read in, selected, and the covalent bonds of the PDB CONECT records calculated:")
363 uf.desc[-1].add_list_element("ReadPdb file")
364 uf.desc[-1].add_list_element("SelectMol '@file'")
365 uf.desc[-1].add_list_element("CalcBond 1 1 1")
366 uf.desc[-1].add_paragraph("Then only the atoms and bonds of the geometric object are selected and the 'ball/stick' style applied:")
367 uf.desc[-1].add_list_element("SelectAtom '0'")
368 uf.desc[-1].add_list_element("SelectBond '0'")
369 uf.desc[-1].add_list_element("SelectAtom ':TNS'")
370 uf.desc[-1].add_list_element("SelectBond ':TNS'")
371 uf.desc[-1].add_list_element("XMacStand ball_stick.mac")
372 uf.desc[-1].add_paragraph("The appearance is finally touched up:")
373 uf.desc[-1].add_list_element("RadiusAtom 1")
374 uf.desc[-1].add_list_element("SelectAtom ':TNS@C*'")
375 uf.desc[-1].add_list_element("RadiusAtom 1.5")
376 uf.backend = molmol.tensor_pdb
377 uf.menu_text = "&tensor_pdb"
378 uf.wizard_height_desc = 550
379 uf.wizard_size = (1000, 750)
380 uf.wizard_apply_button = False
381 uf.wizard_image = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png'
382
383
384
385 uf = uf_info.add_uf('molmol.view')
386 uf.title = "View the collection of molecules from the loaded PDB file."
387 uf.title_short = "Molecule viewing."
388
389 uf.desc.append(Desc_container())
390 uf.desc[-1].add_paragraph("This will simply launch Molmol.")
391
392 uf.desc.append(Desc_container("Prompt examples"))
393 uf.desc[-1].add_prompt("relax> molmol.view()")
394 uf.backend = molmol.view
395 uf.menu_text = "&view"
396 uf.wizard_size = (600, 300)
397 uf.wizard_apply_button = False
398 uf.wizard_image = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png'
399