-
Notifications
You must be signed in to change notification settings - Fork 6
/
molwraper.tcl
98 lines (72 loc) · 2.5 KB
/
molwraper.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
## Wrap the mol command with some convenient
## options
proc moll { args } {
set retval -1
set cmd [lindex $args 0]
set newargs [lrange $args 1 end]
switch -- $cmd {
new {
set filename [lindex $newargs 0]
if {[string match "*.data" $filename]} {
## Assume lammps data
catch {topo readlammpsdata\
[file normalize [glob $filename]]} retval
} elseif {[string match "*.xsc" $filename]\
|| [string match "*.xst" $filename]} {
## pbc dimensions
catch {moll -xst\
[file normalize [glob $filename]]} retval
} else {
catch {mol new [file normalize [glob $filename]]\
{*}[lrange $newargs 1 end]} retval
}
}
addfile {
lappend newargs waitfor all
set filename [lindex $newargs 0]
catch {mol addfile [file normalize [glob $filename]]\
{*}[lrange $newargs 1 end]} retval
}
-f {
set retval [moll new [lindex $newargs 0]]
## Check for wildcards..
foreach filename [lrange $newargs 1 end] {
foreach f [striplist [lsort -dictionary [glob $filename]]] {
moll addfile $f
}
}
}
xst -
xsc {
## Load an XSC file, quite a bit more convenient than pbctools
set filename [lindex $newargs 0]
if {[catch {exec tail -1 $filename} data]} {
vmdcon -err "$data"
return -code error -1
}
lassign $data id ax ay az bx by bz cx cy cz
if {[catch {molinfo top set {a b c} [list $ax $by $cz]} msg]} {
vmdcon -err "Can't set box dimensions: $msg"
return -code error -1
}
vmdcon -info [format "Read box dimensions: %8.4f %8.4f %8.4f"\
$ax $by $cz]
## Provide the dimensions as a return value
set retval [list $ax $by $cz]
}
reload {
if {[lsearch -ascii [info procs] reload] < 0} {
return -code 1 "Reload command currently unavailable"
}
set retval [reload {*}$newargs]
}
default {set retval [mol {*}$args]}
}
return $retval
}
## If we passed arguments to load files
if {[expr {$argc != 0}]\
&& [string match "load" [lindex $argv 0]]} {
set newargs [lrange $argv 1 end]
moll {*}$newargs
}