From: Axel Kohlmeyer (
Date: Wed May 13 2009 - 05:56:32 CDT

On Wed, 2009-05-13 at 12:08 +0200, Thomas Zauner wrote:
> Hello,

hello thomas,

> I am trying to draw shperes with different radii at each atom position, from a
> pdb file. The radius should be proportional to either the value in
> the "Occupancy" or the "Temperatur factor" field in the ATOM line of the pdb
> file. Furthermore it would be optimal if the this radius would be able to
> change if i use a pdb file with multiple MODEL XYZ enrties (frames).

the latter is a bit tricky, as VMD internally assumes that radii (or
charge, type and other properties) don't change over the course of a
trajectory. yet, a lot of this can be "corrected" by some scripting.

> I tried to achieve this by creating a TCL script but was not able to. But my
> skills in this direction are quite limited.

then i suggest to first spend a little time learning some basic tcl.
you can find an excellent tutorial for that at:

as a second step, you should have a closer look at the
scripting examples in the user's guide and then move up
to some more advanced examples. it will take a little extra
effort, but if you plan to use VMD more often, it will pay
off big time.

for your problem in particular, you should load the .pdb file
normally and then type on the vmd console the following script
code (or put it into a text file and run it with "play file.tcl".

set sel [atomselect top all]
$sel set radius [$sel get occupancy]

that should copy the occupancy field (same thing works with beta),
_provided_ the .pdb file is fully conforming to the PDB format rules
(quite a lot are not, since the rules are quirky and derived from
fortran fixed format and work with visualization code more by accident
then by design).
if you change the representation now to VDW, you should see the
different radii.

if you want to have the radii change over the course of a trajectory,
it would be better, if you had the radius information in a separate
file and then read it into a tcl array. you can see an example for
what kind of scripting is needed to do this at:
this example changes the colors based on the charge field. it should
be rather straightforward to change it to adapt it to your case so that
it changes the radius field instead.


> Thank you in andvance.
> THomas

Axel Kohlmeyer
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
If you make something idiot-proof, the universe creates a better idiot.