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 structure user function GUI elements."""
25
26
27 from os import sep
28 from string import split
29 import wx
30
31
32 from generic_fns.pipes import cdp_name, pipe_names
33
34
35 from base import UF_base, UF_page
36 from gui.misc import float_to_gui, gui_to_bool, gui_to_float, gui_to_int, gui_to_int_or_list, gui_to_str, gui_to_str_or_list, str_to_gui
37 from gui.paths import WIZARD_IMAGE_PATH
38
39
40
42 """The container class for holding all GUI elements."""
43
50
51
58
59
66
67
74
75
82
83
90
91
98
99
106
107
114
115
116
118 """The structure.create_diff_tensor_pdb() user function page."""
119
120
121 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'create_diff_tensor_pdb.png'
122 uf_path = ['structure', 'create_diff_tensor_pdb']
123 height_desc = 400
124
125 - def add_contents(self, sizer):
126 """Add the structure specific GUI elements.
127
128 @param sizer: A sizer object.
129 @type sizer: wx.Sizer instance
130 """
131
132
133 self.scale = self.input_field(sizer, "Scaling factor:", tooltip=self.uf._doc_args_dict['scale'])
134 self.scale.SetValue(float_to_gui(1.8e-6))
135
136
137 self.file = self.file_selection(sizer, "The PDB file:", message="PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file'])
138
139
140 self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force'], default=False)
141
142
143 - def on_execute(self):
144 """Execute the user function."""
145
146
147 file = gui_to_str(self.file.GetValue())
148 if not file:
149 return
150
151
152 force = gui_to_bool(self.force.GetValue())
153
154
155 scale = gui_to_float(self.scale.GetValue())
156
157
158 self.execute('structure.create_diff_tensor_pdb', scale=scale, file=file, force=force)
159
160
161
163 """The structure.create_vector_dist() user function page."""
164
165
166 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'create_vector_dist.png'
167 uf_path = ['structure', 'create_vector_dist']
168
169 - def add_contents(self, sizer):
170 """Add the structure specific GUI elements.
171
172 @param sizer: A sizer object.
173 @type sizer: wx.Sizer instance
174 """
175
176
177 self.length = self.input_field(sizer, "Vector length:", tooltip=self.uf._doc_args_dict['length'])
178 self.length.SetValue(float_to_gui(2e-9))
179
180
181 self.file = self.file_selection(sizer, "The PDB file:", message="PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file'])
182
183
184 self.symmetry = self.boolean_selector(sizer, "Symmetry flag:", tooltip=self.uf._doc_args_dict['symmetry'], default=True)
185
186
187 self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force'], default=False)
188
189
190 - def on_execute(self):
191 """Execute the user function."""
192
193
194 file = gui_to_str(self.file.GetValue())
195 if not file:
196 return
197
198
199 force = gui_to_bool(self.force.GetValue())
200
201
202 length = gui_to_float(self.length.GetValue())
203
204
205 self.execute('structure.create_vector_dist', length=length, file=file, symmetry=symmetry, force=force)
206
207
208
209 -class Delete_page(UF_page):
210 """The structure.delete() user function page."""
211
212
213 uf_path = ['structure', 'delete']
214
215 - def add_contents(self, sizer):
216 """Add the structure specific GUI elements.
217
218 @param sizer: A sizer object.
219 @type sizer: wx.Sizer instance
220 """
221
222
223 - def on_execute(self):
224 """Execute the user function."""
225
226
227 self.execute('structure.delete')
228
229
230
231 -class Get_pos_page(UF_page):
232 """The structure.get_pos() user function page."""
233
234
235 uf_path = ['structure', 'get_pos']
236 height_desc = 300
237
238 - def add_contents(self, sizer):
239 """Add the structure specific GUI elements.
240
241 @param sizer: A sizer object.
242 @type sizer: wx.Sizer instance
243 """
244
245
246 self.spin_id = self.spin_id_element(sizer, default='@N')
247
248
249 self.ave_pos = self.boolean_selector(sizer, "Average the atom position across models:", tooltip=self.uf._doc_args_dict['ave_pos'], default=True)
250
251
252 - def on_execute(self):
253 """Execute the user function."""
254
255
256 spin_id = gui_to_str(self.spin_id.GetValue())
257 ave_pos = gui_to_bool(self.ave_pos.GetValue())
258
259
260 self.execute('structure.get_pos', spin_id=spin_id, ave_pos=ave_pos)
261
262
263
264 -class Load_spins_page(UF_page):
265 """The structure.load_spins() user function page."""
266
267
268 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'load_spins.png'
269 uf_path = ['structure', 'load_spins']
270
271 - def add_contents(self, sizer):
272 """Add the structure specific GUI elements.
273
274 @param sizer: A sizer object.
275 @type sizer: wx.Sizer instance
276 """
277
278
279 self.spin_id = self.spin_id_element(sizer, default='@N')
280
281
282 self.ave_pos = self.boolean_selector(sizer, "Average the atom position across models:", tooltip=self.uf._doc_args_dict['ave_pos'], default=True)
283
284
285 - def on_execute(self):
286 """Execute the user function."""
287
288
289 spin_id = gui_to_str(self.spin_id.GetValue())
290 ave_pos = gui_to_bool(self.ave_pos.GetValue())
291
292
293 self.execute('structure.load_spins', spin_id=spin_id, ave_pos=ave_pos)
294
295
296
297 -class Read_pdb_page(UF_page):
298 """The structure.read_pdb() user function page."""
299
300
301 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'read_pdb.png'
302 uf_path = ['structure', 'read_pdb']
303
304 - def add_contents(self, sizer):
305 """Add the structure specific GUI elements.
306
307 @param sizer: A sizer object.
308 @type sizer: wx.Sizer instance
309 """
310
311
312 self.file = self.file_selection(sizer, "The PDB file:", message="PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
313
314
315 self.read_mol = self.input_field(sizer, "Read molecule number:", tooltip=self.uf._doc_args_dict['read_mol'])
316
317
318 self.set_mol_name = self.input_field(sizer, "Set the molecule name:", tooltip=self.uf._doc_args_dict['set_mol_name'])
319
320
321 self.read_model = self.input_field(sizer, "Read model number:", tooltip=self.uf._doc_args_dict['read_model'])
322
323
324 self.set_model_num = self.input_field(sizer, "Set the model number:", tooltip=self.uf._doc_args_dict['set_model_num'])
325
326
327 self.parser = self.combo_box(sizer, "The PDB parser:", choices=['internal', 'scientific'], tooltip=self.uf._doc_args_dict['parser'])
328 self.parser.SetValue(str_to_gui('internal'))
329
330
331 - def on_execute(self):
332 """Execute the user function."""
333
334
335 file = gui_to_str(self.file.GetValue())
336 read_mol = gui_to_int_or_list(self.read_mol.GetValue())
337 set_mol_name = gui_to_str_or_list(self.set_mol_name.GetValue())
338 read_model = gui_to_int_or_list(self.read_model.GetValue())
339 set_model_num = gui_to_int_or_list(self.set_model_num.GetValue())
340 parser = gui_to_str(self.parser.GetValue())
341
342
343 self.execute('structure.read_pdb', file=file, read_mol=read_mol, set_mol_name=set_mol_name, read_model=read_model, set_model_num=set_model_num, parser=parser)
344
345
346
347 -class Read_xyz_page(UF_page):
348 """The structure.read_xyz() user function page."""
349
350
351
352 uf_path = ['structure', 'read_xyz']
353
354 - def add_contents(self, sizer):
355 """Add the structure specific GUI elements.
356
357 @param sizer: A sizer object.
358 @type sizer: wx.Sizer instance
359 """
360
361
362 self.file = self.file_selection(sizer, "The XYZ file:", message="XYZ file selection", wildcard="XYZ files (*.xyz)|*.xyz;*.XYZ", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
363
364
365 self.read_mol = self.input_field(sizer, "Read molecule number:", tooltip=self.uf._doc_args_dict['read_mol'])
366
367
368 self.set_mol_name = self.input_field(sizer, "Set the molecule name:", tooltip=self.uf._doc_args_dict['set_mol_name'])
369
370
371 self.read_model = self.input_field(sizer, "Read model number:", tooltip=self.uf._doc_args_dict['read_model'])
372
373
374 self.set_model_num = self.input_field(sizer, "Set the model number:", tooltip=self.uf._doc_args_dict['set_model_num'])
375
376
377 - def on_execute(self):
378 """Execute the user function."""
379
380
381 file = gui_to_str(self.file.GetValue())
382 read_mol = gui_to_int_or_list(self.read_mol.GetValue())
383 set_mol_name = gui_to_str_or_list(self.set_mol_name.GetValue())
384 read_model = gui_to_int_or_list(self.read_model.GetValue())
385 set_model_num = gui_to_int_or_list(self.set_model_num.GetValue())
386
387
388 self.execute('structure.read_xyz', file=file, read_mol=read_mol, set_mol_name=set_mol_name, read_model=read_model, set_model_num=set_model_num)
389
390
391
392 -class Write_pdb_page(UF_page):
393 """The structure.write_pdb() user function page."""
394
395
396 image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'write_pdb.png'
397 uf_path = ['structure', 'write_pdb']
398
399 - def add_contents(self, sizer):
400 """Add the structure specific GUI elements.
401
402 @param sizer: A sizer object.
403 @type sizer: wx.Sizer instance
404 """
405
406
407 self.file = self.file_selection(sizer, "The PDB file:", message="PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file'])
408
409
410 self.model_num = self.input_field(sizer, "Only write model number:", tooltip=self.uf._doc_args_dict['model_num'])
411
412
413 - def on_execute(self):
414 """Execute the user function."""
415
416
417 file = gui_to_str(self.file.GetValue())
418 model_num = gui_to_str(self.model_num.GetValue())
419
420
421 self.execute('structure.write_pdb', file=file, model_num=model_num)
422
423
424
425 -class Vectors_page(UF_page):
426 """The structure.vectors() user function page."""
427
428
429 uf_path = ['structure', 'vectors']
430
431 - def add_contents(self, sizer):
432 """Add the structure specific GUI elements.
433
434 @param sizer: A sizer object.
435 @type sizer: wx.Sizer instance
436 """
437
438
439 self.attached = self.input_field(sizer, "The attached atom:", tooltip=self.uf._doc_args_dict['attached'])
440 self.attached.SetValue(str_to_gui("H"))
441
442
443 self.spin_id = self.spin_id_element(sizer, desc='Restrict vector loading to the spins:')
444
445
446 self.model = self.input_field(sizer, "The model:", tooltip=self.uf._doc_args_dict['model'])
447
448
449 self.verbosity = self.spin_control(sizer, "The verbosity level:", default=1, min=0, tooltip=self.uf._doc_args_dict['verbosity'])
450
451
452 self.ave = self.boolean_selector(sizer, "Average the vector across models:", tooltip=self.uf._doc_args_dict['ave'], default=True)
453
454
455 self.unit = self.boolean_selector(sizer, "Calculate unit vectors:", tooltip=self.uf._doc_args_dict['unit'], default=True)
456
457
458 - def on_execute(self):
459 """Execute the user function."""
460
461
462 attached = gui_to_str(self.attached.GetValue())
463 spin_id = gui_to_str(self.spin_id.GetValue())
464 model = gui_to_int(self.model.GetValue())
465 verbosity = gui_to_int(self.verbosity.GetValue())
466 ave = gui_to_bool(self.ave.GetValue())
467 unit = gui_to_bool(self.unit.GetValue())
468
469
470 self.execute('structure.vectors', attached=attached, spin_id=spin_id, model=model, verbosity=verbosity, ave=ave, unit=unit)
471