From: Axel Kohlmeyer (
Date: Thu Oct 01 2009 - 16:12:41 CDT

On Thu, 2009-10-01 at 23:28 +0800, Sun Yicheng wrote:
> Dear VMD user,

dear sun yicheng,
> i have two files : dump.pdb and
> dump.pdb is a regular PDB file and stores the values which i
> want to color atoms in dump.pdb.
> format of :
> 1.02
> 2.04
> 4.04
> 5.02
> 4.23
> .
> .
> i extract these values by awk command, one line contains a value.
> i have gone though the mail list for some suggestions, but my
> script does't work well, color is not changed per frame. it must be
> some error in it that i can not find. i want to know how to load the
> file to "user" field correctly.
> i got this script from mail list, what does " set line "" " means
> in the script?

'set line ""' will set the variable $line to an empty value.
this is standard Tcl syntax. if you don't recognize this, there
is a very high chance, that your problems result from insufficient
knowledge of the Tcl syntax and semantics.

the most likely cause of the problem is, that the script below
expects a specific format of the data file, and that your file
does not follow this. the code below that all data for a single
time step is in a single line of the .data file, whereas your
description looks as if you have the data for (only) one atom
per line. that - of course - cannot work. so either change the
format of the data file or change the loop below to become a
double loop where you first build the list of values for all atoms
and then assign them to the selection.


> -------The script:------------
> set file dump.pdb
> mol new $file
> set numframes [molinfo top get numframes]
> set numatoms [molinfo top get numatoms]
> set sel [atomselect top "all"]
> set fp [open "" r]
> set line ""
> for {set i 0} {$i<$numframes} {incr i} {
> gets $fp line
> $sel frame $i
> puts "setting user data for frame [$sel frame].."
> for {set j 0} {$j<$numatoms} {incr j} {
> animate goto $i
> $sel set user $line
> }
> }
> $sel delete
> 2009-10-01
> ______________________________________________________________________
> Sun Yicheng

Dr. Axel Kohlmeyer 
Institute for Computational Molecular Science
College of Science and Technology
Temple University, Philadelphia PA, USA.