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 'molmol' user function class for interacting with MOLMOL."""
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 molmol
32 from specific_fns.model_free.molmol import Molmol
33
34
36 """Class for interfacing with Molmol."""
37
38 - def clear_history(self):
39
40 if self._exec_info.intro:
41 text = self._exec_info.ps3 + "molmol.clear_history()"
42 print(text)
43
44
45 molmol.clear_history()
46
47
48 clear_history._doc_title = "Clear the Molmol command history."
49 clear_history._doc_title_short = "Clear Molmol history."""
50 clear_history._doc_desc = """
51 This will clear the Molmol history from memory.
52 """
53 _build_doc(clear_history)
54
55
68
69
70 command._doc_title = "Execute a user supplied Molmol command."
71 command._doc_title_short = "Molmol command execution."
72 command._doc_args = [
73 ["command", "The Molmol command to execute."]
74 ]
75 command._doc_desc = """
76 This allows Molmol commands to be passed to the program. This can be useful for automation or scripting.
77 """
78 command._doc_examples = """
79 To reinitialise the Molmol instance, type:
80
81 relax> molmol.command("InitAll yes")
82 """
83 _build_doc(command)
84
85
86 - def macro_apply(self, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None):
87
88 if self._exec_info.intro:
89 text = self._exec_info.ps3 + "molmol.macro_apply("
90 text = text + "data_type=" + repr(data_type)
91 text = text + ", style=" + repr(style)
92 text = text + ", colour_start=" + repr(colour_start)
93 text = text + ", colour_end=" + repr(colour_end)
94 text = text + ", colour_list=" + repr(colour_list) + ")"
95 print(text)
96
97
98 arg_check.is_str(data_type, 'data type')
99 arg_check.is_str(style, 'style')
100 arg_check.is_str_or_num_list(colour_start, 'starting colour of the linear gradient', size=3, can_be_none=True)
101 arg_check.is_str_or_num_list(colour_end, 'ending colour of the linear gradient', size=3, can_be_none=True)
102 arg_check.is_str(colour_list, 'colour list', can_be_none=True)
103
104
105 molmol.macro_apply(data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list)
106
107
108 macro_apply._doc_title = "Execute Molmol macros."
109 macro_apply._doc_title_short = "Molmol macro execution."
110 macro_apply._doc_args = [
111 ["data_type", "The data type to map to the structure."],
112 ["style", "The style of the macro."],
113 ["colour_start", "The starting colour, either an array or string, of the linear colour gradient."],
114 ["colour_end", "The ending colour, either an array or string, of the linear colour gradient."],
115 ["colour_list", "The list of colours to match the start and end strings."]
116 ]
117 macro_apply._doc_desc = """
118 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.
119 """
120 macro_apply._doc_examples = """
121 To map the order parameter values, S2, onto the structure using the classic style, type:
122
123 relax> molmol.macro_apply('s2')
124 relax> molmol.macro_apply(data_type='s2')
125 relax> molmol.macro_apply(data_type='s2', style="classic")
126 """
127 macro_apply._doc_additional = [
128 colour._linear_gradient_doc,
129 Molmol.classic_style_doc,
130 colour.__molmol_colours_prompt_doc__,
131 colour.__x11_colours_prompt_doc__
132 ]
133 _build_doc(macro_apply)
134
135
136 - def macro_run(self, file=None, dir='molmol'):
150
151
152 macro_run._doc_title = "Open and execute the Molmol macro file."
153 macro_run._doc_title_short = "Molmol macro file execution."
154 macro_run._doc_args = [
155 ["file", "The name of the Molmol macro file."],
156 ["dir", "The directory name."],
157 ]
158 macro_run._doc_desc = """
159 This user function is for opening and running a Molmol macro located within a text file.
160 """
161 macro_run._doc_examples = """
162 To execute the macro file 's2.mac' located in the directory 'molmol', type:
163
164 relax> molmol.macro_run(file='s2.mac')
165 relax> molmol.macro_run(file='s2.mac', dir='molmol')
166 """
167 _build_doc(macro_run)
168
169
170 - def macro_write(self, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None, file=None, dir='molmol', force=False):
171
172 if self._exec_info.intro:
173 text = self._exec_info.ps3 + "molmol.macro_write("
174 text = text + "data_type=" + repr(data_type)
175 text = text + ", style=" + repr(style)
176 text = text + ", colour_start=" + repr(colour_start)
177 text = text + ", colour_end=" + repr(colour_end)
178 text = text + ", colour_list=" + repr(colour_list)
179 text = text + ", file=" + repr(file)
180 text = text + ", dir=" + repr(dir)
181 text = text + ", force=" + repr(force) + ")"
182 print(text)
183
184
185 arg_check.is_str(data_type, 'data type')
186 arg_check.is_str(style, 'style')
187 arg_check.is_str_or_num_list(colour_start, 'starting colour of the linear gradient', size=3, can_be_none=True)
188 arg_check.is_str_or_num_list(colour_end, 'ending colour of the linear gradient', size=3, can_be_none=True)
189 arg_check.is_str(colour_list, 'colour list', can_be_none=True)
190 arg_check.is_str_or_inst(file, 'file name', can_be_none=True)
191 arg_check.is_str(dir, 'directory name', can_be_none=True)
192 arg_check.is_bool(force, 'force flag')
193
194
195 molmol.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)
196
197
198 macro_write._doc_title = "Create Molmol macros."
199 macro_write._doc_title_short = "Molmol macro creation."
200 macro_write._doc_args = [
201 ["data_type", "The data type to map to the structure."],
202 ["style", "The style of the macro."],
203 ["colour_start", "The starting colour, either an array or string, of the linear colour gradient."],
204 ["colour_end", "The ending colour, either an array or string, of the linear colour gradient."],
205 ["colour_list", "The list of colours to match the start and end strings."],
206 ["file", "The name of the file."],
207 ["dir", "The directory name."],
208 ["force", "A flag which, if set to True, will cause the file to be overwritten."]
209 ]
210 macro_write._doc_desc = """
211 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.
212 """
213 macro_write._doc_examples = """
214 To create a Molmol macro mapping the order parameter values, S2, onto the structure using
215 the classic style, type:
216
217 relax> molmol.macro_write('s2')
218 relax> molmol.macro_write(data_type='s2')
219 relax> molmol.macro_write(data_type='s2', style="classic", file='s2.mac', dir='molmol')
220 """
221 macro_write._doc_additional = [
222 colour._linear_gradient_doc,
223 Molmol.classic_style_doc,
224 colour.__molmol_colours_prompt_doc__,
225 colour.__x11_colours_prompt_doc__
226 ]
227 _build_doc(macro_write)
228
229
231
232 if self._exec_info.intro:
233 text = self._exec_info.ps3 + "molmol.ribbon()"
234 print(text)
235
236
237 molmol.ribbon()
238
239
240 ribbon._doc_title = "Apply the Molmol ribbon style."
241 ribbon._doc_title_short = "Molmol ribbon style application."
242 ribbon._doc_desc = """
243 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:
244
245 CalcAtom 'H'
246 CalcAtom 'HN'
247 CalcSecondary
248 XMacStand ribbon.mac
249 """
250 ribbon._doc_examples = """
251 To apply the ribbon style to the PDB file loaded, type:
252
253 relax> molmol.ribbon()
254 """
255 _build_doc(ribbon)
256
257
270
271
272 tensor_pdb._doc_title = "Display the diffusion tensor PDB geometric object over the loaded PDB."
273 tensor_pdb._doc_title_short = "Diffusion tensor and structure display."
274 tensor_pdb._doc_args = [
275 ["file", "The name of the PDB file containing the tensor geometric object."]
276 ]
277 tensor_pdb._doc_desc = """
278 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.
279
280 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:
281
282 SelectAtom ''
283 SelectBond ''
284 SelectAngle ''
285 SelectDist ''
286 SelectPrim ''
287 RotateInit
288 MoveInit
289
290 Next the tensor PDB file is read in, selected, and the covalent bonds of the PDB CONECT records calculated:
291
292 ReadPdb file
293 SelectMol '@file'
294 CalcBond 1 1 1
295
296 Then only the atoms and bonds of the geometric object are selected and the 'ball/stick' style applied:
297
298 SelectAtom '0'
299 SelectBond '0'
300 SelectAtom ':TNS'
301 SelectBond ':TNS'
302 XMacStand ball_stick.mac
303
304 The appearance is finally touched up:
305
306 RadiusAtom 1
307 SelectAtom ':TNS@C*'
308 RadiusAtom 1.5
309 """
310 _build_doc(tensor_pdb)
311
312
314
315 if self._exec_info.intro:
316 text = self._exec_info.ps3 + "molmol.view()"
317 print(text)
318
319
320 molmol.view()
321
322
323 view._doc_title = "View the collection of molecules from the loaded PDB file."
324 view._doc_title_short = "Molecule viewing."
325 view._doc_desc = """
326 This will simply launch Molmol.
327 """
328 view._doc_examples = """
329 relax> molmol.view()
330 """
331 _build_doc(view)
332