-
Notifications
You must be signed in to change notification settings - Fork 2
/
bfee.tcl
2184 lines (1828 loc) · 64.3 KB
/
bfee.tcl
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
##
## Binding Free Energy Estimator v1.1
##
## A plugin for automatical binding free energy calculation
##
## Email: fhh2626_at_gmail.com
## Date 2020.7.16
##
## cite: Haohao Fu, et al. JCIM, 2018, 58, 556
##
## Changelog:
## 2018.11.8 v0.5 beta:
## H-mass repartitioning supported and numstep reduced
## added water box based on the protein-ligand distance vector
## reduced frequency of writing colvars outputs
## now default pressure is 1.01325 bar
## 2018.11.12 v0.51 beta:
## more strict check for polar_theta and polar_phi to guarantee the rotational invariance
## by default, WTM-eABF instead classical eABF is used to accelerate sampling
## 2018.11.13 v0.52 beta:
## minor big fixes
## 2018.11.20 v0.53 beta:
## removed H-mass repartitioning, which is not stable in free-energy calculation
## by default, colvarsRestartFrequency=outputFreq
## reduced stepsPerCycle for stability
## 2020.6.12 v0.6 beta:
## adapted the latest version of Colvars
## uses stochastic velocity rescaling instead of Langevin barostat to improve efficiency
## 2020.6.15 v1.0:
## alchemical free-energy calculation now supported
## 2020.6.16 v1.01:
## minor bug fixes
## 2020.6.18 v1.02:
## switched to bidirectional FEP by default
## 2020.7.16 v1.1:
## now users can set reference and protein seperately
## making tuning the pulling direction easily
##
package provide BFEEstimator 1.1
namespace eval BFEE {
variable version "v1.1"
variable w ;# handle to main window
# below is for integration
# record the pmf
variable x []
variable G []
variable width 0
variable BOLTZMANN 0.0019872041
# for H-mass repartitioning
# hydrogen mass
variable HMass 1.0080
# distance threhold for covalent bonding
variable dThrehold 1.8
variable jobType
variable temperature
variable sel1
variable sel2
variable analyzermsd
variable analyzeeulerTheta
variable analyzeeulerPhi
variable analyzeeulerPsi
variable analyzepolarTheta
variable analyzepolarPhi
variable analyzeTemperature
variable r_star
variable psfDir
variable coorDir
variable velDir
variable xscDir
variable psfDirLig
variable coorDirLig
variable velDirLig
variable xscDirLig
variable paramDirList
variable rmsdDir
variable eulerThetaDir
variable eulerPhiDir
variable eulerPsiDir
variable polarThetaDir
variable polarPhiDir
variable rDir
variable unrmsdDir
# the GUI of BFEE plugin
proc ::BFEE::drawGUI {} {
variable w
variable jobType
variable temperature
variable sel1
variable sel2
variable sel3
variable analyzermsd
variable analyzeeulerTheta
variable analyzeeulerPhi
variable analyzeeulerPsi
variable analyzepolarTheta
variable analyzepolarPhi
variable analyzeTemperature
variable r_star
variable version
# If already initialized, just turn on
if { [winfo exists .textview] } {
wm deiconify $w
return
}
set w [toplevel ".bfee"]
wm title $w "Binding Free Energy Calculation"
wm resizable $w 0 0
ttk::label $w.discription -text " Binding Free Energy Calculation" -borderwidth 5 -relief sunken -padding "5 5"
ttk::radiobutton $w.jobType1 -text "Protein:Ligand" -variable ::BFEE::jobType -value proLig -width 20
ttk::radiobutton $w.jobType2 -text "Protein:Protein" -variable ::BFEE::jobType -value proPro -state disabled
set jobType proLig
ttk::notebook $w.setupTab
ttk::frame $w.setupTab.setup
ttk::frame $w.setupTab.analyze
# in setup notebook
ttk::labelframe $w.setupTab.setup.input -text "Input for Complex"
ttk::label $w.setupTab.setup.input.psfFile -text "psf file:"
ttk::entry $w.setupTab.setup.input.psfEntry -textvariable ::BFEE::psfDir -width 21
ttk::button $w.setupTab.setup.input.psfButton -text "Browse" -command ::BFEE::findPsfDir -width 9
ttk::label $w.setupTab.setup.input.coorFile -text "coor file:"
ttk::entry $w.setupTab.setup.input.coorEntry -textvariable ::BFEE::coorDir -width 21
ttk::button $w.setupTab.setup.input.coorButton -text "Browse" -command ::BFEE::findCoorDir -width 9
ttk::label $w.setupTab.setup.input.velFile -text "vel file:"
ttk::entry $w.setupTab.setup.input.velEntry -textvariable ::BFEE::velDir -width 21
ttk::button $w.setupTab.setup.input.velButton -text "Browse" -command ::BFEE::findVelDir -width 9
ttk::label $w.setupTab.setup.input.xscFile -text "xsc file:"
ttk::entry $w.setupTab.setup.input.xscEntry -textvariable ::BFEE::xscDir -width 21
ttk::button $w.setupTab.setup.input.xscButton -text "Browse" -command ::BFEE::findXscDir -width 9
#ttk::labelframe $w.setupTab.setup.inputLig -text "Input for Ligand"
#ttk::label $w.setupTab.setup.inputLig.psfFile -text "psf file:"
#ttk::entry $w.setupTab.setup.inputLig.psfEntry -textvariable ::BFEE::psfDirLig -width 21
#ttk::button $w.setupTab.setup.inputLig.psfButton -text "Browse" -command ::BFEE::findPsfDirLig -width 9
#ttk::label $w.setupTab.setup.inputLig.coorFile -text "coor file:"
#ttk::entry $w.setupTab.setup.inputLig.coorEntry -textvariable ::BFEE::coorDirLig -width 21
#ttk::button $w.setupTab.setup.inputLig.coorButton -text "Browse" -command ::BFEE::findCoorDirLig -width 9
#ttk::label $w.setupTab.setup.inputLig.velFile -text "vel file:"
#ttk::entry $w.setupTab.setup.inputLig.velEntry -textvariable ::BFEE::velDirLig -width 21
#ttk::button $w.setupTab.setup.inputLig.velButton -text "Browse" -command ::BFEE::findVelDirLig -width 9
#ttk::label $w.setupTab.setup.inputLig.xscFile -text "xsc file:"
#ttk::entry $w.setupTab.setup.inputLig.xscEntry -textvariable ::BFEE::xscDirLig -width 21
#ttk::button $w.setupTab.setup.inputLig.xscButton -text "Browse" -command ::BFEE::findXscDirLig -width 9
ttk::labelframe $w.setupTab.setup.otherPar -text "Other parameters"
ttk::label $w.setupTab.setup.otherPar.temp -text "Temperature:"
ttk::entry $w.setupTab.setup.otherPar.tempEntry -textvariable ::BFEE::temperature
set temperature 300
ttk::label $w.setupTab.setup.otherPar.param -text "Parameter files:"
listbox $w.setupTab.setup.otherPar.paramDir -listvariable ::BFEE::paramDirList -height 4 -width 21
ttk::scrollbar $w.setupTab.setup.otherPar.scroll -command "$w.setupTab.setup.otherPar.paramDir xview" -orient horizontal
$w.setupTab.setup.otherPar.paramDir configure -xscrollcommand "$w.setupTab.setup.otherPar.scroll set"
ttk::button $w.setupTab.setup.otherPar.add -text "Add" -command ::BFEE::addParamDir -width 6
ttk::button $w.setupTab.setup.otherPar.clear -text "Clear" -command ::BFEE::clearParamDir -width 6
# reference is used to calculate Eular and spherical angles
# and determine the distance and direction of pulling simulation
ttk::label $w.setupTab.setup.otherPar.sel1 -text "Select reference:"
ttk::entry $w.setupTab.setup.otherPar.sel1Entry -textvariable ::BFEE::sel1
set sel1 "segname SH3D"
# ligand should be the whole drug molecule
ttk::label $w.setupTab.setup.otherPar.sel2 -text "Select ligand:"
ttk::entry $w.setupTab.setup.otherPar.sel2Entry -textvariable ::BFEE::sel2
set sel2 "segname PPRO"
# protein should be the whole host molecule, used in step 8
# (the protein will be removed)
ttk::label $w.setupTab.setup.otherPar.sel3 -text "Select protein:"
ttk::entry $w.setupTab.setup.otherPar.sel3Entry -textvariable ::BFEE::sel3
set sel3 "segname SH3D"
ttk::button $w.setupTab.setup.generate -text "Generate Inputs" -command ::BFEE::generateFiles
ttk::labelframe $w.setupTab.setup.contactus -text "Readme"
ttk::label $w.setupTab.setup.contactus.readme -text \
"step 1: Set up corresponding options and click
<Generate Inputs>
step 2: Run simulations. Change <numstep> in
NAMD config file, <centers> of harmonic
restraints and <lower-> and <upperboundary>
of each collective variable if needed
step 3: Calculate binding free energies using
<Analyze> tab"
#ttk::button $w.setupTab.setup.contactus.generate -text "About BFEEstimator" -command ::BFEE::aboutus
#ttk::label $w.setupTab.setup.contactus.chipot -text "Chris Chipot: [email protected]"
#ttk::label $w.setupTab.setup.contactus.haohao -text "Haohao Fu: [email protected]"
# in analyze notebook
ttk::labelframe $w.setupTab.analyze.input -text "Input for PMFs (*.czar.pmf)"
ttk::label $w.setupTab.analyze.input.boundstate -text "Bound state:"
ttk::label $w.setupTab.analyze.input.rmsdFile -text "RMSD:" -anchor center
ttk::entry $w.setupTab.analyze.input.rmsdEntry -textvariable ::BFEE::rmsdDir -width 23
ttk::button $w.setupTab.analyze.input.rmsdButton -text "Browse" -command ::BFEE::findrmsdDir -width 9
ttk::label $w.setupTab.analyze.input.eulerThetaFile -text "Theta:" -anchor center
ttk::entry $w.setupTab.analyze.input.eulerThetaEntry -textvariable ::BFEE::eulerThetaDir -width 23
ttk::button $w.setupTab.analyze.input.eulerThetaButton -text "Browse" -command ::BFEE::findeulerThetaDir -width 9
ttk::label $w.setupTab.analyze.input.eulerPhiFile -text "Phi:" -anchor center
ttk::entry $w.setupTab.analyze.input.eulerPhiEntry -textvariable ::BFEE::eulerPhiDir -width 23
ttk::button $w.setupTab.analyze.input.eulerPhiButton -text "Browse" -command ::BFEE::findeulerPhiDir -width 9
ttk::label $w.setupTab.analyze.input.eulerPsiFile -text "Psi:" -anchor center
ttk::entry $w.setupTab.analyze.input.eulerPsiEntry -textvariable ::BFEE::eulerPsiDir -width 23
ttk::button $w.setupTab.analyze.input.eulerPsiButton -text "Browse" -command ::BFEE::findeulerPsiDir -width 9
ttk::label $w.setupTab.analyze.input.polarThetaFile -text "theta:" -anchor center
ttk::entry $w.setupTab.analyze.input.polarThetaEntry -textvariable ::BFEE::polarThetaDir -width 23
ttk::button $w.setupTab.analyze.input.polarThetaButton -text "Browse" -command ::BFEE::findpolarThetaDir -width 9
ttk::label $w.setupTab.analyze.input.polarPhiFile -text "phi:" -anchor center
ttk::entry $w.setupTab.analyze.input.polarPhiEntry -textvariable ::BFEE::polarPhiDir -width 23
ttk::button $w.setupTab.analyze.input.polarPhiButton -text "Browse" -command ::BFEE::findpolarPhiDir -width 9
ttk::label $w.setupTab.analyze.input.rFile -text "R:" -anchor center
ttk::entry $w.setupTab.analyze.input.rEntry -textvariable ::BFEE::rDir -width 23
ttk::button $w.setupTab.analyze.input.rButton -text "Browse" -command ::BFEE::findrDir -width 9
ttk::label $w.setupTab.analyze.input.unboundstate -text "Unbound state:"
ttk::label $w.setupTab.analyze.input.unrmsdFile -text "RMSD:" -anchor center
ttk::entry $w.setupTab.analyze.input.unrmsdEntry -textvariable ::BFEE::unrmsdDir -width 23
ttk::button $w.setupTab.analyze.input.unrmsdButton -text "Browse" -command ::BFEE::findunrmsdDir -width 9
ttk::labelframe $w.setupTab.analyze.forceConst -text "Force Constants (in NAMD units)"
ttk::label $w.setupTab.analyze.forceConst.bound -text "Bound state:"
ttk::label $w.setupTab.analyze.forceConst.rmsd -text "RMSD:" -width 6 -anchor w
ttk::entry $w.setupTab.analyze.forceConst.rmsdEntry -textvariable ::BFEE::analyzermsd -width 6
set analyzermsd 10
ttk::label $w.setupTab.analyze.forceConst.eulerTheta -text "Theta:" -width 6 -anchor center
ttk::entry $w.setupTab.analyze.forceConst.eulerThetaEntry -textvariable ::BFEE::analyzeeulerTheta -width 6
set analyzeeulerTheta 0.1
ttk::label $w.setupTab.analyze.forceConst.eulerPhi -text "Phi:" -width 6 -anchor center
ttk::entry $w.setupTab.analyze.forceConst.eulerPhiEntry -textvariable ::BFEE::analyzeeulerPhi -width 6
set analyzeeulerPhi 0.1
ttk::label $w.setupTab.analyze.forceConst.eulerPsi -text "Psi:" -width 6 -anchor w
ttk::entry $w.setupTab.analyze.forceConst.eulerPsiEntry -textvariable ::BFEE::analyzeeulerPsi -width 6
set analyzeeulerPsi 0.1
ttk::label $w.setupTab.analyze.forceConst.polarTheta -text "theta:" -width 6 -anchor center
ttk::entry $w.setupTab.analyze.forceConst.polarThetaEntry -textvariable ::BFEE::analyzepolarTheta -width 6
set analyzepolarTheta 0.1
ttk::label $w.setupTab.analyze.forceConst.polarPhi -text "phi:" -width 6 -anchor center
ttk::entry $w.setupTab.analyze.forceConst.polarPhiEntry -textvariable ::BFEE::analyzepolarPhi -width 6
set analyzepolarPhi 0.1
#ttk::label $w.setupTab.analyze.forceConst.unbound -text "Unbound state:"
#ttk::label $w.setupTab.analyze.forceConst.unrmsd -text "RMSD:" -width 6 -anchor center
#ttk::entry $w.setupTab.analyze.forceConst.unrmsdEntry -textvariable analyzeunrmsd -width 7
ttk::labelframe $w.setupTab.analyze.otherPar -text "Other parameter"
ttk::label $w.setupTab.analyze.otherPar.temp -text "Temperature: "
ttk::entry $w.setupTab.analyze.otherPar.tempEntry -textvariable ::BFEE::analyzeTemperature -width 10
set analyzeTemperature 300
ttk::label $w.setupTab.analyze.otherPar.rs -text "r*: " -width 6 -anchor e
ttk::entry $w.setupTab.analyze.otherPar.rsEntry -textvariable ::BFEE::r_star -width 10
set r_star 30
ttk::button $w.setupTab.analyze.compute -text "Compute Binding Free Energy" -command ::BFEE::computeFreeEnergy
# drawing GUI
grid $w.discription -columnspan 2 -sticky we
grid $w.jobType1 $w.jobType2 -sticky we
grid $w.setupTab -columnspan 2
$w.setupTab add $w.setupTab.setup -text "Setup"
$w.setupTab add $w.setupTab.analyze -text "Analyze"
grid $w.setupTab.setup.input -sticky nswe
grid $w.setupTab.setup.input.psfFile $w.setupTab.setup.input.psfEntry $w.setupTab.setup.input.psfButton -sticky w -padx 0.5m
grid $w.setupTab.setup.input.coorFile $w.setupTab.setup.input.coorEntry $w.setupTab.setup.input.coorButton -sticky w -padx 0.5m
grid $w.setupTab.setup.input.velFile $w.setupTab.setup.input.velEntry $w.setupTab.setup.input.velButton -sticky w -padx 0.5m
grid $w.setupTab.setup.input.xscFile $w.setupTab.setup.input.xscEntry $w.setupTab.setup.input.xscButton -sticky w -padx 0.5m
#grid $w.setupTab.setup.inputLig -sticky nswe
#grid $w.setupTab.setup.inputLig.psfFile $w.setupTab.setup.inputLig.psfEntry $w.setupTab.setup.inputLig.psfButton -sticky w -padx 0.5m
#grid $w.setupTab.setup.inputLig.coorFile $w.setupTab.setup.inputLig.coorEntry $w.setupTab.setup.inputLig.coorButton -sticky w -padx 0.5m
#grid $w.setupTab.setup.inputLig.velFile $w.setupTab.setup.inputLig.velEntry $w.setupTab.setup.inputLig.velButton -sticky w -padx 0.5m
#grid $w.setupTab.setup.inputLig.xscFile $w.setupTab.setup.inputLig.xscEntry $w.setupTab.setup.inputLig.xscButton -sticky w -padx 0.5m
grid $w.setupTab.setup.otherPar -sticky nswe
grid $w.setupTab.setup.otherPar.temp $w.setupTab.setup.otherPar.tempEntry -columnspan 1 -sticky w
grid $w.setupTab.setup.otherPar.param -column 0 -rowspan 3
grid $w.setupTab.setup.otherPar.paramDir -column 1 -row 1 -rowspan 2
grid $w.setupTab.setup.otherPar.scroll -column 1 -row 3 -sticky nswe
grid $w.setupTab.setup.otherPar.add -row 1 -column 2
grid $w.setupTab.setup.otherPar.clear -row 2 -column 2
grid $w.setupTab.setup.otherPar.sel1 $w.setupTab.setup.otherPar.sel1Entry -sticky w
grid $w.setupTab.setup.otherPar.sel2 $w.setupTab.setup.otherPar.sel2Entry -sticky w
grid $w.setupTab.setup.otherPar.sel3 $w.setupTab.setup.otherPar.sel3Entry -sticky w
grid $w.setupTab.setup.generate -columnspan 2 -sticky nswe
grid $w.setupTab.setup.contactus -sticky e
grid $w.setupTab.setup.contactus.readme
#grid $w.setupTab.setup.contactus.generate -columnspan 2 -sticky nswe
#grid $w.setupTab.setup.contactus.chipot -sticky w
#grid $w.setupTab.setup.contactus.haohao -sticky w
grid $w.setupTab.analyze.input -sticky nswe
grid $w.setupTab.analyze.input.boundstate -columnspan 2 -sticky w
grid $w.setupTab.analyze.input.rmsdFile $w.setupTab.analyze.input.rmsdEntry $w.setupTab.analyze.input.rmsdButton -sticky w -padx 0.5m
grid $w.setupTab.analyze.input.eulerThetaFile $w.setupTab.analyze.input.eulerThetaEntry $w.setupTab.analyze.input.eulerThetaButton -sticky w -padx 0.5m
grid $w.setupTab.analyze.input.eulerPhiFile $w.setupTab.analyze.input.eulerPhiEntry $w.setupTab.analyze.input.eulerPhiButton -sticky w -padx 0.5m
grid $w.setupTab.analyze.input.eulerPsiFile $w.setupTab.analyze.input.eulerPsiEntry $w.setupTab.analyze.input.eulerPsiButton -sticky w -padx 0.5m
grid $w.setupTab.analyze.input.polarThetaFile $w.setupTab.analyze.input.polarThetaEntry $w.setupTab.analyze.input.polarThetaButton -sticky w -padx 0.5m
grid $w.setupTab.analyze.input.polarPhiFile $w.setupTab.analyze.input.polarPhiEntry $w.setupTab.analyze.input.polarPhiButton -sticky w -padx 0.5m
grid $w.setupTab.analyze.input.rFile $w.setupTab.analyze.input.rEntry $w.setupTab.analyze.input.rButton -sticky w -padx 0.5m
grid $w.setupTab.analyze.input.unboundstate -columnspan 2 -sticky w
grid $w.setupTab.analyze.input.unrmsdFile $w.setupTab.analyze.input.unrmsdEntry $w.setupTab.analyze.input.unrmsdButton -sticky w -padx 0.5m
grid $w.setupTab.analyze.forceConst -sticky nswe
grid $w.setupTab.analyze.forceConst.bound -columnspan 2 -sticky w
grid $w.setupTab.analyze.forceConst.rmsd $w.setupTab.analyze.forceConst.rmsdEntry $w.setupTab.analyze.forceConst.eulerTheta $w.setupTab.analyze.forceConst.eulerThetaEntry $w.setupTab.analyze.forceConst.eulerPhi $w.setupTab.analyze.forceConst.eulerPhiEntry -sticky w
grid $w.setupTab.analyze.forceConst.eulerPsi $w.setupTab.analyze.forceConst.eulerPsiEntry $w.setupTab.analyze.forceConst.polarTheta $w.setupTab.analyze.forceConst.polarThetaEntry $w.setupTab.analyze.forceConst.polarPhi $w.setupTab.analyze.forceConst.polarPhiEntry -sticky w
#grid $w.setupTab.analyze.forceConst.unbound -columnspan 2 -sticky w
#grid $w.setupTab.analyze.forceConst.unrmsd $w.setupTab.analyze.forceConst.unrmsdEntry
grid $w.setupTab.analyze.otherPar -sticky we
grid $w.setupTab.analyze.otherPar.temp $w.setupTab.analyze.otherPar.tempEntry $w.setupTab.analyze.otherPar.rs $w.setupTab.analyze.otherPar.rsEntry -pady 1m
grid $w.setupTab.analyze.compute -sticky we
}
# the function of Browse button
proc ::BFEE::findPsfDir {} {
set psfTypes {
{{Protein Structure Files} {.psf}}
{{All Files} *}
}
variable psfDir
set psfDir [tk_getOpenFile -filetypes $psfTypes]
}
proc ::BFEE::findCoorDir {} {
set coorTypes {
{{Coordinate Files} {.pdb .coor}}
{{All Files} *}
}
variable coorDir
set coorDir [tk_getOpenFile -filetypes $coorTypes]
}
proc ::BFEE::findVelDir {} {
set velTypes {
{{Velocity Files} {.vel}}
{{All Files} *}
}
variable velDir
set velDir [tk_getOpenFile -filetypes $velTypes]
}
proc ::BFEE::findXscDir {} {
set xscTypes {
{{eXtended System Configuration Files} {.xsc}}
{{All Files} *}
}
variable xscDir
set xscDir [tk_getOpenFile -filetypes $xscTypes]
}
proc ::BFEE::findPsfDirLig {} {
variable psfDirLig
set psfDirLig [tk_getOpenFile]
}
proc ::BFEE::findCoorDirLig {} {
variable coorDirLig
set coorDirLig [tk_getOpenFile]
}
proc ::BFEE::findVelDirLig {} {
variable velDirLig
set velDirLig [tk_getOpenFile]
}
proc ::BFEE::findXscDirLig {} {
variable xscDirLig
set xscDirLig [tk_getOpenFile]
}
# functions for add and clear button
proc ::BFEE::addParamDir {} {
set paramTypes {
{{Force Field Parameters Files} {.inp .prm}}
{{All Files} *}
}
variable paramDirList
set dir [tk_getOpenFile -multiple 1 -filetypes $paramTypes]
if {$dir != ""} {
lappend paramDirList {*}$dir
}
}
proc ::BFEE::clearParamDir {} {
variable paramDirList
set paramDirList []
}
# functions for browse button in analyze notebook
set pmfTypes {
{{Potential of Mean Force} {.pmf}}
{{All Files} *}
}
proc ::BFEE::findrmsdDir {} {
variable rmsdDir
set rmsdDir [tk_getOpenFile -filetypes $::BFEE::pmfTypes]
}
proc ::BFEE::findeulerThetaDir {} {
variable eulerThetaDir
set eulerThetaDir [tk_getOpenFile -filetypes $::BFEE::pmfTypes]
}
proc ::BFEE::findeulerPhiDir {} {
variable eulerPhiDir
set eulerPhiDir [tk_getOpenFile -filetypes $::BFEE::pmfTypes]
}
proc ::BFEE::findeulerPsiDir {} {
variable eulerPsiDir
set eulerPsiDir [tk_getOpenFile -filetypes $::BFEE::pmfTypes]
}
proc ::BFEE::findpolarThetaDir {} {
variable polarThetaDir
set polarThetaDir [tk_getOpenFile -filetypes $::BFEE::pmfTypes]
}
proc ::BFEE::findpolarPhiDir {} {
variable polarPhiDir
set polarPhiDir [tk_getOpenFile -filetypes $::BFEE::pmfTypes]
}
proc ::BFEE::findrDir {} {
variable rDir
set rDir [tk_getOpenFile -filetypes $::BFEE::pmfTypes]
}
proc ::BFEE::findunrmsdDir {} {
variable unrmsdDir
set unrmsdDir [tk_getOpenFile -filetypes $::BFEE::pmfTypes]
}
# about us
proc ::BFEE::aboutus {} {
variable version
tk_messageBox -type ok -icon info \
-message \
"Binding Free Energy Estimator $version
Simple User's Guide:
step 1: set corresponding options, generate files
step 2: run simulations, take care the steps of
each simulations, the <center> option of
the harmonic restraints and the <lowerbounday>
and the <upperboundary> of each colvar
step 3: remove the comments in each pmf file, then
calculate binding free energy using the
analyze tab"
}
# move the box so that the center of mass of protein is (0,0,0)
# do it before generating input files
# generate ./eq_normalized.coor and ./eq.normalized.xst in the current folder
proc ::BFEE::move_complex {psf_file coor_file vel_file xsc_file} {
variable sel1
variable sel2
mol addfile $psf_file
mol addfile $coor_file
set all [atomselect top all]
set protein [atomselect top "$sel1 and noh"]
$all moveby [vecsub {0 0 0} [measure center $protein]]
$all writenamdbin ./eq_normalized.coor
pbc readxst $xsc_file
set pbc_now [lindex [pbc get -now] 0]
pbc set $pbc_now -now
pbc writexst ./eq_normalized.xst
unset all
unset protein
mol delete top
}
# check the polar angle theta
# do it before generating input files, if theta < 30 or > 150, then we rotate it by 90 degrees
# to avoid the rotating invarience of theta
proc ::BFEE::check_polar_theta {psf_file coor_file vel_file xsc_file} {
variable sel1
variable sel2
mol addfile $psf_file
mol addfile $coor_file
set selection1 [atomselect top "$sel1 and noh"]
set selection2 [atomselect top "$sel2 and noh"]
# calculate the angle of native state
set c1 [measure center $selection1]
set c2 [measure center $selection2]
set c [vecsub $c2 $c1]
set c [vecnorm $c]
set angle [expr 180 / 3.1415926 * acos([lindex $c 2])]
if {$angle < 30} {
tk_messageBox -type ok -icon info -message \
"Warning: the direction vector between the protein and the ligand
is almost parallel to z-axis! Rotate automatically!"
# rotate the complex by 90 degrees along x axis
# coor file
set all [atomselect top all]
$all move [trans center [measure center $all] axis x 90 ]
$all writenamdbin $coor_file
unset all
mol delete top
# vel file
mol addfile $psf_file
mol addfile $vel_file type namdbin
set all [atomselect top all]
$all move [trans center [measure center $all] axis x 90 ]
$all writenamdbin $vel_file
unset all
#mol delete top
# xsc file
pbc readxst $xsc_file
set pbc_now [lindex [pbc get -now] 0]
# exchange y-z
set temp [lindex $pbc_now 2]
set pbc_now [lreplace $pbc_now 2 2 [lindex $pbc_now 1]]
set pbc_now [lreplace $pbc_now 1 1 $temp]
pbc set $pbc_now -now
pbc writexst $xsc_file
mol delete top
} elseif {$angle > 150} {
tk_messageBox -type ok -icon info -message \
"Warning: the direction vector between the protein and the ligand
is almost parallel to z-axis! Rotate automatically!"
# rotate the complex by -90 degrees along x axis
# coor file
set all [atomselect top all]
$all move [trans center [measure center $all] axis x -90 ]
$all writenamdbin $coor_file
unset all
mol delete top
# vel file
mol addfile $psf_file
mol addfile $vel_file type namdbin
set all [atomselect top all]
$all move [trans center [measure center $all] axis x -90 ]
$all writenamdbin $vel_file
unset all
#mol delete top
# xsc file
pbc readxst $xsc_file
set pbc_now [lindex [pbc get -now] 0]
# exchange y-z
set temp [lindex $pbc_now 2]
set pbc_now [lreplace $pbc_now 2 2 [lindex $pbc_now 1]]
set pbc_now [lreplace $pbc_now 1 1 $temp]
pbc set $pbc_now -now
pbc writexst $xsc_file
mol delete top
} else {
mol delete top
}
}
# check the polar angle phi
# do it before generating input files, is phi > 150 or if phi < -150, then we rotate it by 180 degrees
# to avoid the periodicity of phi
proc ::BFEE::check_polar_phi {psf_file coor_file vel_file xsc_file} {
variable sel1
variable sel2
mol addfile $psf_file
mol addfile $coor_file
set selection1 [atomselect top "$sel1 and noh"]
set selection2 [atomselect top "$sel2 and noh"]
# calculate the angle of native state
set c1 [measure center $selection1]
set c2 [measure center $selection2]
set c [vecsub $c2 $c1]
set c [vecnorm $c]
set angle [expr 180 / 3.1415926 * atan2([lindex $c 1], [lindex $c 0])]
if {$angle > 150 || $angle < -150} {
tk_messageBox -type ok -icon info -message \
"Warning: the direction vector between the protein and the ligand
is close to 180 degrees! Rotate automatically!"
# rotate the complex by 180 degrees along z axis
# coor file
set all [atomselect top all]
$all move [trans center [measure center $all] axis z 180 ]
$all writenamdbin $coor_file
unset all
mol delete top
# vel file
mol addfile $psf_file
mol addfile $vel_file type namdbin
set all [atomselect top all]
$all move [trans center [measure center $all] axis z 180 ]
$all writenamdbin $vel_file
unset all
#mol delete top
# xsc file
#pbc readxst $xsc_file
#set pbc_now [lindex [pbc get -now] 0]
# exchange y-z
#set temp [lindex $pbc_now 2]
#set pbc_now [lreplace $pbc_now 2 2 [lindex $pbc_now 1]]
#set pbc_now [lreplace $pbc_now 1 1 $temp]
#pbc set $pbc_now -now
#pbc writexst $xsc_file
mol delete top
} else {
mol delete top
}
}
# output the definition of collective variables
proc ::BFEE::colvar_RMSD {set_boundary output_file {rmsdFile ./ligand.pdb}} {
puts $output_file "
colvar {
name RMSD\n"
if {$set_boundary == 1} {
puts $output_file "
width 0.05
lowerboundary 0
upperboundary 3
subtractAppliedForce on
expandboundaries on
extendedLagrangian on
extendedFluctuation 0.05\n"
}
puts $output_file "
rmsd {
atoms {
atomsFile $rmsdFile
atomsCol B
atomsColValue 1.0
}
refpositionsfile $rmsdFile
}
}\n"
}
proc ::BFEE::colvar_euler_angle {set_boundary output_file euler_angle} {
puts $output_file "
colvar {
name $euler_angle
scriptedFunction $euler_angle \n"
if {$set_boundary == 1} {
puts $output_file "
width 1
lowerboundary -10
upperboundary 10
subtractAppliedForce on
expandboundaries on
extendedLagrangian on
extendedFluctuation 1\n"
}
puts $output_file "
Orientation {
atoms {
atomsFile ./ligand.pdb
atomsCol B
atomsColValue 1.0
centerReference on
rotateReference on
enableFitGradients no
fittingGroup {
atomsFile ./protein.pdb
atomsCol B
atomsColValue 1.0
}
refPositionsFile ./protein.pdb
}
refPositionsFile ./ligand.pdb
}
}\n"
}
# calculate the value of polar angles
# will be used in polar angle CVs
proc ::BFEE::polar_angle_value {polar_angle psf_file coor_file} {
variable sel1
variable sel2
mol addfile $psf_file
mol addfile $coor_file
set selection1 [atomselect top "$sel1 and noh"]
set selection2 [atomselect top "$sel2 and noh"]
# calculate the angle of native state
set c1 [measure center $selection1]
set c2 [measure center $selection2]
set c [vecsub $c2 $c1]
set c [vecnorm $c]
if {$polar_angle == "polarTheta"} {
set angle_center [expr 180 / 3.1415926 * acos([lindex $c 2])]
} elseif {$polar_angle == "polarPhi"} {
set angle_center [expr 180 / 3.1415926 * atan2([lindex $c 1], [lindex $c 0])]
}
mol delete top
return [expr floor($angle_center)]
}
proc ::BFEE::colvar_polar_angle {set_boundary output_file polar_angle value} {
puts $output_file "
colvar {
name $polar_angle\n"
if {$set_boundary == 1} {
puts $output_file "
width 1
lowerboundary [expr $value - 10]
upperboundary [expr $value + 10]
subtractAppliedForce on
expandboundaries on
extendedLagrangian on
extendedFluctuation 1\n"
}
puts $output_file "
$polar_angle {
atoms {
atomsFile ./ligand.pdb
atomsCol B
atomsColValue 1.0
centerReference on
rotateReference on
fittingGroup {
atomsFile ./protein.pdb
atomsCol B
atomsColValue 1.0
}
refPositionsFile ./protein.pdb
}
}
}\n"
}
# calculate the value of r*
# will be used in the distance CV
proc ::BFEE::r_value {psf_file coor_file} {
variable sel1
variable sel2
mol addfile $psf_file
mol addfile $coor_file
set selection1 [atomselect top "$sel1 and noh"]
set selection2 [atomselect top "$sel2 and noh"]
# calculate r of native state
set c1 [measure center $selection1]
set c2 [measure center $selection2]
set distance [vecdist $c1 $c2]
return $distance
}
proc ::BFEE::colvar_r {set_boundary output_file distance} {
set upper_distance [expr floor($distance + 21)]
set lower_distance [expr floor($distance - 2)]
if {$lower_distance < 0} {
set lower_distance 0.2
}
puts $output_file "
colvar {
name r\n"
if {$set_boundary == 1} {
puts $output_file "
width 0.1
lowerboundary $lower_distance
upperboundary $upper_distance
subtractAppliedForce on
expandboundaries on
extendedLagrangian on
extendedFluctuation 0.1\n"
}
puts $output_file "
distance {
forceNoPBC yes
group1 {
atomsFile ./protein.pdb
atomsCol B
atomsColValue 1.0
}
group2 {
atomsFile ./ligand.pdb
atomsCol B
atomsColValue 1.0
}
}
}\n"
}
# output the head of colvars config file
proc ::BFEE::colvar_head {output_file} {
puts $output_file "colvarsTrajFrequency 500
colvarsRestartFrequency 50000
"
}
# output the bias
proc ::BFEE::bias_walls {output_file colvar lowerwall upperwall} {
puts $output_file "
harmonicWalls {
colvars $colvar
lowerWalls $lowerwall
upperWalls $upperwall
lowerWallConstant 0.2
upperWallConstant 0.2
}\n"
}
# ti = 0 for plain harmonic restrants, 1 for forward Ti calculation, 2 for backward Ti calculation
proc ::BFEE::bias_harmonic {output_file colvar constant center {ti 0}} {
puts $output_file "
harmonic {
colvars $colvar
forceConstant $constant
centers $center\n"
if {$ti != 0} {
puts $output_file "targetNumSteps 2000000
targetEquilSteps 100000
targetForceConstant 0
targetForceExponent 4\n"
}
if {$ti == 1} {
puts $output_file "lambdaSchedule 1 0.99999 0.9999 0.999 0.99 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0\n"
}
if {$ti == 2} {
puts $output_file "lambdaSchedule 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.99 0.999 0.9999 0.99999 1\n"
}
puts $output_file "}\n"
}
proc ::BFEE::bias_abf {output_file colvar} {
puts $output_file "
abf {
colvars $colvar
FullSamples 10000
historyfreq 50000
writeCZARwindowFile
}
metadynamics {
colvars $colvar
hillWidth 3.0
hillWeight 0.05
wellTempered on
biasTemperature 4000
}\n"
}
# output the colvar that restrains the protein
proc ::BFEE::colvar_protein {output_file psf_file coor_file ref_protein} {
variable sel1
mol addfile $psf_file
mol addfile $coor_file
set selection1 [atomselect top "$sel1 and noh"]
puts $output_file "
colvar {
name translation
distance {
group1 {
atomsFile ./protein.pdb
atomsCol B
atomsColValue 1.0
}
group2 {
dummyAtom ([lindex [measure center $selection1] 0], [lindex [measure center $selection1] 1], [lindex [measure center $selection1] 2])
}
}
}
harmonic {
colvars translation
centers 0.0
forceConstant 10.0
}
colvar {
name orientation
orientation {
atoms {
atomsFile ./protein.pdb
atomsCol B
atomsColValue 1.0
}
refPositionsFile $ref_protein
}
}
harmonic {
colvars orientation
centers (1.0, 0.0, 0.0, 0.0)
forceConstant 200.0
} \n"
mol delete top
}
# write reference files for colvars
proc ::BFEE::write_ref {psf_file coor_file} {
variable sel1
variable sel2
mol addfile $psf_file
mol addfile $coor_file
set all [atomselect top all]
set selection1 [atomselect top "$sel1 and noh"]
set selection2 [atomselect top "$sel2 and noh"]
$all set beta 0
$selection1 set beta 1
$all writepdb protein.pdb
$all set beta 0
$selection2 set beta 1
$all writepdb ligand.pdb
$all delete
mol delete top
}
# add water box based on psf and coor (for step 7)
proc ::BFEE::add_watbox {psf_file coor_file} {
variable sel1
variable sel2
mol addfile $psf_file
mol addfile $coor_file
set selection1 [atomselect top "$sel1 and noh"]
set selection2 [atomselect top "$sel2 and noh"]
set direction [vecsub [measure center $selection2] [measure center $selection1]]
# get the direction of protein-ligand distance vector
# for extending water box
if {[lindex $direction 0] > 0} {
set xm 0
set xp 22
} else {
set xp 0
set xm 22
}
if {[lindex $direction 1] > 0} {
set ym 0
set yp 22
} else {
set yp 0
set ym 22
}
if {[lindex $direction 2] > 0} {
set zm 0
set zp 22
} else {
set zp 0
set zm 22
}
set all [atomselect top all]
$all writepdb $coor_file.pdb
mol delete top
#solvate $psf_file $coor_file.pdb -t 15 -o solvated -s W2 -b 2.2
solvate $psf_file $coor_file.pdb -x $xm -y $ym -z $zm +x $xp +y $yp +z $zp -o solvated -s W2 -b 2.2
mol delete top
}
# remove protein based on psf and coor (for step 8)
proc ::BFEE::remove_protein {psf_file coor_file} {
variable sel3
variable sel2
mol addfile $psf_file
mol addfile $coor_file
set nopro [atomselect top "not $sel3"]
$nopro writepsf lig.psf
$nopro writepdb lig.pdb
$nopro delete
mol delete top
}
# output PBC information for namd config file (for step 7,8)
proc ::BFEE::write_cell {output_file temperature pdb_file} {