From: Fahimeh Baftizadeh (fahimeh.baftizadeh_at_googlemail.com)
Date: Tue Feb 26 2013 - 12:42:59 CST

Hello,

I am trying to load a pdb trajectory and update the occupancy column at
each fram. As far as I know, this is not automatic in VMD and I had to
write a tcl script for that. Here is my script:

mol new {new2.pdb} type pdb waitfor all
 set molid 0
 set i 0
 set pattern {ATOM}
 set fp [open "new2.pdb" r]
 while {[gets $fp line] !=-1} {
   if {[regexp $pattern $line]} {
      set occu($i) [lindex $line 8]
      incr i}
 }
 close $fp

 proc do_refresh_occupancy {args} {
      global occu molid
      set a [molinfo $molid get numatoms]
      set f [molinfo $molid get frame]
      for {set j 0} {$j <= $f} {incr j} {
        for {set i 0} {$i < $a} {incr i} {
          set s [atomselect $molid "index $i"]
          $s set occupancy $occu([expr $a*$j+$i])
        }
      }
 }

 trace variable vmd_frame($molid) w do_refresh_occupancy
 mol colupdate 0 $molid on
 mol scaleminmax 0 $molid 0.0 2.0
 animate goto start
 do_refresh_occupancy

in which I read and load new2.pdb ... saving the occupancy column and then
update it each fram. This is maybe complicated one but I am new to tcl and
didn't know how to make it simpler.
My problem now is that if new2.pdb is large ... then VMD crash and complain
for memory ... (malloc)
Could you please help me to solve this problem?

Thanks
Fahimeh