The utilities plugin provides a number of general purpose functions and algorithms. The commands are found in the ::util:: namespace.

Author:

Jan Saam
Institute of Biochemistry
Charite Berlin
Germany
saam@charite.de

Commands

Simple stuff:
::util::deg2rad deg Converts degree to radians.
::util::rad2deg rad Converts radians to degree.
::util::min a b Returns the smaller of two values.
::util::max a b Returns the larger of two values.
::util::roundup val Rounds positive values up and negative values down to the next integer.
::util::rounddown val Rounds positive values down and negative values up to the next integer.
Argument parsing:
::util::getargs arglist tag deflt ?n? Extracts the arguments of an option from a list and returns them. If the option $tag was not found the default value $deflt is returned. The number of arguments that will be returned is specified with $n.
Example:
::util::getargs {-a arg1 -b -c arg2 arg3 -d} "-c" {} 2
--> arg1 arg2
::util::getswitch arglist tag Checks if a certain switch $tag occurs in $taglist.
Example:
::util::getswich {-a 5 -b -c} "-b"
--> 1
List processing:
::util::lmin list Returns the min value of a list of real or integer numbers.
::util::lmax list Returns the max value of a list of real or integer numbers.
::util::ldiff list1 list2 Returns the difference of lists $list1 and $list2, i.e all elements that occur in $list1, but not in $list2.
::util::lnand list1 list2 Returns the opposite of the intersection of two lists, i.e. all elements that occur only in one of both lists.
::util::lintersect list1 list2 Returns the intersection of two lists, i.e. all elements that occur at least once in both lists.
::util::lcontains list1 list2 ?-all? Returns the first sublist of $list2 that is contained in $list1. If -all is specified, then all sublists are returned.
Example:
::util::lcontains {a b c d e f g} {x b c y e f z} -all
--> {b c} {e f}
::util::lrevert list Returns the given list in reverse order.
::util::lincr listname ?val? Increases each element in the list specified by its variable name by $val. (I.e. lincr modifies the original list not a copy.)
::util::sort_alike list1 list2 ?args? Sorts elements in list1 in the same way as list2 would be sorted using the rules given in args. The options in $args are passed on to the underlying TCL lsort command.
Example:
::util::sort_alike {a b c d} {3 2 4 1} -integer
--> c b d a
Rings:
::util::find_rings molid Finds rings in the molecule. For each ring a list of atom indices describing the ring is returned.
::util::unique_rings ringlist Removes rings that enclose other rings from the given list of rings.
::util::compare_rings ring1 ring2 Compare two rings, return the longest common chain.
::util::reorder_ring ring ind1 ?ind2? Return the ring, which is a list of atoms, in a different order, beginning with atom $ind1. If the second atom $ind2 is given then the ring is returned in the according order starting with $ind1 $ind2.
Topology:
::util::clear_bondlist molid Clear VMD's bondlist, no bond will be drawn on the screen anymore.
::util::addbond molid atom0 atom1 If the bond does not yet exist in VMD's bond list then add it.
::util::delbond molid atom0 atom1 Remove specified bond from VMD's bond list.
::util::bondlist ?-molid molid? ?-sel selection? Returns a list of bonded atom pairs. You can specify an atom selection, otherwise all atoms are considered.
::util::anglelist ?-molid molid? ?-sel selection? Returns a list of triples defining bond angles that can be constructed from the existing bonds. You can specify an atom selection, otherwise all atoms are considered.
::util::anglelist ?-molid molid? ?-sel selection? Returns a list of triples defining bond angles that can be constructed from the existing bonds. You can specify an atom selection, otherwise all atoms are considered.
::util::dihedlist ?-molid molid? ?-sel selection? ?-bonds bondlist? Returns a list of quadruples defining dihedral angles that can be constructed from the existing bonds. You can specify an atom selection, otherwise all atoms are considered. If you already have a bondlist as created by ::util::bondlist, you can provide it via -bonds, thus enabling faster computation. If you don't specify -all then only one dihedral angle will be generated per bond.
::util::bondedsel molid atom0 atom1 ?-maxdepth n? ?-all? Returns a list of atoms describing the tree of bonded atoms starting with root $atom0 and continuing towards $atom1. If $atom1 is omitted or empty then the in each direction are followed until $maxdepth is reached, respectively. If -all is specified, for instance in conjunction with -maxdepth 4, then the atoms bonded 1-2 and 1-3 to $atom0 are also returned.
Example:
::util::bondedsel top 8 9 -maxdepth 3
--> Returns all atoms that are bonded exactly in 1-3 distance to atom 8 in the direction of the bond 8--9.