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