-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathripmd.tcl
2432 lines (2053 loc) · 88.6 KB
/
ripmd.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
package provide ripmd 1.0
namespace eval RIPMD:: {
namespace export ripmd
# window handles
variable w ;# handle to main window
variable resultFolder
##########################################
##
## variables for general options section
##
##########################################
#checkbuttons variables
variable calpha 1zx
variable hbonds 1
variable salt 1
variable disulphide 1
variable capi 1
variable pipi 1
variable ArgArg 1
variable vdw 0
variable coulomb 0
variable pearson 0
#output path variable
variable dirName
#final graph format
variable format "GML"
#selection to use
variable proteinSelection "protein"
#############################################
##
##variables for interaction options section
##
#############################################
#for C alpha
variable calphaDist "8"
#for hbond
variable hbondDist "3"
variable hbondAngle "120"
#for salt
variable saltDist "6"
#pi - pi
variable pipiDist "6"
#Arg - Arg
variable ArgArgDist "5"
#coulomb
variable simulatedPermittivity "1"
variable reactionFieldPermittivity "82"
variable reactionField 1
variable temp "298.5"
variable inverseDebye "0"
variable coulombThreshold "12"
variable coulombCovalentDist "3"
#cartion-pi
variable capiDist "7"
variable capiAngle1 "0"
variable capiAngle2 "60"
variable capiAngle3 "120"
variable capiAngle4 "180"
#disulphide
variable disulphideDist "3"
variable disulphideAng1 "60"
variable disulphideAng2 "90"
#vdw
variable covalentDist "3"
variable distVDW1 "-0.1"
variable distVDW2 "3"
##########################################
##
## variables for MD options section
##
##########################################
#MD time
variable percentaje "75"
##########################################
##
## variables for PDB options section
##
##########################################
variable missing 0
#ph
variable pH "7.0"
#################################
##
## for RIP-MD execution
##
#################################
#files on VMD
variable pathToFiles
variable pdb "*"
variable dcd "*"
variable psf "*"
variable command
variable outputFolder "*"
variable proc "1"
variable errors
################################
##
## for VMD representation and
## displaying
##
###############################
variable displayCalpha 1
variable displayHbonds 1
variable displaySalt 1
variable displayDisulphide 1
variable displayCapi 1
variable displayPipi 1
variable displayArgArg 1
variable displayVdw 0
variable displayCoulomb 0
#frame to use
variable frame "0"
variable frame_start "0"
variable frame_end "-1"
variable frame_separation "0"
#to show pearson
variable pearson1 "All"
variable pearson2 "All"
#general variable to draw bonds
variable residIndexDict
variable indexResidDict
variable matrixCalpha
variable matrixHbond
variable matrixSalt
variable matrixDisulphide
variable matrixCationPi
variable matrixPiPi
variable matrixArgArg
variable matrixCoulomb
variable matrixVdw
variable nodes ""
variable selection ""
variable toUse "segid"
variable forceField "RIP_MD/dat/top_all22_prot.rtf"
variable parameterFile "RIP_MD/dat/par_all22_prot.prm"
variable hist "All"
}
#
# function to draw the target residues of each interaction
#
proc RIPMD::drawNotSelectedResidues {indices} {
if {[llength $indices] == 0} {
#if we dont have target residues we will return
return
}
set chain {}
foreach num $indices {
set aux1 "[dict get $RIPMD::indexResidDict $num]"
set aux [split $aux1 ":"]
#if chain is not in the chain variable we will append it
if {[string match *[lindex $aux 1]* $chain] != 1} {
append chain "[lindex $aux 1] "
}
}
###
#now we will append to a list of list the different residues
set resids {}
set resids [lrepeat [llength $chain] {}]
set Selection ""
foreach index $indices {
#setting a list of residues to append in order of the chain
set aux [split [dict get $RIPMD::indexResidDict $index] ":"]
#now we will look for the actual chain to append the residue
set position [lsearch $chain [lindex $aux 1]]
set auxList [lindex $resids $position]
append auxList "[lindex $aux 2] "
set resids [lreplace $resids $position $position $auxList]
}
#at this point the selection is configured
set countChain 0
foreach item $chain {
if {$countChain != [expr [llength $chain] - 1]} {
append Selection "($RIPMD::toUse $item and resid [lindex $resids $countChain] ) or "
} else {
append Selection "($RIPMD::toUse $item and resid [lindex $resids $countChain] )"
}
incr countChain
}
#creating new representations and setting protein style
set numbersOfRep [molinfo top get numreps]
for { set i 0 } { $i < $numbersOfRep} {incr i} {
mol delrep end top
}
mol addrep top
mol modselect 0 top protein
mol modstyle 0 top trace 0.2
mol modmaterial 0 top Transparent
mol modcolor 0 top colorid 8
mol addrep top
mol modselect 1 top alpha
mol modstyle 1 top vdw 0.5
mol modcolor 1 top colorid 1
mol addrep top
mol modselect 2 top "$RIPMD::selection"
mol modstyle 2 top Bonds 0.2
mol addrep top
mol modselect 3 top "$Selection"
mol modstyle 3 top Bonds 0.2
}
#
# function to draw bonds
#
proc RIPMD::drawBonds {} {
set indices {}
#first we will delete all draws
foreach ID [graphics top list] {
graphics top delete $ID
}
#and now we will look for interactions to draw
if {$RIPMD::nodes != ""} {
set indices {}
#we are sure that anode has been selected
foreach index [$RIPMD::nodes curselection] {
#######################################
##
##To display Calpha interactions
##
######################################
if {$RIPMD::displayCalpha == 1} {
set cont 0
#we will set the first coordinate
set aux [split [$RIPMD::nodes get $index] ":"]
#toUse is = to chain or segid
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and alpha"]
set coord1 [$res1 get {x y z}]
foreach item [lindex $RIPMD::matrixCalpha $index] {
if {$item != 0} {
#we will set the second coordinate
set aux [split [$RIPMD::nodes get $cont] ":"]
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and alpha"]
set coord2 [$res2 get {x y z}]
#now we will draw the dashed line
set a [lindex $coord1 0]
set b [lindex $coord2 0]
#to select yellow color for contacts
graphics top color 0
graphics top line $a $b width 5 style dashed
#append to indices list to then draw the new residues
if {[lsearch $indices $cont] == -1} {
lappend indices $cont
}
}
incr cont
}
}
#######################################
##
##To display HBonds
##
######################################
if {$RIPMD::displayHbonds == 1} {
set cont 0
#we will set the first coordinate
set aux [split [$RIPMD::nodes get $index] ":"]
foreach item [lindex $RIPMD::matrixHbond $index] {
if {$item != {}} {
foreach list $item {
set resids [split [lindex [lindex $item 0] 0] " "]
set firstAtom [lindex [split [lindex $resids 0] ":"] 3]
set secondAtom [lindex [split [lindex $resids 2] ":"] 3]
set aux [split [lindex $resids 0] ":"]
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type $firstAtom"]
set coord1 [$res1 get {x y z}]
set aux [split [lindex $resids 2] ":"]
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type $secondAtom"]
set coord2 [$res2 get {x y z}]
#now we will draw the dashed line
set a [lindex $coord1 0]
set b [lindex $coord2 0]
#to select yellow color for contacts
graphics top color 8
graphics top line $a $b width 5 style dashed
}
#append to indices list to then draw the new residues
if {[lsearch $indices $cont] == -1} {
lappend indices $cont
}
}
incr cont
}
}
#######################################
##
##To display Salt Bridges
##
######################################
if {$RIPMD::displaySalt == 1} {
set cont 0
#we will set the first coordinate
set aux [split [$RIPMD::nodes get $index] ":"]
foreach item [lindex $RIPMD::matrixSalt $index] {
if {$item != {}} {
foreach list $item {
set resids [split [lindex [lindex $item 0] 0] " "]
set firstAtom [lindex [split [lindex $resids 0] ":"] 3]
set secondAtom [lindex [split [lindex $resids 2] ":"] 3]
set aux [split [lindex $resids 0] ":"]
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type $firstAtom"]
set coord1 [$res1 get {x y z}]
set aux [split [lindex $resids 2] ":"]
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type $secondAtom"]
set coord2 [$res2 get {x y z}]
#now we will draw the dashed line
set a [lindex $coord1 0]
set b [lindex $coord2 0]
#to select yellow color for contacts
graphics top color 3
graphics top line $a $b width 5 style dashed
}
#append to indices list to then draw the new residues
if {[lsearch $indices $cont] == -1} {
lappend indices $cont
}
}
incr cont
}
}
#######################################
##
##To display Disulphide interactions
##
######################################
if {$RIPMD::displayDisulphide == 1} {
set cont 0
#we will set the first coordinate
set aux [split [$RIPMD::nodes get $index] ":"]
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type SG"]
set coord1 [$res1 get {x y z}]
foreach item [lindex $RIPMD::matrixDisulphide $index] {
if {$item != 0} {
#we will set the second coordinate
set aux [split [$RIPMD::nodes get $cont] ":"]
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type SG"]
set coord2 [$res2 get {x y z}]
#now we will draw the dashed line
set a [lindex $coord1 0]
set b [lindex $coord2 0]
#to select blue color for contacts
graphics top color 4
graphics top line $a $b width 5 style dashed
#append to indices list to then draw the new residues
if {[lsearch $indices $cont] == -1} {
lappend indices $cont
}
}
incr cont
}
}
#######################################
##
##To display cation pi interaction
##
######################################
if {$RIPMD::displayCapi == 1} {
set cont 0
set aux [split [$RIPMD::nodes get $index] ":"]
foreach item [lindex $RIPMD::matrixCationPi $index] {
if {$item != {}} {
foreach list $item {
set firstRes [lindex [split [lindex $list 0] " "] 0]
set secondRes [lindex [split [lindex $list 0] " "] 3]
#getting the coord of the cation
set cation [lindex [split $firstRes ":"] 0]
set res1 ""
set chain [lindex [split $firstRes ":"] 1]
set resid [lindex [split $firstRes ":"] 2]
if {$cation == "LYS"} {
set res1 [atomselect top "$RIPMD::toUse $chain and resid $resid and type NZ"]
} elseif {$cation == "HIS"} {
set res1 [atomselect top "$RIPMD::toUse $chain and resid $resid and type NE2"]
} elseif {$cation == "ARG"} {
set res1 [atomselect top "$RIPMD::toUse $chain and resid $resid and type CZ"]
}
set coord1 [$res1 get {x y z}]
#now we will extract the coord for the pi system
set pi [lindex [split $secondRes ":"] 0]
set res2 ""
set chain [lindex [split $secondRes ":"] 1]
set resid [lindex [split $secondRes ":"] 2]
set coord2 ""
if {$pi == "PHE" || $pi == "TYR"} {
set cont2 0
set coord2 [veczero]
set res2 [atomselect top "$RIPMD::toUse $chain and resid $resid and type CG CD1 CD2 CE1 CE2 CZ"]
set coords [$res2 get {x y z}]
foreach coord $coords {
set coord2 [vecadd $coord2 $coord]
incr cont2
}
set coord2 [vecscale [expr 1.0 / $cont2] $coord2]
} elseif {$pi == "TRP"} {
set cont2 0
set coord2 [veczero]
set res2 [atomselect top "$RIPMD::toUse $chain and resid $resid and type CG CD1 CD2 NE1 CE2 CE3 CZ2 CZ3 CH2"]
set coords [$res2 get {x y z}]
foreach coord $coords {
set coord2 [vecadd $coord2 $coord]
incr cont2
}
set coord2 [vecscale [expr 1.0 / $cont2] $coord2]
} elseif {$pi == "HIS"} {
set cont2 0
set coord2 [veczero]
set res2 [atomselect top "chain $chain and resid $resid and type CG ND1 CE1 NE2 CD2"]
set coords [$res2 get {x y z}]
foreach coord $coords {
set coord2 [vecadd $coord2 $coord]
incr cont2
}
set coord2 [vecscale [expr 1.0 / $cont2] $coord2]
}
#to select pink color for contacts
graphics top color 7
graphics top line [lindex $coord1 0] $coord2 width 5 style dashed
}
#append to indices list to then draw the new residues
if {[lsearch $indices $cont] == -1} {
lappend indices $cont
}
}
incr cont
}
}
###################################
##
##To display Pi Pi interactions
##
###################################
if {$RIPMD::displayPipi == 1} {
set cont 0
set coord1 [veczero]
set coord2 [veczero]
#we will set the first coordinate
set aux [split [$RIPMD::nodes get $index] ":"]
if {[lindex $aux 0] == "PHE" || [lindex $aux 0] == "TYR"} {
set cont 0
set coord1 [veczero]
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type CG CD1 CD2 CE1 CE2 CZ"]
set coords [$res1 get {x y z}]
foreach coord $coords {
set coord1 [vecadd $coord1 $coord]
incr cont
}
set coord1 [vecscale [expr 1.0 / $cont] $coord1]
} elseif {[lindex $aux 0] == "TRP"} {
set cont 0
set coord1 [veczero]
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type CG CD1 CD2 NE1 CE2 CE3 CZ2 CZ3 CH2"]
set coords [$res1 get {x y z}]
foreach coord $coords {
set coord1 [vecadd $coord1 $coord]
incr cont
}
set coord1 [vecscale [expr 1.0 / $cont] $coord1]
} elseif {[lindex $aux 0] == "HIS" || [lindex $aux 0] == "HSD" || [lindex $aux 0] == "HSE" || [lindex $aux 0] == "HSP"} {
set cont 0
set coord1 [veczero]
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type CG ND1 CE1 NE2 CD2"]
set coords [$res1 get {x y z}]
foreach coord $coords {
set coord1 [vecadd $coord1 $coord]
incr cont
}
set coord1 [vecscale [expr 1.0 / $cont] $coord1]
}
set cont2 0
foreach item [lindex $RIPMD::matrixPiPi $index] {
if {$item != 0} {
set coord2 [veczero]
set aux [split [$RIPMD::nodes get $cont2] ":"]
if {[lindex $aux 0] == "PHE" || [lindex $aux 0] == "TYR"} {
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type CG CD1 CD2 CE1 CE2 CZ"]
} elseif {[lindex $aux 0] == "TRP"} {
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type CG CD1 CD2 NE1 CE2 CE3 CZ2 CZ3 CH2"]
} elseif {[lindex $aux 0] == "HIS" || [lindex $aux 0] == "HSD" || [lindex $aux 0] == "HSE" || [lindex $aux 0] == "HSP"} {
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type CG ND1 CE1 NE2 CD2"]
}
set coords [$res2 get {x y z}]
set cont 0
foreach coord $coords {
set coord2 [vecadd $coord2 $coord]
incr cont
}
set coord2 [vecscale [expr 1.0 / $cont] $coord2]
#now we will draw the dashed line
set a [lindex $coord1 0]
set b [lindex $coord2 0]
#to select pink color for contacts
graphics top color 9
graphics top line $coord1 $coord2 width 5 style dashed
#append to indices list to then draw the new residues
if {[lsearch $indices $cont2] == -1} {
lappend indices $cont2
}
}
incr cont2
}
}
#######################################
##
##To display Arg - Arg interactions
##
######################################
if {$RIPMD::displayArgArg == 1} {
set cont 0
#we will set the first coordinate
set aux [split [$RIPMD::nodes get $index] ":"]
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type CZ"]
set coord1 [$res1 get {x y z}]
foreach item [lindex $RIPMD::matrixArgArg $index] {
if {$item != 0} {
#we will set the second coordinate
set aux [split [$RIPMD::nodes get $cont] ":"]
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type CZ"]
set coord2 [$res2 get {x y z}]
#now we will draw the dashed line
set a [lindex $coord1 0]
set b [lindex $coord2 0]
#to select yellow color for contacts
graphics top color 1
graphics top line $a $b width 5 style dashed
#append to indices list to then draw the new residues
if {[lsearch $indices $cont] == -1} {
lappend indices $cont
}
}
incr cont
}
}
#######################################
##
##To display vdW
##
######################################
if {$RIPMD::displayVdw == 1} {
set cont 0
#we will set the first coordinate
set aux [split [$RIPMD::nodes get $index] ":"]
foreach item [lindex $RIPMD::matrixVdw $index] {
if {$item != {}} {
foreach list $item {
set resids [split [lindex [lindex $item 0] 0] " "]
set firstAtom [lindex [split [lindex $resids 0] ":"] 3]
set secondAtom [lindex [split [lindex $resids 2] ":"] 3]
set aux [split [lindex $resids 0] ":"]
set res1 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type $firstAtom"]
set coord1 [$res1 get {x y z}]
if {$coord1 != ""} {
set aux [split [lindex $resids 2] ":"]
set res2 [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type $secondAtom"]
set coord2 [$res2 get {x y z}]
if {$coord2 != ""} {
#now we will draw the dashed line
set a [lindex $coord1 0]
set b [lindex $coord2 0]
#to select yellow color for contacts
graphics top color 11
graphics top line $a $b width 5 style dashed
}
#append to indices list to then draw the new residues
if {[lsearch $indices $cont] == -1} {
lappend indices $cont
}
}
}
}
incr cont
}
}
##########################################################################################################################################
###################################
##
##To display Coulomb interactions
##
###################################
if {$RIPMD::displayCoulomb == 1} {
set cont 0
#we will set the first coordinate
set aux [split [$RIPMD::nodes get $index] ":"]
foreach item [lindex $RIPMD::matrixCoulomb $index] {
set coord1 [veczero]
set coord2 [veczero]
if {$item != {}} {
foreach list $item {
set resids [split [lindex [lindex $item 0] 0] " "]
set firstAtoms [string map {"," " "} [split [lindex [split [lindex $resids 0] ":"] 3]]]
set secondAtoms [string map {"," " "} [split [lindex [split [lindex $resids 2] ":"] 3]]]
#now we have two list of atoms groups forming the interaction
set aux [split [lindex $resids 0] ":"]
#to set the first coord
set coord1 [veczero]
set cont1 0
foreach atom $firstAtoms {
set coords ""
set sel [atomselect top "$RIPMD::toUse [lindex $aux 1] and resid [lindex $aux 2] and type $atom"]
set coords [$sel get {x y z}]
if {$coords != ""} {
foreach coord $coords {
set coord1 [vecadd $coord1 $coord]
incr cont1
}
}
}
if {$cont1 != 0} {
#getting the average of coord1
set coord1 [vecscale [expr 1.0 / $cont1] $coord1]
#to set coord2
set coord2 [veczero]
set cont1 0
set aux2 [split [lindex $resids 2] ":"]
foreach atom $secondAtoms {
set coords ""
set sel [atomselect top "$RIPMD::toUse [lindex $aux2 1] and resid [lindex $aux2 2] and type $atom"]
set coords [$sel get {x y z}]
if {$coords != ""} {
foreach coord $coords {
set coord2 [vecadd $coord2 $coord]
incr cont1
}
}
}
if {$cont1 != 0} {
set coord2 [vecscale [expr 1.0 / $cont1] $coord2]
#to select tan color for contacts
graphics top color 5
graphics top line $coord1 $coord2 width 5 style dashed
}
#append to indices list to then draw the new residues
if {[lsearch $indices $cont] == -1} {
lappend indices $cont
}
}
}
}
incr cont
}
}
###################################################################################################################
}
}
RIPMD::drawNotSelectedResidues $indices
}
#
# Function to select nodes and make bonds
#
proc RIPMD::selectionMade {w} {
set chain {}
# --- loop through each selected element
foreach index [$w curselection] {
set numbersOfRep [molinfo top get numreps]
for { set i 0 } { $i < $numbersOfRep} {incr i} {
mol delrep end top
}
#creating new representations and setting protein style
mol addrep top
mol modselect 0 top protein
mol modstyle 0 top trace 0.2
mol modmaterial 0 top Transparent
mol modcolor 0 top colorid 8
mol addrep top
mol modselect 1 top alpha
mol modstyle 1 top vdw 0.5
mol modcolor 1 top colorid 1
set aux [split [$w get $index] ":"]
#if chain is not in the chain variable we will append it
if {[string match *[lindex $aux 1]* $chain] != 1} {
append chain "[lindex $aux 1] "
}
}
#now we will append to a list of list the different residues
set resids {}
set resids [lrepeat [llength $chain] {}]
set selection ""
foreach index [$w curselection] {
#setting a list of residues to append in order of the chain
set aux [split [$w get $index] ":"]
#now we will look for the actual chain to append the residue
set position [lsearch $chain [lindex $aux 1]]
set auxList [lindex $resids $position]
append auxList "[lindex $aux 2] "
set resids [lreplace $resids $position $position $auxList]
}
#at this point the selection is configured
set countChain 0
#to use is to know if we have chain or segid
foreach item $chain {
if {$countChain != [expr [llength $chain] - 1]} {
append selection "($RIPMD::toUse $item and resid [lindex $resids $countChain] ) or "
} else {
append selection "($RIPMD::toUse $item and resid [lindex $resids $countChain] )"
}
incr countChain
}
set sel [atomselect top $selection]
if { [llength [$sel getbonds]] == 0 } {
set RIPMD::toUse "chain"
set selection [string map {segid chain} $selection]
}
set RIPMD::selection "$selection"
mol addrep top
mol modselect 2 top "$selection"
mol modstyle 2 top Bonds 0.2
set RIPMD::nodes $w
RIPMD::drawBonds
}
#
#function to fill the matrices
#
proc RIPMD::fillMatrices {} {
set fp [open "$RIPMD::resultFolder/RIP-MD_Results/Graphs/consensus_as_list" r]
set file_data [read $fp]
close $fp
## Process data file
set data2 [split $file_data "\n"]
foreach line2 $data2 {
set line3 [split $line2 " "]
if { $line3 != "" } {
#adding interaction to the matrices
set matrixCoord1 [dict get $RIPMD::residIndexDict [lindex $line3 0]]
set matrixCoord2 [dict get $RIPMD::residIndexDict [lindex $line3 1]]
#alpha carbon
if {[string match *-(Ca)-* $line2] == 1} {
set vector [lindex $RIPMD::matrixCalpha $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]
set vector [lreplace $vector $matrixCoord2 $matrixCoord2 [incr actualValue]]
#two matrixcoord1 because is the start and end of the position
set RIPMD::matrixCalpha [lreplace $RIPMD::matrixCalpha $matrixCoord1 $matrixCoord1 $vector]
set vector [lindex $RIPMD::matrixCalpha $matrixCoord2]
set actualValue [lindex $vector $matrixCoord1]
set vector [lreplace $vector $matrixCoord1 $matrixCoord1 [incr actualValue]]
set RIPMD::matrixCalpha [lreplace $RIPMD::matrixCalpha $matrixCoord2 $matrixCoord2 $vector]
}
#HBond
if {[string match *-(HB)-* $line2] == 1} {
#getting the interacting atoms in the HBond
set interaction [split $line2 "'"]
if {[string match *time* $line2] == 1} {
set interactionName [lindex $interaction [expr [llength $interaction] - 6]]
set interaction [split $interactionName "-"]
} else {
set interactionName [lindex $interaction [expr [llength $interaction] - 2]]
set interaction [split $interactionName "-"]
}
set atomList {}
lappend atomList $interaction
#filling the NxNxM matrix
set vector [lindex $RIPMD::matrixHbond $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]
set vector [lreplace $vector $matrixCoord2 $matrixCoord2 [lappend actualValue $atomList]]
set RIPMD::matrixHbond [lreplace $RIPMD::matrixHbond $matrixCoord1 $matrixCoord1 $vector]
set vector [lindex $RIPMD::matrixHbond $matrixCoord2]
set actualValue [lindex $vector $matrixCoord1]
set vector [lreplace $vector $matrixCoord1 $matrixCoord1 [lappend actualValue $atomList]]
set RIPMD::matrixHbond [lreplace $RIPMD::matrixHbond $matrixCoord2 $matrixCoord2 $vector]
}
#Salt Bridges
if {[string match *-(salt)-* $line2] == 1} {
#getting the interacting atoms in the Salt bridge
set interaction [split $line2 "'"]
if {[string match *time* $line2] == 1} {
set interactionName [lindex $interaction [expr [llength $interaction] - 6]]
set interaction [split $interactionName "-"]
} else {
set interactionName [lindex $interaction [expr [llength $interaction] - 2]]
set interaction [split $interactionName "-"]
}
set atomList {}
lappend atomList $interaction
#filling the NxNxM matrix
set vector [lindex $RIPMD::matrixSalt $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]
set vector [lreplace $vector $matrixCoord2 $matrixCoord2 [lappend actualValue $atomList]]
set RIPMD::matrixSalt [lreplace $RIPMD::matrixSalt $matrixCoord1 $matrixCoord1 $vector]
set vector [lindex $RIPMD::matrixSalt $matrixCoord2]
set actualValue [lindex $vector $matrixCoord1]
set vector [lreplace $vector $matrixCoord1 $matrixCoord1 [lappend actualValue $atomList]]
set RIPMD::matrixSalt [lreplace $RIPMD::matrixSalt $matrixCoord2 $matrixCoord2 $vector]
}
#disulphide bridges
if {[string match *-(SS)-* $line2] == 1} {
set vector [lindex $RIPMD::matrixDisulphide $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]
set vector [lreplace $vector $matrixCoord2 $matrixCoord2 [incr actualValue]]
set RIPMD::matrixDisulphide [lreplace $RIPMD::matrixDisulphide $matrixCoord1 $matrixCoord1 $vector]
set vector [lindex $RIPMD::matrixDisulphide $matrixCoord2]
set actualValue [lindex $vector $matrixCoord1]
set vector [lreplace $vector $matrixCoord1 $matrixCoord1 [incr actualValue]]
set RIPMD::matrixDisulphide [lreplace $RIPMD::matrixDisulphide $matrixCoord2 $matrixCoord2 $vector]
}
#cation pi interaction
if {[string match *-(cation-pi)-* $line2] == 1} {
#getting the interacting atoms in the cation pi interaction
set interaction [split $line2 "'"]
if {[string match *time* $line2] == 1} {
set interactionName [lindex $interaction [expr [llength $interaction] - 6]]
set interaction [split $interactionName "-"]
} else {
set interactionName [lindex $interaction [expr [llength $interaction] - 6]]
set interaction [split $interactionName "-"]
}
set atomList {}
lappend atomList $interaction
#filling the NxNxM matrix
set vector [lindex $RIPMD::matrixCationPi $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]
set vector [lreplace $vector $matrixCoord2 $matrixCoord2 [lappend actualValue $atomList]]
set RIPMD::matrixCationPi [lreplace $RIPMD::matrixCationPi $matrixCoord1 $matrixCoord1 $vector]
set vector [lindex $RIPMD::matrixCationPi $matrixCoord2]
set actualValue [lindex $vector $matrixCoord1]
set vector [lreplace $vector $matrixCoord1 $matrixCoord1 [lappend actualValue $atomList]]
set RIPMD::matrixCationPi [lreplace $RIPMD::matrixCationPi $matrixCoord2 $matrixCoord2 $vector]
}
#pi-pi interaction
if {[string match *-(pi-pi)-* $line2] == 1} {
set vector [lindex $RIPMD::matrixPiPi $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]
set vector [lreplace $vector $matrixCoord2 $matrixCoord2 [incr actualValue]]
set RIPMD::matrixPiPi [lreplace $RIPMD::matrixPiPi $matrixCoord1 $matrixCoord1 $vector]
set vector [lindex $RIPMD::matrixPiPi $matrixCoord2]
set actualValue [lindex $vector $matrixCoord1]
set vector [lreplace $vector $matrixCoord1 $matrixCoord1 [incr actualValue]]
set RIPMD::matrixPiPi [lreplace $RIPMD::matrixPiPi $matrixCoord2 $matrixCoord2 $vector]
}
#Arg - Arg interaction
if {[string match *-(Arg-Arg)-* $line2] == 1} {
set vector [lindex $RIPMD::matrixArgArg $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]
set vector [lreplace $vector $matrixCoord2 $matrixCoord2 [incr actualValue]]
#two matrixcoord1 because is the start and end of the position
set RIPMD::matrixArgArg [lreplace $RIPMD::matrixArgArg $matrixCoord1 $matrixCoord1 $vector]
set vector [lindex $RIPMD::matrixArgArg $matrixCoord2]
set actualValue [lindex $vector $matrixCoord1]
set vector [lreplace $vector $matrixCoord1 $matrixCoord1 [incr actualValue]]
set RIPMD::matrixArgArg [lreplace $RIPMD::matrixArgArg $matrixCoord2 $matrixCoord2 $vector]
}
#Coulomb
if {[string match *-(coulomb)-* $line2] == 1} {
set interaction [split $line2 "'"]
if {[string match *time* $line2] == 1} {
set interactionName [lindex $interaction [expr [llength $interaction] - 10]]
set interaction [split $interactionName "-"]
} else {
set interactionName [lindex $interaction [expr [llength $interaction] - 2]]
set interaction [split $interactionName "-"]
}
#set interactionName [lindex $interaction [expr [llength $interaction] - 2]]
#set interaction [split $interactionName "-"]
set atomList {}
lappend atomList $interaction
#filling the NxNxM matrix
set vector [lindex $RIPMD::matrixCoulomb $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]
set vector [lreplace $vector $matrixCoord2 $matrixCoord2 [lappend actualValue $atomList]]
set RIPMD::matrixCoulomb [lreplace $RIPMD::matrixCoulomb $matrixCoord1 $matrixCoord1 $vector]
set vector [lindex $RIPMD::matrixCoulomb $matrixCoord2]
set actualValue [lindex $vector $matrixCoord1]
set vector [lreplace $vector $matrixCoord1 $matrixCoord1 [lappend actualValue $atomList]]
set RIPMD::matrixCoulomb [lreplace $RIPMD::matrixCoulomb $matrixCoord2 $matrixCoord2 $vector]
}
#vdW
if {[string match *-(vdW)-* $line2] == 1} {
#getting the interacting atoms in the vdW
set interaction [split $line2 "'"]
if {[string match *time* $line2] == 1} {
set interactionName [lindex $interaction [expr [llength $interaction] - 10]]
set interaction [split $interactionName "-"]
} else {
set interactionName [lindex $interaction [expr [llength $interaction] - 2]]
set interaction [split $interactionName "-"]
}
set atomList {}
lappend atomList $interaction
#filling the NxNxM matrix
set vector [lindex $RIPMD::matrixVdw $matrixCoord1]
set actualValue [lindex $vector $matrixCoord2]