-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpyMODE_TASK.py
executable file
·2679 lines (2236 loc) · 99.6 KB
/
pyMODE_TASK.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
#filename: pypca.py
#--------------------------------------------------
# TO DO
#===================================================
# 1. Add astrik over required input field --- done
# 2. check to look for mode-task files within conf setting ---- done
# 3. Resize/adjust NMA tab. -------- done
# 4. Add progress bar
# 5. Add better handling of exceptions in NMA
# pyMODE-TASK Copyright Notice
# ============================
#
# The pyMODE-TASK -- a plugin for MODE-TASK, source code is copyrighted, but you can freely use and
# copy it as long as you don't change or remove any of the copyright
# notices.
#
# ----------------------------------------------------------------------
# pyMODE-TASK plugin is Copyright (C) 2017 by Bilal Nizami
#
# All Rights Reserved
#
# Permission to use, copy, modify, distribute, and distribute modified
# versions of this software and its documentation for any purpose and
# without fee is hereby granted, provided that the above copyright
# notice appear in all copies and that both the copyright notice and
# this permission notice appear in supporting documentation, and that
# the name of Bilal Nizami not be used in advertising or publicity
# pertaining to distribution of the software without specific, written
# prior permission.
#
# BILAL NIZAMI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS. IN NO EVENT SHALL BILAL NIZAMI BE LIABLE FOR ANY
# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ----------------------------------------------------------------------
#================================================================
import matplotlib
matplotlib.use('Agg')
import os, sys
import os.path
if sys.version_info[0] < 3:
import Tkinter
from Tkinter import *
from os.path import expanduser
home = expanduser("~")
else:
import tkinter as Tkinter
from tkinter import *
from pathlib import Path
home = str(Path.home())
import subprocess
from tkinter.ttk import Separator, Style
import tkinter.ttk
import Pmw
import tkinter.messagebox, tkinter.filedialog
import os
import pymol
from pymol import cmd
import webbrowser
__version__ = "1.0.0"
"""
pyMODE-TASK
"""
def __init__(self):
self.menuBar.addmenuitem('Plugin', 'command',
'Launch pyMODE-TASK',
label='pyMODE-TASK',
command = lambda s=self: PyMODETASK(s))
class PyMODETASK:
'''Main class of pyMODE-TASK.'''
def __init__(self, app):
self.master = app.root
adplugin_font = ("Courier", 12)
self.frame = Frame(self.master, width=4, height=4, bg="red3", colormap="new")
self.frame.pack()
# build main window
adplugin_font = ("Courier", 10)
self.dialog = Pmw.Dialog(self.master,title = 'pyMODE-TASK',
buttons = ('Exit pyMODE-TASK',))
self.dialog.withdraw()
self.dialog.geometry('1000x730')
#================================================
#
# Menu bar
#===============================================
# Create about dialog.
self.dialog1 = Pmw.MessageDialog(self.dialog.interior(),
title = 'pyMODE-TASK',
message_text = 'A pymol plugin for MODE-TASK\n\n'+
'Version %s\n\n' %__version__ +
'MODE-TASK and pyMODE-TASK is a open source collection of tools to perform the\n'+
'Principal component analysis (PCA), MDS and t-SNE on a protein MD trajectory,\n' +
'and Normal mode analysis (NMA) on protein 3D structure.\n'+
'pyMODE-TASK- is Copyright (C) 2017 by Bilal Nizami, RUBi, Rhodes University.\n',
buttonboxpos = 's',
buttons = ('OK', 'Close'),
defaultbutton = 'Close')
self.dialog1.iconname('pyMODE-TASK')
widget = self.dialog1.component('hull')
Pmw.Color.changecolor(widget, background = 'brown4', foreground='white')
self.dialog1.withdraw()
# Create the Balloon.
self.balloon = Pmw.Balloon(self.master)
# Create and pack the MenuBar.
self.menuBar = Pmw.MenuBar(self.dialog.interior(),
hotkeys=0,
hull_relief = 'raised',
hull_borderwidth = 2,
balloon = self.balloon)
self.menuBar.pack(fill = 'x')
# Add File menu bar.
self.menuBar.addmenu('File', 'Close this window or exit')
self.menuBar.addmenuitem('File', 'command', 'About the pyMODE-TASK',
label = 'About',
command=self.dialog1.activate
)
self.menuBar.addmenuitem('File', 'separator')
self.menuBar.addmenuitem('File', 'command', 'Exit the application',
label = 'Exit',
command=self.dialog.interior().quit)
# Add Help menu bar.
page=MyHelpPage("http://mode-task.readthedocs.io/en/latest/index.html")
self.menuBar.addmenu('Help', 'Help page')
self.menuBar.addmenuitem('Help', 'command', label='Help Page',
command=page.openpage)
page=MyHelpPage("http://pymode-task.readthedocs.io/en/latest/index.html")
#self.menuBar.addmenu('Help', 'pyMODE-TASK help')
self.menuBar.addmenuitem('Help', 'command', label='pyMODE-TASK help',
command=page.openpage)
page=MyHelpPage("http://mode-task.readthedocs.io/en/latest/theory.html")
self.menuBar.addmenuitem('Help', 'separator')
self.menuBar.addmenuitem('Help', 'command', label='PCA Theory',
command=page.openpage)
page=MyHelpPage("http://mode-task.readthedocs.io/en/latest/theory.html")
self.menuBar.addmenuitem('Help', 'command', label='NMA Theory',
command=page.openpage)
self.menuBar.addmenuitem('Help', 'separator')
page=MyHelpPage("http://mode-task.readthedocs.io/en/latest/pca_use.html")
self.menuBar.addmenuitem('Help', 'command', label='PCA Usage',
command=page.openpage)
page=MyHelpPage("http://mode-task.readthedocs.io/en/latest/nma_use.html")
self.menuBar.addmenuitem('Help', 'command', label='NMA Usage',
command=page.openpage)
page=MyHelpPage("http://mode-task.readthedocs.io/en/latest/pca_tut.html")
self.menuBar.addmenuitem('Help', 'separator')
self.menuBar.addmenuitem('Help', 'command', label='PCA Tutorial',
command=page.openpage)
page=MyHelpPage("http://mode-task.readthedocs.io/en/latest/nma_tut.html")
self.menuBar.addmenuitem('Help', 'command', label='NMA Tutorial',
command=page.openpage)
# The title
self.title_label = Label(self.dialog.interior(), text = 'pyMODE-TASK: A pymol plugin of MODE-TASK -- Copyright (C) 2017, Bilal Nizami, RUBi, Rhodes University',
background = 'brown4',
foreground = 'white',
height=1,
width=880,
font=('Arial', 11))
self.title_label.pack(expand = 0, fill = 'both', padx = 1, pady = 1)
# the notebook layout
self.notebook = Pmw.NoteBook(self.dialog.interior())
Pmw.Color.changecolor(self.dialog.interior(), background='gray70', foreground='black')
self.notebook.recolorborders()
self.notebook.pack(fill='both',expand=1,padx=13,pady=13)
# build pages
self.configuration_page = self.notebook.add('Configuration')
self.pca_page = self.notebook.add('PCA')
self.ipca_page = self.notebook.add('Internal PCA')
self.mds_page = self.notebook.add('MDS/t-SNE')
self.nma_page = self.notebook.add('NMA')
self.about_page = self.notebook.add('About')
self.citation_page = self.notebook.add('Citation')
self.help_page = self.notebook.add('Help and Credit')
#---------------------------------------------------------------
# configuration PAGE
#---------------------------------------------------------------
self.balloon = Pmw.Balloon(self.master)
about_pca = """Give the location of pyMODE-TASK directory. For example- If the pyMODE-TASK
directory is in user's home, then pyMODE-TASK directory field should read like /home/user/pyMODE-TASK.
Normally the core scripts should be within pyMODE-TASK/src directory."""
self.conf_top_group = Pmw.Group(self.configuration_page,tag_text='Configuration instructions')
self.conf_top_group.pack(fill = 'both', expand = 0, padx = 2, pady = 25)
myfont = Pmw.logicalfont(name='Courier',size=14)
self.text_field = Pmw.ScrolledText(self.conf_top_group.interior(),
borderframe=5,
vscrollmode='dynamic',
hscrollmode='dynamic',
labelpos='n',
text_width=150, text_height=5,
text_wrap='word',
text_background='navy',
text_foreground='white',
text_font = myfont)
self.text_field.pack(expand = 0, fill = 'both', padx = 4, pady = 4)
self.text_field.insert('end',about_pca)
self.text_field.configure(text_state=DISABLED)
# MODE-TASK location tab
self.mode_task_location = Pmw.Group(self.configuration_page, tag_text='Locate MODE-TASK directory:')
self.mode_task_location.pack(side = TOP,expand=0, fill='x', padx = 4, pady = 25)
# MODE-TASK location files
self.mode_task_location1 = Pmw.EntryField(self.mode_task_location.interior(),
labelpos = 'w',
label_pyclass = DirDialogButtonClassFactory.get(self.set_mode_task_dir),
label_text = 'pyMODE-TASK directory *:',
value=home)
self.balloon.bind(self.mode_task_location1, 'Kindly give the path of pyMODE-TASK directory.\nAll the MODE-TASK core script must be placed\n inside the src directory within the pyMODE-TASK directory.',
'Locate pyMODE-TASK directory')
self.mode_task_location1.pack(side=TOP, fill = 'x', expand = 0, padx = 2, pady = 25)
#===================================================================
# PCA PAGE
#===================================================================
# input files
self.pca_trj_file_io = Pmw.Group(self.pca_page, tag_text='MODE-TASK Input/Output')
self.pca_trj_file_io.pack(side = TOP,expand=1, fill='both', padx = 2, pady = 2)
# Read Trajectory
self.pca_trj_location = Pmw.EntryField(self.pca_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.pca_set_trj_filename,mode='r',filter=[("Gromacs",".xtc"), ("DCD",".dcd"), ("Amber",".mdcrd"), ("All","*.*")]),
label_text = 'Trajectory File *:',
)
self.balloon.bind(self.pca_trj_location, 'Read MD Trajectory file',
'Read MD Trajectory file')
# Read Topology
self.pca_top_location = Pmw.EntryField(self.pca_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.set_top_filename,mode='r',filter=[("PDB",".pdb"), ("GRO",".gro"), ("All","*.*")]),
label_text = 'Topology File *:')
self.balloon.bind(self.pca_top_location, 'Read Topology file',
'Read Topology file')
# RMSD Reference Structure
self.pca_ref_file = Pmw.EntryField(self.pca_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.set_ref_filename,mode='r',filter=[("PDB",".pdb"), ("All","*.*")]),
label_text = 'Ref Structure/Frame:')
self.balloon.bind(self.pca_ref_file, 'Reference structure for RMSD',
'Reference structure for RMSD')
# output directory
self.pca_out_dir_location = Pmw.EntryField(self.pca_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = DirDialogButtonClassFactory.get(self.pca_set_out_location),
label_text = 'Output Directory:',
value = os.getcwd())
self.balloon.bind(self.pca_out_dir_location, 'Results will be saved here',
'Results will be saved here')
entries=(self.pca_trj_location,
self.pca_top_location,
self.pca_ref_file,
self.pca_out_dir_location)
for x in entries:
x.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
Pmw.alignlabels(entries)
#--------------------------------------------
# PCA options
#--------------------------------------------
# PCA Methods
self.pca_page_main_group = Pmw.Group(self.pca_page, tag_text='PCA Options')
self.pca_page_main_group.pack(fill = 'both', expand = 1, padx=2, pady=2)
self.pca_methods_buttons = Pmw.RadioSelect(self.pca_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'PCA Method:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_pc_method_selection)
self.balloon.bind(self.pca_methods_buttons, 'PCA Method',
'PCA Method')
self.pca_methods_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.pca_methods_buttons.add('svd', command = self.ok, text='SVD')
self.pca_methods_buttons.add('evd', command = self.ok, text='EVD')
self.pca_methods_buttons.add('kpca', command = self.ok, text='KernelPCA')
self.pca_methods_buttons.add('ipca', command = self.ok, text='Incremental PCA')
self.pca_methods_buttons.invoke('svd')
# Atom group
self.atm_grp_buttons = Pmw.RadioSelect(self.pca_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Atom group:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_ag_selection)
self.balloon.bind(self.atm_grp_buttons, 'Select atoms for analysis',
'Select atoms for analysis')
self.atm_grp_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.atm_grp_buttons.add('all', command = self.ok, text='All')
self.atm_grp_buttons.add('CA', command = self.ok, text='C-Alpha')
self.atm_grp_buttons.add('backbone', command = self.ok, text='Backbone')
self.atm_grp_buttons.add('protein', command = self.ok, text='Protein')
self.atm_grp_buttons.invoke('CA')
# Number of PCA component
self.pca_comp = Pmw.EntryField(self.pca_page_main_group.interior(),
labelpos = 'w',
label_text = 'PCA component:',
value='All',
command = self.get_pc_selection)
self.balloon.bind(self.pca_comp, 'No. of Principal Component to save',
'No. of Principal Component to save')
self.pca_comp.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
# Kernel Type
self.kernel_type = Pmw.RadioSelect(self.pca_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Kernel Type (kPCA):',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_kt_selection)
self.balloon.bind(self.kernel_type, 'Type of Kernel.\nUsed with kpca method',
'Type of Kernel')
self.kernel_type.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.kernel_type.add('linear', command = self.ok, text='Linear')
self.kernel_type.add('poly', command = self.ok, text='Poly')
self.kernel_type.add('rbf', command = self.ok, text='RBF')
self.kernel_type.add('sigmoid', command = self.ok, text='Sigmoid')
self.kernel_type.add('precomputed', command = self.ok, text='Precomputed')
self.kernel_type.add('cosine', command = self.ok, text='Cosine')
self.kernel_type.invoke('linear')
# SVD Solver
self.svd_solver_type = Pmw.RadioSelect(self.pca_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'SVD solver:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_st_selection
)
self.balloon.bind(self.svd_solver_type, 'Type of SVD solver.\nOnly useful with SVD method',
'Type of SVD solver')
self.svd_solver_type.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.svd_solver_type.add('auto', command = self.ok, text='Auto')
self.svd_solver_type.add('full', command = self.ok, text='Full')
self.svd_solver_type.add('arpack', command = self.ok, text='Arpack')
self.svd_solver_type.add('randomized', command = self.ok, text='Randomized')
self.svd_solver_type.invoke('auto')
pca_options_buttons=(self.pca_methods_buttons, self.atm_grp_buttons, self.pca_comp, self.kernel_type, self.svd_solver_type)
Pmw.alignlabels(pca_options_buttons)
# progress bar
#self.pb = ttk.Progressbar(self.pca_page_main_group.interior(),
# orient="horizontal",
# length=500,
# mode="indeterminate")
#self.pb.pack()
# Run button
self.run_pca_button = Pmw.ButtonBox(self.pca_page_main_group.interior(),orient='horizontal', padx=2,pady=2)
self.run_pca_button.add('Run PCA',fg='blue', command = self.run_pca)
self.run_pca_button.pack(side=LEFT, expand = 1, padx = 2, pady = 2)
##============================================================
#
# internal PCA page
#===========================================================
# input files
self.icpca_trj_file_io = Pmw.Group(self.ipca_page, tag_text='MODE-TASK Input/Output')
self.icpca_trj_file_io.pack(side = TOP,expand=1, fill='both')
# Read Trajectory
self.ipca_trj_location = Pmw.EntryField(self.icpca_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.ipca_set_trj_filename,mode='r',filter=[("Gromacs",".xtc"), ("DCD",".dcd"), ("Amber",".mdcrd"), ("All","*.*")]),
label_text = 'Trajectory File *:',
)
self.balloon.bind(self.ipca_trj_location, 'Read MD Trajectory file',
'Read MD Trajectory file')
# Read Topology
self.ipca_top_location = Pmw.EntryField(self.icpca_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.ipca_set_top_filename,mode='r',filter=[("PDB",".pdb"), ("GRO",".gro"), ("All","*.*")]),
label_text = 'Topology File *:')
self.balloon.bind(self.ipca_top_location, 'Read topology file',
'Read topology file')
# output directory
self.ipca_out_dir_location = Pmw.EntryField(self.icpca_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = DirDialogButtonClassFactory.get(self.ipca_set_out_location),
label_text = 'Output Directory:',
value = os.getcwd())
self.balloon.bind(self.ipca_out_dir_location, 'Results will be saved here',
'Results will be saved here')
entries=(self.ipca_trj_location,
self.ipca_top_location,
self.ipca_out_dir_location)
for x in entries:
x.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
Pmw.alignlabels(entries)
#==========================================
# internal PCA options
#------------------------------------------
self.ipca_page_main_group = Pmw.Group(self.ipca_page, tag_text='Internal PCA Options')
self.ipca_page_main_group.pack(fill = 'both', expand = 1, padx=2, pady=2)
## cordinate type
self.ct_buttons = Pmw.RadioSelect(self.ipca_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Cordinate type:',
frame_borderwidth = 2,
frame_relief = 'groove')
self.ct_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.ct_buttons.add('distance', command = self.ok)
self.ct_buttons.add('angle', command = self.ok)
self.ct_buttons.add('phi', command = self.ok)
self.ct_buttons.add('psi', command = self.ok)
self.ct_buttons.invoke('distance')
self.balloon.bind(self.ct_buttons, 'Type of internal cordinate',
'Type of internal cordinate')
# Atom group
self.ipca_atm_grp_buttons = Pmw.RadioSelect(self.ipca_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Atom group:',
frame_borderwidth = 2,
frame_relief = 'groove')
self.ipca_atm_grp_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.ipca_atm_grp_buttons.add('all', command = self.ok, text='All')
self.ipca_atm_grp_buttons.add('CA', command = self.ok, text='CA')
self.ipca_atm_grp_buttons.add('backbone', command = self.ok, text='Backbone')
self.ipca_atm_grp_buttons.add('protein', command = self.ok, text='Protein')
self.ipca_atm_grp_buttons.invoke('CA')
self.balloon.bind(self.ipca_atm_grp_buttons, 'Select atoms for analysis',
'Select atoms for analysis')
# Number of PCA component
self.pca_comp = Pmw.EntryField(self.ipca_page_main_group.interior(),
labelpos = 'w',
label_text = 'PCA component:',
value='All',
command = self.get_pc_selection)
self.pca_comp.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.balloon.bind(self.pca_comp, 'No. of principal component to save',
'No. of principal component to save')
pca_options_buttons=(self.ct_buttons,
self.ipca_atm_grp_buttons,
self.pca_comp)
Pmw.alignlabels(pca_options_buttons)
# Run button
self.run_pca_button = Pmw.ButtonBox(self.ipca_page_main_group.interior(),
orient='horizontal',
padx=2, pady=2)
self.run_pca_button.add('Run Internal PCA',fg='blue', command = self.run_ipca)
self.run_pca_button.pack(side=LEFT, expand = 1, padx = 2, pady = 2)
##============================================================
# MDS/ t-SNE page
#
#==============================================================
# input files
self.mds_trj_file_io = Pmw.Group(self.mds_page, tag_text='MDS, t-SNE Input/Output')
self.mds_trj_file_io.pack(side = TOP,expand=1, fill='both', padx = 2, pady = 2)
# Read Trajectory
self.mds_trj_location = Pmw.EntryField(self.mds_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.mds_set_trj_filename,mode='r',filter=[("Gromacs",".xtc"), ("DCD",".dcd"), ("Amber",".mdcrd"), ("All","*.*")]),
label_text = 'Trajectory File *:',
)
self.balloon.bind(self.mds_trj_location, 'Read MD trajectory file',
'Read MD trajectory file')
# Read Topology
self.mds_top_location = Pmw.EntryField(self.mds_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.mds_set_top_filename,mode='r',filter=[("PDB",".pdb"), ("GRO",".gro"), ("All","*.*")]),
label_text = 'Topology File *:')
self.balloon.bind(self.mds_top_location, 'Read topology file',
'Read topology file')
# output directory
self.mds_out_dir_location = Pmw.EntryField(self.mds_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = DirDialogButtonClassFactory.get(self.mds_set_out_location),
label_text = 'Output Directory:',
value = os.getcwd())
self.balloon.bind(self.mds_out_dir_location, 'Results will be saved here',
'Results will be saved here')
entries=(self.mds_trj_location,
self.mds_top_location,
self.mds_out_dir_location)
for x in entries:
x.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
Pmw.alignlabels(entries)
# MDS options
#-------------------------------------------------
# MDS Type
self.radioframe = Frame(self.mds_page)
radiogroups = []
self.mds_page_main_group = Pmw.Group(self.radioframe, tag_text='MDS Options')
self.mds_page_main_group.pack(side=LEFT, fill = 'both', expand = 1, padx=2, pady=2)
radiogroups.append(self.mds_page_main_group)
self.mds_type_buttons = Pmw.RadioSelect(self.mds_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'MDS Method:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_mds_type_selection)
self.balloon.bind(self.mds_type_buttons, 'Type of MDS',
'Type of MDS')
self.mds_type_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.mds_type_buttons.add('metric', command = self.ok, text='metric')
self.mds_type_buttons.add('nm', command = self.ok, text ='nonmetric')
self.mds_type_buttons.invoke('metric')
# Atom group
self.atm_grp_buttons = Pmw.RadioSelect(self.mds_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Atom group:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_ag_selection)
self.balloon.bind(self.atm_grp_buttons, 'Select atoms for analysis',
'Select atoms for analysis')
self.atm_grp_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.atm_grp_buttons.add('all', command = self.ok, text='All')
self.atm_grp_buttons.add('CA', command = self.ok, text='CA')
self.atm_grp_buttons.add('backbone', command = self.ok, text='Backbone')
self.atm_grp_buttons.add('protein', command = self.ok, text='Protein')
self.atm_grp_buttons.invoke('CA')
# Dissimilarity Type
self.mds_dissimilarity_type = Pmw.RadioSelect(self.mds_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Dissimilarity type:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_mds_dissimilarity_type)
self.balloon.bind(self.mds_dissimilarity_type, 'Type of dissimilarity matrix',
'Type of dissimilarity matrix')
self.mds_dissimilarity_type.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.mds_dissimilarity_type.add('euc', command = self.ok, text='Euclidean distance')
self.mds_dissimilarity_type.add('rmsd', command = self.ok, text='RMSD')
self.mds_dissimilarity_type.invoke('rmsd')
# Cordinate Type
self.mds_cord_type = Pmw.RadioSelect(self.mds_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Cordinate Type:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_mds_cord_type
)
self.balloon.bind(self.mds_cord_type, 'Internal coordinates type.Only used with euclidean distance',
'Internal coordinates type.Only used with euclidean distance')
self.mds_cord_type.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.mds_cord_type.add('distance', command = self.ok)
self.mds_cord_type.add('phi', command = self.ok)
self.mds_cord_type.add('psi', command = self.ok)
self.mds_cord_type.add('angle', command = self.ok)
self.mds_cord_type.invoke('distance')
# Atom Indices
self.mds_atm_ind_buttons = Pmw.RadioSelect(self.mds_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Atom indices:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_ag_selection)
self.balloon.bind(self.mds_atm_ind_buttons, 'Group of atom for pairwise distance',
'Group of atom for pairwise distance')
self.mds_atm_ind_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.mds_atm_ind_buttons.add('all', command = self.ok, text='All')
self.mds_atm_ind_buttons.add('alpha', command = self.ok, text='CA')
self.mds_atm_ind_buttons.add('backbone', command = self.ok, text='Backbone')
self.mds_atm_ind_buttons.add('minimal', command = self.ok, text='Minimal')
self.mds_atm_ind_buttons.invoke('alpha')
mds_options_buttons=(self.mds_type_buttons,
self.atm_grp_buttons,
self.mds_dissimilarity_type,
self.mds_cord_type,
self.mds_atm_ind_buttons)
Pmw.alignlabels(mds_options_buttons)
# Run MDS button
self.run_mds_button = Pmw.ButtonBox(self.mds_page_main_group.interior(),
orient='horizontal',
padx=2, pady=2)
self.run_mds_button.add('Run MDS',
fg='blue',
command = self.run_mds)
self.run_mds_button.pack(side=LEFT, expand = 1, padx = 2, pady = 2)
##=========================================
# t-SNE options
#-----------------------------------------
# t-SNE options
self.tsne_page_main_group = Pmw.Group(self.radioframe, tag_text='t-SNE Options')
self.tsne_page_main_group.pack(side=LEFT, fill = 'both', expand = 1, padx=2, pady=2)
radiogroups.append(self.tsne_page_main_group)
Pmw.aligngrouptags(radiogroups,)
self.radioframe.pack(padx = 2, pady = 2, expand='yes', fill='both')
# Atom group
self.atm_grp_buttons = Pmw.RadioSelect(self.tsne_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Atom group:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_ag_selection)
self.atm_grp_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.atm_grp_buttons.add('all', command = self.ok, text='All')
self.atm_grp_buttons.add('CA', command = self.ok, text='CA')
self.atm_grp_buttons.add('backbone', command = self.ok, text='Backbone')
self.atm_grp_buttons.add('protein', command = self.ok, text='Protein')
self.atm_grp_buttons.invoke('CA')
# Dissimilarity Type
self.tsne_dissimilarity_type = Pmw.RadioSelect(self.tsne_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Dissimilarity type:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_mds_dissimilarity_type)
self.tsne_dissimilarity_type.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.tsne_dissimilarity_type.add('euc', command = self.ok, text='Euclidean distance')
self.tsne_dissimilarity_type.add('rmsd', command = self.ok, text='RMSD')
self.tsne_dissimilarity_type.invoke('rmsd')
# Cordinate Type
self.tsne_cord_type = Pmw.RadioSelect(self.tsne_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Cordinate Type:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_mds_cord_type
)
self.tsne_cord_type.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.tsne_cord_type.add('distance', command = self.ok)
self.tsne_cord_type.add('phi', command = self.ok)
self.tsne_cord_type.add('psi', command = self.ok)
self.tsne_cord_type.add('angle', command = self.ok)
self.tsne_cord_type.invoke('distance')
# Atom Indices
self.atm_ind_buttons = Pmw.RadioSelect(self.tsne_page_main_group.interior(),
buttontype = 'radiobutton',
selectmode = 'single',
labelpos = 'w',
label_text = 'Atom indices:',
frame_borderwidth = 2,
frame_relief = 'groove',
command = self.get_ag_selection)
self.atm_ind_buttons.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.atm_ind_buttons.add('all', command = self.ok, text='All')
self.atm_ind_buttons.add('CA', command = self.ok, text='CA')
self.atm_ind_buttons.add('backbone', command = self.ok, text='Backbone')
self.atm_ind_buttons.add('protein', command = self.ok, text='Protein')
self.atm_ind_buttons.invoke('CA')
# n_itr
self.n_itr = Pmw.EntryField(self.tsne_page_main_group.interior(),
labelpos = 'w',
label_text = 'Iterations:',
value = 3000,
command = self.get_n_itr)
self.n_itr.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.balloon.bind(self.n_itr, 'Maximum number of iterations for the optimization',
'Number of iteration')
# perplexity
self.perplexity = Pmw.EntryField(self.tsne_page_main_group.interior(),
labelpos = 'w',
label_text = 'Perplexity:',
value = 30.0,
command = self.get_perplexity)
self.perplexity.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.balloon.bind(self.perplexity, 'The perplexity is related to the number of nearest neighbors that is used in other manifold learning algorithms. (float)',
'perplexity')
# Learning rate
self.learning_rate = Pmw.EntryField(self.tsne_page_main_group.interior(),
labelpos = 'w',
label_text = 'Learning rate:',
value = 200.0,
command = self.get_learning_rate)
self.learning_rate.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.balloon.bind(self.learning_rate, 'The learning rate for t-SNE',
'Learning rate')
mds_options_buttons=(self.mds_type_buttons,
self.atm_grp_buttons,
self.tsne_dissimilarity_type,
self.tsne_cord_type,
self.atm_ind_buttons,
self.n_itr,
self.perplexity,
self.learning_rate)
Pmw.alignlabels(mds_options_buttons)
# Run t-SNE button
self.run_mds_button = Pmw.ButtonBox(self.tsne_page_main_group.interior(),orient='horizontal', padx=2,pady=2)
self.run_mds_button.add('Run t-SNE',fg='blue', command = self.run_tsne)
self.run_mds_button.pack(side=LEFT, expand = 1, padx = 2, pady = 2)
#==============================================================
# NMA PAGE
#==============================================================
# input files
self.nma_top_group1 = Pmw.Group(self.nma_page, tag_pyclass = None)
self.nma_top_group1.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
self.nma_trj_file_io = Pmw.Group(self.nma_top_group1.interior(), tag_text='Coarse Graining (1)')
self.nma_trj_file_io.pack(expand=1, fill='both', side=LEFT)
# Read PDB file
self.cg_pdb_location = Pmw.EntryField(self.nma_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.set_cg_pdb_filename,mode='r',filter=[("PDB",".pdb")]),
label_text = 'PDB File *:',
)
self.balloon.bind(self.cg_pdb_location, 'PDB for coarse graining',
'Read PDB for coarse graining')
# coarse graining
self.cg_level = Pmw.EntryField(self.nma_trj_file_io.interior(),
labelpos = 'w',
label_text = 'CG Level:')
self.balloon.bind(self.cg_level, 'level of coarse graining',
'coarse graining')
# Atom Type
self.cg_at_var = StringVar()
self.cg_at_var.set('CB')
self.cg_atm_type = Pmw.OptionMenu(self.nma_trj_file_io.interior(),
labelpos = 'w',
label_text = 'Atom Type:',
menubutton_textvariable = self.cg_at_var,
items = ['CB', 'CA'],
menubutton_width = 5,
)
self.balloon.bind(self.cg_atm_type, 'Atom type',
'Atom type')
# Starting atom
self.cg_start_atm = Pmw.EntryField(self.nma_trj_file_io.interior(),
labelpos = 'w',
label_text = 'Starting atom:',
value='1')
self.balloon.bind(self.cg_start_atm, 'Residue number of the starting atom',
'Residue number of the starting atom')
# output directory
self.cg_out_dir_location = Pmw.EntryField(self.nma_trj_file_io.interior(),
labelpos = 'w',
label_pyclass = DirDialogButtonClassFactory.get(self.set_cg_out_location),
label_text = 'Output Directory:',
value = os.getcwd())
# out pdb file name
self.cg_out_pdb = Pmw.EntryField(self.nma_trj_file_io.interior(),
labelpos = 'w',
label_text = 'Output PDB:',
value='ComplexCG.pdb')
self.balloon.bind(self.cg_out_pdb, 'Output PDB name',
'Output PDB name')
entries=(self.cg_pdb_location,
self.cg_level,
self.cg_start_atm,
self.cg_atm_type,
self.cg_out_dir_location,
self.cg_out_pdb)
for x in entries:
x.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
# Run coarse garining
self.run_cg_button = Pmw.ButtonBox(self.nma_trj_file_io.interior(),
orient='horizontal',
padx=2,
pady=2)
self.run_cg_button.add('Run Coarse Graining',fg='blue', command = self.run_cg)
self.run_cg_button.pack(side=RIGHT, expand = 1, padx = 2, pady = 2)
Pmw.alignlabels(entries)
# NMA options
self.nma_group = Pmw.Group(self.nma_top_group1.interior(), tag_text='NMA (2)')
self.nma_group.pack(expand=1, fill='both', side=LEFT)
# Read PDB file
self.nma_pdb_location = Pmw.EntryField(self.nma_group.interior(),
labelpos = 'w',
label_pyclass = FileDialogButtonClassFactory.get(self.set_nma_pdb_filename,mode='r',filter=[("PDB",".pdb")]),
label_text = 'PDB File *:',
)
self.nma_pdb_location.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
# Cutoff in Ang
self.nma_cut = Pmw.EntryField(self.nma_group.interior(),
labelpos = 'w',
label_text = 'Cutoff (Angstrom):',
value='15',
command = self.get_pc_selection)
self.nma_cut.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
# Atom Type
self.nma_at_var = StringVar()
self.nma_at_var.set('CB')
self.nma_atm_type = Pmw.OptionMenu(self.nma_group.interior(),
labelpos = 'w',
label_text = 'Atom Type:',
menubutton_textvariable = self.nma_at_var,
items = ['CB', 'CA'],
menubutton_width = 5,
)
self.nma_atm_type.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
# output directory
self.nma_out_dir_location = Pmw.EntryField(self.nma_group.interior(),
labelpos = 'w',
label_pyclass = DirDialogButtonClassFactory.get(self.nma_set_out_location),
label_text = 'Output Directory:',
value = os.getcwd())
self.nma_out_dir_location.pack(fill = 'both', expand = 1, padx = 2, pady = 2)
pca_options_buttons=(self.nma_pdb_location,
self.nma_cut,
self.nma_atm_type,
self.nma_out_dir_location)
Pmw.alignlabels(pca_options_buttons)
# Run button
self.run_pca_button = Pmw.ButtonBox(self.nma_group.interior(),
orient='horizontal',
padx=2,
pady=2)
self.run_pca_button.add('Run NMA',fg='blue', command = self.run_nma)
self.run_pca_button.pack(side=LEFT, expand = 1, padx = 2, pady = 2)
##====================================