Re: selection of cholesterol molecules

From: Chris Harrison (
Date: Wed Nov 02 2011 - 00:06:35 CDT

At present you can't (as far as I know). However you can use the below
function to find the center of mass and perhaps select the atom closest to that
set of coordinates.

  proc center_of_mass {selection} {
          # some error checking
          if {[$selection num] <= 0} {
                  error "center_of_mass: needs a selection with atoms"
          # set the center of mass to 0
          set com [veczero]
          # set the total mass to 0
          set mass 0
          # [$selection get {x y z}] returns the coordinates {x y z}
          # [$selection get {mass}] returns the masses
          # so the following says "for each pair of {coordinates} and masses,
    # do the computation ..."
          foreach coord [$selection get {x y z}] m [$selection get mass] {
             # sum of the masses
             set mass [expr $mass + $m]
             # sum up the product of mass and coordinate
             set com [vecadd $com [vecscale $m $coord]]
          # and scale by the inverse of the number of atoms
          if {$mass == 0} {
                  error "center_of_mass: total mass is zero"
          # The "1.0" can't be "1", since otherwise integer division is done
          return [vecscale [expr 1.0/$mass] $com]


PS - please don't cross post on the mailing lists. Since the radial distribution tool is a VMD plugin, post to the vmd-l list. Thanks.

Chris Harrison, Ph.D.
Theoretical and Computational Biophysics Group
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave., Urbana, IL 61801                          Voice: 773-570-0329              Fax:   217-244-6078
Swarna M Patra <> writes:
> Date: Wed, 2 Nov 2011 10:24:06 +0530
> From: Swarna M Patra <>
> To:,
> Subject: namd-l: selection of cholesterol molecules
> Dear NAMD/VMD users,
> I am trying to calculate the radial distribution of cholesterol molecules
> around a particular helix . For that I am using the Radial distribution
> given in VMD. for the 1st selection I give "protein and resid 1 to 50" and
> for 2nd selection I give "resname CHL1" that is cholesterol molecule. which
> actually takes each atom of cholesterol and try to see if it is there or
> not. How can I give the 2nd selection to take Center of mass of cholesterol
> molecule not center of mass of each atom.
> please give me some suggestions
> thanks
> swarna

This archive was generated by hypermail 2.1.6 : Mon Dec 31 2012 - 23:20:57 CST