mol load gro after_full.gro trr test.trr # start the cache for a given molecule proc start_sscache {{molid top}} { global sscache_data if {! [string compare $molid top]} { set molid [molinfo top] } global vmd_frame # set a trace to detect when an animation frame changes trace variable vmd_frame($molid) w sscache return } # remove the trace (need one stop for every start) proc stop_sscache {{molid top}} { if {! [string compare $molid top]} { set molid [molinfo top] } global vmd_frame trace vdelete vmd_frame($molid) w sscache return } # reset the whole secondary structure data cache proc reset_sscache {} { global sscache_data if [info exists sscache_data] { unset sscache_data } return } # when the frame changes, trace calls this function proc sscache {name index op} { # name == vmd_frame # index == molecule id of the newly changed frame # op == w set fil [open he.dat a+] global sscache_data # get the protein atoms set sel [atomselect $index "protein"] $sel frame $name ## get the new frame number # Tcl doesn't yet have it, but VMD does ... set frame [molinfo $index get frame] #set frame $name # see if the ss data exists in the cache if [info exists sscache_data($index,$frame)] { puts $fil nihao $sel set structure $sscache_data($index,$frame) return } puts $fil hello # doesn't exist, so (re)calculate it vmd_calculate_structure $index # save the data for next time set sscache_data($index,$frame) [$sel get structure] puts $fil $name\t$frame\n puts $fil $sscache_data($index,$frame) puts $fil "\n\n" close $fil return } start_sscache set num_steps [molinfo top get numframes] for {set i 0} {$i < $num_steps} {incr i} { sscache $i 0 w reset_sscache } stop_sscache