-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw_interactions.tcl
72 lines (58 loc) · 2.08 KB
/
draw_interactions.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
proc draw_interactions { mol pairs_file color radius} {
# read in contact pairs
set file [open $pairs_file]
# read in each line from the file
while {[gets $file cline] >= 0} {
# split on whitespace
set inds [split $cline ","]
# set variables from each row
set ind1 [lindex $inds 0]
set ind2 [lindex $inds 1]
# make two selections for each atom
set sel1 [atomselect $mol "serial $ind1"]
set sel2 [atomselect $mol "serial $ind2"]
# assign the coordinates to two variables
lassign [$sel1 get {x y z}] start
lassign [$sel2 get {x y z}] end
# set the color for the graphics
graphics $mol color $color
# draw the cylinder
graphics $mol cylinder $start $end radius $radius
}
close $file
}
proc draw_interaction { mol serial_a serial_b color radius} {
# make two selections for each atom
set sel1 [atomselect $mol "serial $serial_a"]
set sel2 [atomselect $mol "serial $serial_b"]
# assign the coordinates to two variables
lassign [$sel1 get {x y z}] start
lassign [$sel2 get {x y z}] end
# set the color for the graphics
graphics $mol color $color
# draw the cylinder
graphics $mol cylinder $start $end radius $radius
}
proc draw_interaction_lines { mol pairs_file color width} {
# read in contact pairs
set file [open $pairs_file]
# read in each line from the file
while {[gets $file cline] >= 0} {
# split on whitespace
set inds [split $cline ","]
# set variables from each row
set ind1 [lindex $inds 0]
set ind2 [lindex $inds 1]
# make two selections for each atom
set sel1 [atomselect $mol "serial $ind1"]
set sel2 [atomselect $mol "serial $ind2"]
# assign the coordinates to two variables
lassign [$sel1 get {x y z}] start
lassign [$sel2 get {x y z}] end
# set the color for the graphics
graphics $mol color $color
# draw the cylinder
graphics $mol line $start $end width $width
}
close $file
}