VMD Usage Note


This blog is a record of personalized, commonly used commands in VMD.

#VMD
# Move in one frame
#select the atoms you want
set sel [atomselect top "type Ca"]
# calculate the COM of the atoms
set geoc [measure center $sel]
# calculate the vector you want to move by
set minus_com [vecsub {0 0 0} $geoc]
# select all atoms
set selall [atomselect top all]
#move all atoms
$selall moveby $minus_com

# Note that above commands only work with "one" frame,
# to do this to all frames, using following commands
set sel [atomselect top "type Ca"]
set selall [atomselect top all]
set n [molinfo top get numframes]
for { set i 0 } { $i < $n } { incr i } {
  $sel frame $i
# The frame option sets the frame of the selection, update tells the atom selection to recompute
  $sel update
  $selall frame $i
  $selall update
  set geoc [measure center $sel]
  set minus_com [vecsub {0 0 0} $geoc]
  $selall moveby $minus_com
}

```

Leave a Reply

Your email address will not be published. Required fields are marked *