Tuesday, January 29, 2013

Manipulating dihedral angles in VMD

VMD's scripting interface is quite powerful. It has a trans bond command which gives the transformation matrix required to achieve desired dihedral rotation. If you want to edit the dihedral 1-2-3-4 (i.e. rotate around bond 2-3), then you first select the set of atoms on which the transformation is to be applied; 1,2,5,6,7,8,9 in this case. To this selection you apply the transformation;

$moveselection move [trans bond [lindex [$a1 get {x y z}] 0] [lindex [$a2 get {x y z}] 0] 10 deg]

trans bond expects only the atom indices. The value 10 indicates the magnitude and sign of change to the dihedral 1-2-3-4. deg says the change should be in degrees and not radians. To get a nice picture of rotation around a bond use this script:

set movesel [atomselect top "index 1 2 5 6 7 8 9"]
for {set i 0} {$i <360 } {incr i 10}

{
$movesel move [trans bond [lindex [$a1 get {x y z}] 0] [lindex [$a2 get {x y z}] 0] 10 deg]
render TachyonInternal [format "rotate%03d.tga" $i]
}

4 comments:

  1. What is variable $a1 and $a2? which atom make this variable?

    ReplyDelete
    Replies
    1. set a1 [atomselect top "index 2"]
      set a2 [atomselect top "index 3"]

      Delete
  2. same for me, very useful, thanks Pavan!

    ReplyDelete