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