#VMD --- start of VMD description block #Name: # Trajectory path #Synopsis: # Draws the path of the center of mass of a selection through an animation #Version: # 1.4 #Uses VMD version: # 1.8 #Ease of use: # 2 #Procedures: #
# set water [atomselect top "resid 5243"] # trajectory_path $water scale # # # follow solvation shell around an atom. # set solv [atomselect top "water and exwithin 3.8 of index 199"] # trajectory_path $solv yellow 3 1 #Files: # trajectory_path #Author: # Andrew Dalke <dalke@ks.uiuc.edu> # Axel Kohlmeyer <axel.kohlmeyer@rub.de> (linewidth/update) #\VMD --- end of block proc trajectory_path {selection {color blue} {linewidth 1} {update 0}} { # save the current selection frame number and get the molecule id. set sel_frame [$selection frame] set gr_mol [$selection molindex] # make the list of coordinates set num_frames [molinfo $gr_mol get numframes] set coords {} for {set i 0} {$i < $num_frames} {incr i} { $selection frame $i if {$update} { $selection update } # compute the center of mass and save it on the list lappend coords [measure center $selection weight mass] } ##### now make the graphics and store the respective graphic ids in a list. set gr_list {} set coords [lassign $coords prev] # use the color scale? if {$color == "scale"} { set count 0 incr num_frames set basecolors [colorinfo num] set scalecolors [expr [colorinfo max] - [colorinfo num]] foreach coord $coords { set color [expr $basecolors + int($scalecolors * ($count + 0.0) / ($num_frames + 0.0))] graphics $gr_mol color $color lappend gr_list [graphics $gr_mol line $prev $coord width $linewidth] set prev $coord incr count } } else { # constant color graphics $gr_mol color $color foreach coord $coords { lappend gr_list [graphics $gr_mol line $prev $coord width $linewidth] set prev $coord } } # return the selection to its original state $selection frame $sel_frame if {$update} {$selection update} return $gr_list }