-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbendix.tcl
More file actions
6295 lines (5587 loc) · 307 KB
/
Copy pathbendix.tcl
File metadata and controls
6295 lines (5587 loc) · 307 KB
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
#===============================================================================
#
# bendix.tcl
#
# A protein characterization software for atomistic and coarse-grained proteins.
# Bendix abstracts secondary structure without sacrificing conformation,
# and allows quantification and visualisation of helix geometry.
# Bendix is a plugin for Visual Molecular Dynamics (VMD).
#
# For more information, please see the website:
# http://sbcb.bioch.ox.ac.uk/Bendix
#
#
# Authors: A Caroline E Dahl, Matthieu Chavent and Mark S P Sansom
# University of Oxford, February 2013
#
# Citation: Bendix: Intuitive helix geometry analysis and abstraction
# Anna Caroline E. Dahl; Matthieu Chavent; Mark S.P. Sansom
# Bioinformatics (2012) 28 (16): 2193-2194.
#
# Please send feature requests and bug reports to [email protected].
# Thank you.
#
#
# .........::::::: University of Illinois Open Source License :::::::.........
# Copyright 2012-2013 Structural Bioinformatics and Computational Biochemistry unit
# University of Oxford
# All rights reserved.
#
# Developed by: A Caroline E Dahl
# Structural Bioinformatics and Computational Biochemistry unit
# University of Oxford
# http://sbcb.bioch.ox.ac.uk
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the Software), to deal with
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to
# do so, subject to the following conditions:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimers.
#
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimers in the documentation
# and/or other materials provided with the distribution.
#
# - Neither the names of Structural Bioinformatics and Computational Biochemistry,
# University of Oxford, nor the names of its contributors may be used to endorse
# or promote products derived from this Software without specific prior written
# permission.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS WITH THE SOFTWARE.
#
#
#===============================================================================
#### Installation notes (see also http://sbcb.bioch.ox.ac.uk/Bendix/faq.html):
#
# 1. Identify the path to your installed VMD package,
# e.g. /Computer/Programs/VMD/
# 2. Decompress and save bendix1.1 and its content in a special VMD plugin subdirectory:
# /Computer/Programs/VMD/plugins/noarch/tcl/
# N.B. On Macs: right-click the VMD icon in Applications, choose "Show Package Contents"
# and navigate to Contents > vmd > plugins > noarch > tcl
# 3. Identify (or create) and open the the vmd user settings file: vmdrc
# You find it in (e.g.) /Computer/Programs/VMD/ or in your home directory
# (N.B. this is a hidden file in Linux and MAC distributions)
# 4. Append these lines to vmdrc:
# vmd_install_extension bendix bendix "Visualization/Bendix"
# menu main on
# 5. Restart VMD.
# Bendix appears under the VMD Main window tab
# Extensions > Visualization > Bendix
#
# .. alternatively load bendix from VMD's terminal or Tk Console using these commands:
# source /dir/where/you/saved/bendix1.1/bendix.tcl
# bendix
#
#### Code maintenance notes:
#
# English spelling is used throughout.
# Internal procs are initially indented by 2 spaces to save space.
# The code is divided up into the following sections:
# Create global variables
# Main GUI setup
# Procs:
# GUI-related
# Load and save files
# User help and acknowledgements
# Draw non-bendices
# Helix analysis
# Trajectory and molecule ID detection
# Particle and subset validation
# Error messages
# Hide, erase and reset
# Main bendix proc (long):
# Assign helicity, retrieve coordinates, calculate helix axis,
# apply spline, calculate angles, draw to screen.
#
#_______________________________________________________________________________
package provide bendix 1.1
package require tile
package require multiplot
################################################################################
# GLOBAL VARs #
################################################################################
global env
namespace eval ::bendix:: {
variable proteinID "0";
variable particle_name "CA";
variable previous_particle_name "CA";
variable subset "";
variable helix_radius "2.2";
variable angle_max "20.0";
variable angle_colour_scale "RGB";
variable uniform_colour 1 ;
variable uniform_colour_type 2;
variable input_colour "red";
variable curvature_graph_X "";
variable curvature_graph_Y "";
variable points_to_graph "";
variable spline_resolution "4";
variable TurnResolution 4;
variable previous_TurnResolution 4;
variable AngleSide 3.6;
variable frame 0;
variable previous_frame 0;
variable rep_zero 1;
variable autoColour 1;
variable autoCartoon 0;
variable autoNewCartoon 0;
variable normalised_startsandstops "";
variable list_of_chains "";
variable xyz "";
variable helix_assignment "";
variable helix_assignment_by_backbone "";
variable startIndex "";
variable endIndex "";
variable spline_coords "";
variable spline_startsandstops "";
variable residueIndex "";
variable backbone_radius "0.2";
variable helix_type 1;
variable CG 0;
variable AThelix_string "";
variable String_for_cartoonify "";
variable CGbackbone 0;
variable maximumAngle_per_frame "";
variable vmdFrame "";
variable helixNumber 0;
variable MartiniBackbone "";
variable MartiniHelix "";
variable MartiniSheet "";
variable MartiniBackboneNew "";
variable MartiniHelixNew "";
variable MartiniSheetNew "";
variable list_of_indices_where_Chains_start "";
variable previous_helix_type "";
variable CG_Backbone_indexNs "";
variable CG_Backbone_normalised_startsandstops "";
variable quick_and_dirty 0;
variable slow_and_pretty 0;
variable helix_coord_at_startNstop "";
variable helix_indices_at_startNstop "";
variable heres_a_helix "";
variable angle_per_turn_per_frame {}
variable angle_per_AA_per_frame_BARRED ""
variable helix_axis_per_helix_per_frame_BARRED ""
variable AngleAutoScale 1;
variable 3D_surf 0;
variable z_squeeze 3.0;
variable frame_squeeze 3.0;
variable subset_by_backbone "";
variable proteinID_by_backbone "";
variable die 1;
variable die_backbone 1;
variable frame_done_before 0;
variable first_surf_drawn "";
variable first_axis_drawn "";
variable last_axis_drawn "";
variable axesON 0;
variable surfed 0;
variable Resolution_wrt_ends
variable CG_old_sheet_rep_list ""
variable First_backbone_drawn_list ""
variable Last_backbone_drawn_list ""
variable CG_old_rep_list ""
variable old_rep_list ""
variable CG_cartoonified_list 0
variable cartoonified_list 0
variable packed 0
variable Sugeta_point 0
variable surf_repID "";
variable index_of_helix_assignment_used_for_angle "";
variable StoreData 0;
variable AAN_associated_w_splineIndex
variable realAAs_for_23D_graph_Xaxis
variable fixed_particleNames ""
variable custom_particle 0
#### Selection warning variables
variable tested_alt_particle_for_empty_select_AAs 0
variable tested_alt_particle_for_empty_start_and_end_AA_N_of_chains 0
variable tested_alt_particle_for_inexistent_start_and_end_AA_N_of_chains 0
variable tested_alt_particle_for_empty_residueNs 0
variable tested_alt_particle_for_empty_startIndex 0
variable autolooper 0
########## Speed-up variables
variable previous_proteinID "0";
variable previous_subset "";
variable previous_helix_assignment "";
variable previous_spline_resolution "4";
}
# ::bendix::bendix -------------------------------------------------------------
# Create the GUI and run relevant procs if called via GUI.
#
# Results:
# A robust GUI that allows the user to choose from available settings
# and execute them by drawing to the VMD Display.
# Examples of settings are helix assignment, treatment of non-bendices,
# colouring, 2D and 3D graphing and resolution.
# Analysis tools are reachable from the menubar.
#
# Details of procs that are internal to ::bendix::bendix are given
# when they appear, below.
#
# ------------------------------------------------------------------------------
proc ::bendix::bendix {} {
puts stdout " \nInfo) Bendix v1.1 by Caroline Dahl - software that lets your protein abstractions be naturally curvy.\
\nInfo) http://sbcb.bioch.ox.ac.uk/Bendix/ \
\nInfo) If Bendix contributes towards your publication, please cite:\
\nInfo) Dahl ACE, Chavent M and Sansom MSP (2012) \
\nInfo) Bendix: intuitive helix geometry analysis and abstraction. \
\nInfo) Bioinformatics 28 (16): 2193-2194\n"
variable selection
variable bix
global vmd_frame;
global vmd_initialize_structure
global env
global auto_path
global vmd_molecule
global vmd_quit
#### Detect available molecules and set proteinID to an existent molecule.
set N_loaded_molecules [molinfo num]
set ID_mols [molinfo list]
set ::bendix::proteinID [lindex $ID_mols 0]
#### Needs a molecule?
if {! [string compare $::bendix::proteinID top]} {
set ::bendix::proteinID [molinfo top]
}
#### vmd_frame and vmd_molecule are VMD-managed arrays. When this array changes, call relevant Bendix procs.
trace add variable vmd_molecule write {::bendix::set_molIDs;};
trace add variable vmd_frame write ::bendix::sscache
trace add variable vmd_quit write "::bendix::quit"
#### Note the initial protein position in the VMD Display, so that Erase (and Reset) can get back to it:
set N_loaded_Mols [molinfo num]
if {$N_loaded_Mols != 0} {
global original_protein_viewpoint
set original_protein_viewpoint [molinfo $::bendix::proteinID get {center_matrix rotate_matrix scale_matrix global_matrix}]
}
#### Make a list out of a ::bendix::variable. Load lists with fifty unset or zero-variables
#### bendix will update these lists as it runs, to keep track of what is drawn.
foreach list_counter {0 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} {
foreach list_name {::bendix::First_backbone_drawn_list ::bendix::Last_backbone_drawn_list ::bendix::CG_old_sheet_rep_list ::bendix::CG_old_rep_list ::bendix::old_rep_list} {
lappend $list_name ""
}
foreach cartoonified_list {::bendix::CG_cartoonified_list ::bendix::cartoonified_list} {
lappend $cartoonified_list "0"
}
}
################################################################################
# GUI SETUP #
################################################################################
if [winfo exists .bex] {
wm deiconify $bix
return
}
set bix [toplevel ".bex"]
wm title $bix "bendix"
wm attributes $bix -alpha 1.0;
wm geometry $bix +100+100
wm resizable $bix 0 0;
# Latter means non-resizable. Ensures that the 'forgotten' menu works
# and doesn't play up when the user (accidentally) resizes the window.
frame $bix.top
#### Menu
frame $bix.menubar -relief raised -bd 2
pack $bix.menubar -padx 1 -fill x -side top
menubutton $bix.menubar.openfiles -text "File" -underline 0 -menu $bix.menubar.openfiles.menu
$bix.menubar.openfiles config -width 5
pack $bix.menubar.openfiles -side left
menu $bix.menubar.openfiles.menu -tearoff no
$bix.menubar.openfiles.menu add command -label "Open helix assignment file..." -command ::bendix::openHelixFile
$bix.menubar.openfiles.menu add command -label "Open colouring file..." -command ::bendix::openColourFile
$bix.menubar.openfiles.menu add command -label "Save helix assignment..." -command ::bendix::saveHelixFile
$bix.menubar.openfiles.menu add command -label "Save colouring..." -command ::bendix::saveColourFile
$bix.menubar.openfiles.menu add command -label "Save surf data..." -command ::bendix::saveSurfData
$bix.menubar.openfiles.menu add command -label "Save axes data..." -command ::bendix::saveAxisData
$bix.menubar.openfiles.menu add command -label "Reset and Quit" -command ::bendix::quit
menubutton $bix.menubar.analysis -text "Analysis" -underline 0 -menu $bix.menubar.analysis.menu
$bix.menubar.analysis config -width 8
pack $bix.menubar.analysis -side left
menu $bix.menubar.analysis.menu -tearoff no
$bix.menubar.analysis.menu add command -label "Plot: Angle along helix" -command ::bendix::create_graph -state disabled
$bix.menubar.analysis.menu add command -label "Plot: Maximum angle per helix over time" -command ::bendix::create_MaxAngle_graph -state disabled
$bix.menubar.analysis.menu add command -label "Surf: Angle along helix over time..." -command ::bendix::popup_for_Surf -state disabled
$bix.menubar.analysis.menu add checkbutton -label "Store dynamic data" -variable ::bendix::StoreData -state disabled
$bix.menubar.analysis.menu add checkbutton -label "Store helix axes" -variable ::bendix::StoreAxes
menubutton $bix.menubar.howto -text "Help" -underline 0 -menu $bix.menubar.howto.menu
$bix.menubar.howto config -width 5
pack $bix.menubar.howto -side left
menu $bix.menubar.howto.menu -tearoff no
$bix.menubar.howto.menu add command -label "What is bendix?" -command ::bendix::shortbendix
$bix.menubar.howto.menu add command -label "Quick help!" -command ::bendix::quickBendix
$bix.menubar.howto.menu add command -label "Online Tutorial" -command "vmd_open_url {http://sbcb.bioch.ox.ac.uk/Bendix/tutorial.html}"
$bix.menubar.howto.menu add command -label "Online Troubleshooter" -command "vmd_open_url {http://sbcb.bioch.ox.ac.uk/Bendix/faqLess.html#QA}"
menubutton $bix.menubar.bendixInfo -text "About" -underline 0 -menu $bix.menubar.bendixInfo.menu
$bix.menubar.bendixInfo config -width 7
pack $bix.menubar.bendixInfo -side left
menu $bix.menubar.bendixInfo.menu -tearoff no
$bix.menubar.bendixInfo.menu add command -label "Who made bendix?" -command ::bendix::WhoMadebendix
#### Main GUI Body
labelframe $bix.lf1 -text "Protein selection" -pady 3 -padx 6 -font {-weight bold -family helvetica}
labelframe $bix.lf2 -text "Helix features" -pady 3 -padx 6 -font {-weight bold -family helvetica}
labelframe $bix.lf3 -text "How to draw non-Bendices" -pady 3 -padx 6 -font {-weight bold -family helvetica}
frame $bix.lf1.field1 -borderwidth 1
frame $bix.lf1.field2 -borderwidth 1
frame $bix.lf1.field3 -borderwidth 1
frame $bix.lf1.field4 -borderwidth 1
frame $bix.lf1.field5 -borderwidth 1
frame $bix.lf2.field1 -borderwidth 1
frame $bix.lf2.field4 -borderwidth 1
frame $bix.lf2.field5 -borderwidth 1
frame $bix.lf2.field6 -borderwidth 1
frame $bix.lf2.field7 -borderwidth 1
frame $bix.lf2.field8 -borderwidth 1
frame $bix.lf3.field1 -borderwidth 1
frame $bix.field1
frame $bix.field2
frame $bix.field3
frame $bix.field4
#### labelfield 1: 1-4
message $bix.lf1.field1.msg -width 100 -text "Mol ID:"
set N_loaded_molecules [molinfo num]
set ID_mols [molinfo list]
set N_mols ""
for {set molN 0} {$molN < $N_loaded_molecules} {incr molN } {
lappend N_mols [lindex $ID_mols $molN]
}
spinbox $bix.lf1.field1.molname -values $N_mols -state readonly -width 3
checkbutton $bix.lf1.field1.cg -justify right -text "CG" -variable ::bendix::CG \
-command ::bendix::MakeCG
message $bix.lf1.field1.spacer -text "" -width 10
message $bix.lf1.field1.name -text "Backbone particle(s):" -width 190
entry $bix.lf1.field1.particleName -textvariable ::bendix::particle_name -background white \
-selectbackground yellow2 -width 18
message $bix.lf1.field2.msg -justify left -width 100 -text "Subset:"
entry $bix.lf1.field2.molname -textvariable ::bendix::subset -background white \
-selectbackground yellow2 -width 50
message $bix.lf1.field3.msg -justify left -width 430 \
-text " For example 'resid 1 to 20 and (chain B or chain C) '. Default is the full protein." \
-font {helvetica 8}
message $bix.lf1.field4.msg -justify left -text "Helices:" -width 100
entry $bix.lf1.field4.helices -textvariable ::bendix::helix_assignment -background white \
-selectbackground yellow2 -width 42
button $bix.lf1.field4.clear -command {set ::bendix::helix_assignment ""; set ::bendix::String_for_cartoonify "" } \
-text "Clear" -font {helvetica 8} -background white
message $bix.lf1.field5.msg -justify left -text " Helix start and end resid numbers.\
If left blank, helicity is auto-assigned." -font {helvetica 8} -foreground black -width 430
#### labelfield 2: 1-7
radiobutton $bix.lf2.field1.straight -variable ::bendix::helix_type -value 0 -text "Straight helices" \
-command ::bendix::cylinders
radiobutton $bix.lf2.field1.bendix -variable ::bendix::helix_type -value 1 -text "Bendices: use every " \
-command ::bendix::bendices
set turns [list 1 2 3 4 5 6 7 8 9 10];
spinbox $bix.lf2.field1.cp -values $turns -state readonly -width 3
$bix.lf2.field1.cp set 4
message $bix.lf2.field1.spacer -text "residues" -width 50
radiobutton $bix.lf2.field5.colourbutton0 -variable ::bendix::uniform_colour -value 0 \
-text "Heatmap color:" -command ::bendix::Hello_curvature
message $bix.lf2.field5.msg2 -justify right -width 50 -text " Scale:" -foreground "gray60" -padx 1
ttk::combobox $bix.lf2.field5.listbox -width 6 -values [list RWB BWR RGryB BGryR RGB BGR RWG GWR GWB BWG BlkW WBlk] -state readonly
# NB. Requires the tile package.
message $bix.lf2.field5.msg -justify right -width 100 -text " Color threshold:" -foreground "gray60" -padx 1
entry $bix.lf2.field5.molname -textvariable ::bendix::angle_max -state disabled \
-background white -selectbackground yellow2 -width 4
message $bix.lf2.field5.msg3 -justify right -width 30 -text "Side:" -foreground "gray60"
entry $bix.lf2.field5.angleL -textvariable ::bendix::AngleSide -background white -selectbackground yellow2 \
-width 3 -state disabled
radiobutton $bix.lf2.field6.colourbutton1 -variable ::bendix::uniform_colour -value 1 \
-text "Uniform color:" \
-command ::bendix::Hello_uniform
message $bix.lf2.field6.spacer -text " "
radiobutton $bix.lf2.field6.uniformcolour0 -variable ::bendix::uniform_colour_type -value 0 -text "full selection"
radiobutton $bix.lf2.field6.uniformcolour1 -variable ::bendix::uniform_colour_type -value 1 -text "by chain"
radiobutton $bix.lf2.field6.uniformcolour2 -variable ::bendix::uniform_colour_type -value 2 -text "by helix"
message $bix.lf2.field7.msg -justify left -width 140 -text "Color(s):"
entry $bix.lf2.field7.molname -textvariable ::bendix::input_colour -state disabled \
-background white -selectbackground yellow2 -width 40
checkbutton $bix.lf2.field7.checkON -text "Auto" -variable ::bendix::autoColour -command ::bendix::autoON
message $bix.lf2.field8.msg -width 200 -text "Separate colors by space" -font {helvetica 8} \
-foreground "gray60"
message $bix.lf2.msg -text "Material:" -width 100
ttk::combobox $bix.lf2.listbox -width 15 -values [list Opaque Transparent BrushedMetal Diffuse Ghost Glass1 Glass2 Glass3 Glossy HardPlastic MetallicPastel Steel Translucent Edgy EdgyShiny EdgyGlass Goodsell AOShiny AOChalky AOEdgy BlownGlass GlassBubble] -state readonly
# NB. Requires the tile package.
message $bix.lf2.spacer -text ""
message $bix.lf2.msg2 -justify left -width 60 -text "Radius:"
entry $bix.lf2.molname -textvariable ::bendix::helix_radius -background white -selectbackground yellow2 \
-width 4
message $bix.lf2.msg3 -justify left -width 70 -text "Resolution:"
entry $bix.lf2.molname2 -textvariable ::bendix::spline_resolution -background white -selectbackground yellow2 \
-width 3
#### labelframe 3: Reps for else than Bendified
checkbutton $bix.lf3.field1.rep0 -text "Rep 0" -variable ::bendix::rep_zero -command ::bendix::hiderep_zero
message $bix.lf3.field1.spacer -text " "
checkbutton $bix.lf3.field1.cartoon -text "Cartoon" -variable ::bendix::autoCartoon \
-command ::bendix::cartoonify
checkbutton $bix.lf3.field1.newcartoon -text "NewCartoon" -variable ::bendix::autoNewCartoon \
-command ::bendix::cartoonify
checkbutton $bix.lf3.field1.tube -text "Tube" -variable ::bendix::autoTube -command ::bendix::cartoonify
message $bix.lf3.field1.spacer2 -text " "
checkbutton $bix.lf3.field1.quick -text "Draft" -variable ::bendix::quick_and_dirty \
-command ::bendix::drawBackbone
checkbutton $bix.lf3.field1.slow -text "Join" -variable ::bendix::slow_and_pretty \
-command ::bendix::drawBackbone
button $bix.field2.boutonaffiche0 -command {set ::bendix::autolooper 0; ::bendix::mainDrawingLoop} \
-text "Draw" -background green
button $bix.field2.boutonaffiche1 -command ::bendix::erase -text "Erase" -background tomato -width 5
button $bix.field2.settings -command {
bind .bex <Unmap> { }
if {$::bendix::packed == 0} {
pack forget .bex.lf2
pack forget .bex.lf2.field5
pack forget .bex.lf2.field6
pack forget .bex.lf3
pack .bex.lf1 -side top -padx 4 -anchor w -expand true -fill x -pady 4
pack .bex.lf2.field1 -side top
pack .bex.lf2.field5 -side top -anchor w
pack .bex.lf2.field6 -side top -anchor w
pack .bex.lf2.field7 -side top -anchor w
pack .bex.lf2.field8 -side top
pack .bex.lf2 -side top -ipady 5 -padx 4 -anchor w -expand true -fill x
pack .bex.lf2.msg -side left
pack .bex.lf2.listbox -side left
pack .bex.lf2.spacer -side left
pack .bex.lf2.molname2 -side right
pack .bex.lf2.msg3 -side right
pack .bex.lf2.molname -side right
pack .bex.lf2.msg2 -side right
pack .bex.lf3 -side top -pady 4 -padx 4 -anchor w -expand true -fill x
.bex.field2.settings configure -text "Hide settings"
} else {
pack forget .bex.lf3
pack forget .bex.lf1
pack forget .bex.lf2.field1
pack forget .bex.lf2.field7
pack forget .bex.lf2.field8
pack forget .bex.lf2.msg
pack forget .bex.lf2.listbox
pack forget .bex.lf2.spacer -side left
pack forget .bex.lf2.molname2 -side right
pack forget .bex.lf2.msg3 -side right
pack forget .bex.lf2.molname -side right
pack forget .bex.lf2.msg2 -side right
pack .bex.lf3
.bex.field2.settings configure -text "Settings"
}
bind .bex <Unmap> {::bendix::quit}
set ::bendix::packed [expr 1 - $::bendix::packed]
} -text "Settings" -width 10 -font {helvetica 9}
#### Visualise:
pack $bix.lf1.field1 -side top -anchor w
pack $bix.lf1.field1.msg -side left
pack $bix.lf1.field1.molname -side left
pack $bix.lf1.field1.spacer -side left
pack $bix.lf1.field1.name -side left
pack $bix.lf1.field1.particleName -side left
pack $bix.lf1.field1.cg -side right -padx 3
pack $bix.lf1.field2 -side top -anchor w
pack $bix.lf1.field2.msg -side left
pack $bix.lf1.field2.molname -side right -anchor e -expand true -fill x
pack $bix.lf1.field3 -side top -anchor w
pack $bix.lf1.field3.msg -side left
pack $bix.lf1.field4 -side top -anchor w
pack $bix.lf1.field4.msg -side left
pack $bix.lf1.field4.clear -side right -padx 2
pack $bix.lf1.field4.helices -side right -expand true -fill x
pack $bix.lf1.field5 -anchor w
pack $bix.lf1.field5.msg -side left
pack $bix.lf1 -side top -padx 4 -anchor w -expand true -fill x -pady 4
pack forget $bix.lf1
#### First packed gets its selected location
pack $bix.lf2.field1 -side top -anchor w
pack $bix.lf2.field1.straight -side left
pack $bix.lf2.field1.bendix -side left
pack $bix.lf2.field1.spacer -side right
pack $bix.lf2.field1.cp -side right
pack $bix.lf2.field5 -side top -anchor w
pack $bix.lf2.field5.colourbutton0 -side left -anchor w
pack $bix.lf2.field5.angleL -side right
pack $bix.lf2.field5.msg3 -side right
pack $bix.lf2.field5.molname -side right
pack $bix.lf2.field5.msg -side right
pack $bix.lf2.field5.listbox -side right
pack $bix.lf2.field5.msg2 -side right
pack $bix.lf2.field6 -side top -anchor w
pack $bix.lf2.field6.colourbutton1 -side left
pack $bix.lf2.field6.spacer -side left
pack $bix.lf2.field6.uniformcolour2 -side right
pack $bix.lf2.field6.uniformcolour1 -side right
pack $bix.lf2.field6.uniformcolour0 -side right
pack $bix.lf2.field7 -side top -anchor w
pack $bix.lf2.field7.msg -side left
pack $bix.lf2.field7.checkON -side right
pack $bix.lf2.field7.molname -side right
pack $bix.lf2.field8 -side top
pack $bix.lf2.field8.msg -side bottom
pack $bix.lf2 -side top -ipady 5 -padx 4 -anchor w -expand true -fill x
pack $bix.lf2.msg -side left
pack $bix.lf2.listbox -side left
pack $bix.lf2.spacer -side left
pack $bix.lf2.molname2 -side right
pack $bix.lf2.msg3 -side right
pack $bix.lf2.molname -side right
pack $bix.lf2.msg2 -side right
pack forget $bix.lf2.field1
pack forget $bix.lf2.field7
pack forget $bix.lf2.field8
pack forget $bix.lf2.msg
pack forget $bix.lf2.listbox
pack forget $bix.lf2.spacer -side left
pack forget $bix.lf2.molname2 -side right
pack forget $bix.lf2.msg3 -side right
pack forget $bix.lf2.molname -side right
pack forget $bix.lf2.msg2 -side right
####
pack $bix.lf3.field1 -side top -padx 2
pack $bix.lf3.field1.rep0 -side left
pack $bix.lf3.field1.spacer -side left
pack $bix.lf3.field1.slow -side right
pack $bix.lf3.field1.quick -side right
pack $bix.lf3.field1.spacer2 -side right
pack $bix.lf3.field1.newcartoon -side right
pack $bix.lf3.field1.cartoon -side right
pack $bix.lf3.field1.tube -side right
pack $bix.lf3 -side top -pady 4 -padx 4 -anchor w -expand true -fill x
####
pack $bix.field2 -side bottom
pack $bix.field2.boutonaffiche0 -side left -padx 10 -pady 5
pack $bix.field2.settings -side right -padx 10 -pady 5
pack $bix.field2.boutonaffiche1 -side right -padx 10 -pady 5
#### Upon window close (..or minimisation), exit Bendix properly.
bind $bix <Unmap> {
::bendix::quit
}
## Why does the wm for Delete window not work?
## In order to quit and reset upon Bendix window closure,
## I was forced to bind the quit and reset function to Unmap instead,
## which unfortunately works on minimisation, too.
# wm protocol .bex WM_DELETE_WINDOW {
# ::bendix::quit
# }
#### Hit Return to run the Bendix main drawing loop
bind $bix <Return> {set ::bendix::autolooper 0; ::bendix::mainDrawingLoop}
################################################################################
# GUI PROCS #
################################################################################
# ::bendix::MakeCG -------------------------------------------------------------
# Updates the GUI to dis/allow CG-related settings,
# update fields with default CG or AT settings
# and display/hide ir/relevant text.
# If CG, it stores what particle names to seek in the protein,
# depending on the sought secondary structure.
# ------------------------------------------------------------------------------
proc ::bendix::MakeCG {} {
if {$::bendix::CG == 1} {
.bex.lf3.field1.cartoon configure -state disable
.bex.lf3.field1.newcartoon configure -state disable
.bex.lf3.field1.tube configure -state disable
set ::bendix::MartiniBackbone "B\[CNESTH\].*"
set ::bendix::MartiniHelix "BH.*"
set ::bendix::MartiniSheet "BE.*"
set ::bendix::MartiniBackboneNew "BB\[cnesth\].*"
set ::bendix::MartiniHelixNew "BBh.*"
set ::bendix::MartiniSheetNew "BBe.*"
set ::bendix::particle_name "CA B.*"
} else {
if {$::bendix::autoCartoon == 1} {
.bex.lf3.field1.cartoon configure -state normal
.bex.lf3.field1.newcartoon configure -state disable
.bex.lf3.field1.tube configure -state disable
.bex.lf3.field1.slow configure -state disable
.bex.lf3.field1.quick configure -state disable
} elseif {$::bendix::autoNewCartoon == 1} {
.bex.lf3.field1.cartoon configure -state disable
.bex.lf3.field1.newcartoon configure -state normal
.bex.lf3.field1.tube configure -state disable
.bex.lf3.field1.slow configure -state disable
.bex.lf3.field1.quick configure -state disable
} elseif {$::bendix::autoTube == 1} {
.bex.lf3.field1.cartoon configure -state disable
.bex.lf3.field1.newcartoon configure -state disable
.bex.lf3.field1.tube configure -state normal
.bex.lf3.field1.slow configure -state disable
.bex.lf3.field1.quick configure -state disable
} elseif {$::bendix::slow_and_pretty == 1} {
.bex.lf3.field1.cartoon configure -state disable
.bex.lf3.field1.newcartoon configure -state disable
.bex.lf3.field1.tube configure -state disable
.bex.lf3.field1.slow configure -state normal
.bex.lf3.field1.quick configure -state disable
} elseif {$::bendix::quick_and_dirty == 1} {
.bex.lf3.field1.cartoon configure -state disable
.bex.lf3.field1.newcartoon configure -state disable
.bex.lf3.field1.tube configure -state disable
.bex.lf3.field1.slow configure -state disable
.bex.lf3.field1.quick configure -state normal
} else {
.bex.lf3.field1.cartoon configure -state normal
.bex.lf3.field1.newcartoon configure -state normal
.bex.lf3.field1.tube configure -state normal
.bex.lf3.field1.slow configure -state normal
.bex.lf3.field1.quick configure -state normal
}
set ::bendix::particle_name "CA"
}
}
# ::bendix::Hello_curvature ----------------------------------------------------
# Updates the GUI to allow Bendix-related settings,
# display/hide or dis/enable ir/relevant text or choices
# ------------------------------------------------------------------------------
proc ::bendix::Hello_curvature { } {
.bex.lf2.field5.molname configure -state normal
.bex.lf2.field7.molname configure -state disable
.bex.lf2.field7.checkON configure -state disable
.bex.lf2.field6.uniformcolour0 configure -state disable
.bex.lf2.field6.uniformcolour1 configure -state disable
.bex.lf2.field6.uniformcolour2 configure -state disable
.bex.lf2.field5.msg3 configure -foreground black
.bex.lf2.field5.msg configure -foreground black
.bex.lf2.field5.msg2 configure -foreground black
.bex.lf2.field5.angleL configure -state normal
.bex.lf2.field7.msg configure -foreground "gray60"
.bex.lf2.field8.msg configure -foreground "gray60"
.bex.menubar.analysis.menu entryconfigure 0 -state normal
.bex.menubar.analysis.menu entryconfigure 1 -state normal
.bex.menubar.analysis.menu entryconfigure 2 -state normal
.bex.menubar.analysis.menu entryconfigure 3 -state normal
}
# ::bendix::Hello_uniform ------------------------------------------------------
# Updates the GUI to allow uniform-colouring-related settings
# and disable/hide irrelevant text or choices.
# ------------------------------------------------------------------------------
proc ::bendix::Hello_uniform { } {
.bex.lf2.field5.molname configure -state disable
if {$::bendix::autoColour != 1} {
.bex.lf2.field7.molname configure -state normal
.bex.lf2.field8.msg configure -foreground black
}
.bex.lf2.field7.checkON configure -state normal
.bex.lf2.field6.uniformcolour0 configure -state normal
.bex.lf2.field6.uniformcolour1 configure -state normal
.bex.lf2.field6.uniformcolour2 configure -state normal
.bex.lf2.field5.msg configure -foreground "gray60"
.bex.lf2.field5.msg2 configure -foreground "gray60"
.bex.lf2.field5.msg3 configure -foreground "gray60"
.bex.lf2.field5.angleL configure -state disabled
.bex.lf2.field7.msg configure -foreground black
.bex.menubar.analysis.menu entryconfigure 0 -state disabled
.bex.menubar.analysis.menu entryconfigure 1 -state disabled
.bex.menubar.analysis.menu entryconfigure 2 -state disabled
.bex.menubar.analysis.menu entryconfigure 3 -state disabled
}
# ::bendix::cylinders ----------------------------------------------------------
# Updates the GUI to allow [cylinder rendition of helices]-related
# settings and disable/hide irrelevant text or choices.
# ------------------------------------------------------------------------------
proc ::bendix::cylinders {} {
set ::bendix::uniform_colour 1
.bex.lf2.field5.colourbutton0 configure -state disable
.bex.lf2.field1.cp configure -state disabled
::bendix::Hello_uniform
}
# ::bendix::bendices -----------------------------------------------------------
# Updates the GUI to allow bendix-related settings
# and disable/hide irrelevant text or choices.
# ------------------------------------------------------------------------------
proc ::bendix::bendices {} {
if {$::bendix::uniform_colour == 0 } {
.bex.lf2.field5.molname configure -state normal
.bex.lf2.field5.msg configure -foreground black
.bex.lf2.field5.msg2 configure -foreground black
.bex.lf2.field5.msg3 configure -foreground black
}
.bex.lf2.field5.colourbutton0 configure -state normal
.bex.lf2.field1.cp configure -state readonly
}
# ::bendix::autoON -------------------------------------------------------------
# Updates the GUI to dis/allow anto-colouring of helices
# and dis/enable the colour input field.
# ------------------------------------------------------------------------------
proc ::bendix::autoON {} {
if {$::bendix::autoColour == 1} {
.bex.lf2.field7.molname configure -state disable
.bex.lf2.field8.msg configure -foreground "gray60"
} else {
.bex.lf2.field7.molname configure -state normal
.bex.lf2.field8.msg configure -foreground black
}
}
################################################################################
# LOAD AND SAVE FILES #
################################################################################
# ::bendix::openHelixFile ------------------------------------------------------
# Pop-ups the GUI for loading helix assignment from a previously saved file.
# Inserts found text in the ::bendix::helix_assignment field and variable,
# and closes the file.
# ------------------------------------------------------------------------------
proc ::bendix::openHelixFile { } {
set myHelixAssignmentFile [tk_getOpenFile -title "Load helix assignment"]
if { $myHelixAssignmentFile == "" } {
return;
}
set helixfileID [open $myHelixAssignmentFile r];
set ::bendix::helix_assignment ""
while { [gets $helixfileID line] >= 0 } {
.bex.lf1.field4.helices insert end [format "%s" $line]
}
close $helixfileID;
# close $myHelixAssignmentFile;
}
# ::bendix::openColourFile -----------------------------------------------------
# Pop-ups the GUI for loading helix colouring from a previously saved file.
# Edits the GUI display to uncheck the Auto-colouring tickbox
# and tick the uniform colour box.
# Calls the ::bendix::Hello_uniform proc to edit the GUI further.
# Erases any previous ::bendix::input_colour field/variable data
# and inserts found text, and closes the file.
# ------------------------------------------------------------------------------
proc ::bendix::openColourFile { } {
.bex.lf2.field7.molname configure -state normal
.bex.lf2.field8.msg configure -foreground black
set ::bendix::autoColour 0
set ::bendix::uniform_colour 1
::bendix::Hello_uniform
set ::bendix::input_colour ""
set myColourFile [tk_getOpenFile -title "Load helix colour scheme"]
if { $myColourFile == "" } {
return;
}
set colourFileID [open $myColourFile r];
while { [gets $colourFileID line] >= 0 } {
.bex.lf2.field7.molname insert end [format "%s" $line]
}
close $colourFileID;
}
# ::bendix::saveHelixFile ------------------------------------------------------
# Pop-ups the GUI for saving helix starts and stops
# in the ::bendix::helix_assignment field and variable to file.
# ------------------------------------------------------------------------------
proc ::bendix::saveHelixFile {} {
set myHelixSaveFile [tk_getSaveFile -title "Save helix assignment"]
if { $myHelixSaveFile == "" } {
return;
}
set helixSavefileID [open $myHelixSaveFile w]
puts $helixSavefileID $::bendix::helix_assignment
close $helixSavefileID;
}
# ::bendix::saveColourFile -----------------------------------------------------
# Pop-ups the GUI for saving colour per helix
# in the ::bendix::input_colour field and variable to file.
# ------------------------------------------------------------------------------
proc ::bendix::saveColourFile {} {
set mySaveHelixColourFile [tk_getSaveFile -title "Save helix colour scheme"]
if { $mySaveHelixColourFile == "" } {
return;
}
set fileSaveHelixColourID [open $mySaveHelixColourFile w]
puts $fileSaveHelixColourID $::bendix::input_colour
close $fileSaveHelixColourID;
}
# ::bendix::saveSurfData -------------------------------------------------------
# Edits collected frame number, helix residue and angle data
# to be tab- and newline-spaced. This is done to conform
# to major graphing software standards for input data,
# so it can be copy-pasted.
# Pop-ups the GUI for saving this data, writes to the user-specified file
# and closes the file.
# ------------------------------------------------------------------------------
proc ::bendix::saveSurfData {} {
set one_row ""
set all_rows ""
set one_row_tabbed ""
set all_rows_tabbed ""
set all_turns "0\t"
foreach turnN $::bendix::curvature_graph_X {
append all_turns $turnN "\t"
}
foreach item $::bendix::angle_per_AA_per_frame_BARRED {
if {([expr int($item)] == $item) && $item != "0.0"} {
if {$one_row != ""} {
append all_rows $one_row "\n"
set one_row ""
}
if {$one_row_tabbed != ""} {
append all_rows_tabbed $one_row_tabbed "\n"
set one_row_tabbed ""
}
}
append one_row $item " "
append one_row_tabbed $item "\t"
}
append all_rows $one_row
append all_rows_tabbed $one_row_tabbed
set myDataFile [tk_getSaveFile -title "Save surf data"]
if { $myDataFile == "" } {
return;
}
set fileDataID [open $myDataFile w]
puts $fileDataID "Hi! Below is your helix curvature data.\
\n\nFor clear results, open this document in an editor that recognises newline characters.\
\nColumns are delimited by tabs, and rows by newline characters.\
\n\nRow 1 = Residues. If you chose to save multiple helices' data, these are listed sequentially\
(as are angles).\n\nColumn 1 = Frame numbers, in the order that you played the trajectory.\
To collect data starting from a different frame, load your frame of choice, hit \[Erase\]\
in the bendix main window (this deletes any collected data), \[Draw\] and play your trajectory.\
\n\n\n==================================================================================\n\n\
$all_turns\n$all_rows_tabbed"
close $fileDataID;
}
# ::bendix::saveAxisData -------------------------------------------------------
# Checks that data exists; if it does not it prompts the user to turn on coordinate storage.
# Pop-ups the GUI for saving coordinate data, writes to the user-specified file
# and closes the file.
# ------------------------------------------------------------------------------
proc ::bendix::saveAxisData {} {
if {$::bendix::helix_axis_per_helix_per_frame_BARRED == ""} {
#### Where there's nothing to graph, return error.
catch {destroy .messpopNoAxesCoords}
toplevel .messpopNoAxesCoords
wm geometry .messpopNoAxesCoords +100+150
#grab .messpopNoAxesCoords
wm title .messpopNoAxesCoords "No axis data to save yet."
message .messpopNoAxesCoords.msg1 -width 350 \
-text "Bendix detects no saved coordinate data to write to file.\
\nYou need to enable axis coordinate storage by selecting 'Store helix axes' under Bendix' Analysis menu.\nThen redraw your protein (by clicking Erase followed by Draw) to generate axis data." -pady 15 -padx 10
button .messpopNoAxesCoords.ok -text Return -background green \
-command {
destroy .messpopNoAxesCoords
return 0
}
pack .messpopNoAxesCoords.msg1 -side top
pack .messpopNoAxesCoords.ok -side bottom -pady 5
#### Upon window close or minimisation, exit properly.
#bind .messpopNoAxesCoords <Unmap> {
# destroy .messpopNoAxesCoords
# return 0
#}
} else {
#### Save stored coordinates:
set myAxisFile [tk_getSaveFile -title "Save axes data"]
if { $myAxisFile == "" } {
return;
}
set fileDataID [open $myAxisFile w]
puts $fileDataID "Hi! Below is your Bendix axis data.\
\nN.B. The helix axis algorithm requires 5 or more residues to generate an axis, so only helices that contain 5 or more residues are listed here.\
\nFor more information, see http://sbcb.bioch.ox.ac.uk/Bendix/faqLess_Tech.html or the original paper by Sugeta and Miyazawa in Biopolymers 1967 5(7):673-679.
\n\nCoordinates are tabbed and different helices' data are separated by newline characters. For clear results, open this document in an editor that recognises newline and tab characters.\
\nFrame numbers are in the order that you played the trajectory.\
To collect data starting from a different frame, load your frame of choice, hit \[Erase\]\
in the bendix main window (this deletes any collected data), \[Draw\] and play your trajectory.\
\n\n\n==================================================================================
$::bendix::helix_axis_per_helix_per_frame_BARRED\n"
close $fileDataID;
}
}
################################################################################
# USER HELP AND ACKNOWLEDGEMENTS #
################################################################################
# ::bendix::quickBendix --------------------------------------------------------
# Sources a picture which shows how to use the Bendix GUI, as a pop-up
# ------------------------------------------------------------------------------
proc ::bendix::quickBendix {} {
global get_file