-
Notifications
You must be signed in to change notification settings - Fork 6
/
cpk.tcl
83 lines (62 loc) · 1.85 KB
/
cpk.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
## Use a repid id and create 3 copies with representations:
## 1. seltext and "C.*"
## 2. seltext and "O.*"
## 3. seltext and "N.*"
proc cpk {repid {molid top}} {
if {$molid == "top"} {
set molid [molinfo top]
}
## Selection text
set seltext [molinfo $molid get "{selection $repid}"]
## Color
set colorid [molinfo $molid get "{color $repid}"]
## Molinfo properties
catch {array unset rep}
foreach x {rep material} {
set rep($x) [molinfo $molid get "{$x $repid}"]
}
## Mol properties
foreach x {numperiodic showperiodic
scaleminmax smoothrep drawframes} {
set rep($x) [list $molid $repid [mol $x $molid $repid]]
}
## More mol properties (WTF? why reverse molid/repid?)
foreach x {selupdate colupdate} {
set rep($x) [list $repid $molid [mol $x $repid $molid]]
}
## Create the selections and set properties
foreach x {\"C.*\" \"O.*\" \"N.*\"} color [list $colorid "ColorID 1" "ColorID 0"] {
mol selection "name $x and ($seltext)"
mol color {*}$color
mol addrep $molid
foreach {prop val} [array get rep *] {
mol $prop {*}[join $val]
}
}
}
## Make a lookup of all reps in vmd indexed by {molid repid}
proc get_reps {{molid "all"}} {
global reps
catch {array unset reps}
if {$molid == "all"} {
set molid [molinfo list]
}
set N [molinfo $x get numreps]
foreach x $molid {
for {set i 0} {$i < $N} {incr i} {
lassign [molinfo $x get "{rep $i} {selection $i}"] rep sel
set reps([list $x $i]) [list $rep $sel]
}
}
parray reps
}
proc set_reps {molid prop val {repids "all"}} {
set N [molinfo $x get numreps]
if {$repids == "all"} {
set repids {}
for {set i 0} {$i < $N} {incr i} {lappend repids $i}
}
foreach r $repids {
mol $prop $molid $r {*}[join $val]
}
}