From: Axel Kohlmeyer (
Date: Wed Jun 18 2008 - 18:43:57 CDT

On Wed, 18 Jun 2008, Anthony Ivetac wrote:

AI> Hi,
AI> I would like to calculate the values of bonds/angles/dihedrals (from a MD
AI> trajectory) using the "label" command. However, instead of calculating these
AI> values for pairs/triplets/quads of atoms in the PDB file, I would like to
AI> calculate them for centers-of-mass.
AI> For example, I calculate the xyz coordinates for two centers-of-mass (com1
AI> and com2) and then want to calculate the 'bond length' between these
AI> coordinates with:
AI> label add Bonds 0/${com1} 0/${com2}
AI> But the label command is expecting com1 and com2 to be atoms, not a list of
AI> xyz coordinates - is there a simple workaround for this, please? e.g. to
AI> convert an xyz into a 'pseudo-atom'?

you can do this, but it has to be a "real" atom as far
as VMD is concerned, as the label command cannot work
directly as you want to do (how should it know how
the coordinates were computed? and update them?).

AI> I would rather use the label command than the mathematical functions I've
AI> seen others use to calculate bonds/angles/dihedrals.

in that case you have to add additional coordinates somewhere.
i would create a second "molecule" that holds just as many
"dummy" coordinates as you need (just construct a simple .xyz
file). then do something like the following:

set m1 [mol new orig.psf]
set m2 [mol new]
animate delete all
mol top $m1
mol addfile mol addfile trajec.dcd waitfor all

set sel1 [atomselect $m1 "protein and resid 10"]
set sel2 [atomselect $m1 "protein and resid 12"]
set d1 [atomselect $m2 "index 0"]
set d2 [atomselect $m2 "index 1"]

set nf [molinfo $m1 get numframes]

for {set i 0} {$i < $nf} {incr i} {
  animate dup $m2 ; # new frame in dummy trajectory
  molinfo set frame $i
  $sel1 frame $i
  $sel2 frame $i
  $d1 frame $i
  $d2 frame $i

  $d1 set {x y z} [measure center $sel1]
  $d2 set {x y z} [measure center $sel2]

# save the data for later use.
animate write psf dummy.psf
animate write dcd com-d1d2.dcd waitfor all

now you can do:

label add Bonds $m2/0 $m2/1

and hack away.

having those special coordinates in a seperate file
gives you the option to seletively turn them on or
off at your whim and it won't mess up other computations.


AI> Thanks!

Axel Kohlmeyer
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
If you make something idiot-proof, the universe creates a better idiot.