From: Roni Saiba (
Date: Fri Jun 18 2021 - 21:09:24 CDT

I am trying to write a tcl script to measure percentage helicity at
each frame of a VMD .dcd trajectory. I found the following discussion
on the VMD mailing list:

     "to calculate the secondary structure for a selection at a given
timestep, you should go to that timestep, and the use the command mol
reanalyze top which runs that timestep through stride (among other
things). Once this is done, you can access the secondary structure of
an atomselect object with $sel get structure"

I have tried to implement it as follows,

set outfile [open ./percent_helix.dat w]
set lookup {H G I}
set frame_num [molinfo top get numframes]
set full [atomselect top "name CA"]
set len [llength [$full get resid]]

for {set i 0} {$i < $frame_num} {incr i} {
     set helix 0
     $full frame i
     $full update
     mol reanalyze top
     set struc_string [$full get structure]
     foreach letter $lookup {
         set temp [expr {[llength [split $struc_string $letter]] - 1}]
         incr helix $temp
     set percent [expr {double($helix) / double($len) * 100}]
     puts $outfile "$i\t$percent"
$full delete
close $outfile

However, the output i am the same percentage value at each timestep. I
have figured that the reason behind that is the command mol reanalyze
top is not changing the secondary structure values at each frame. What
should I correct in my script?

Roni Saiba