From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Wed Oct 03 2007 - 06:29:53 CDT

On Wed, 3 Oct 2007, Alessio Alexiadis wrote:

AA> Hi everybody

hi alessio,

AA> I want to count the number of H-bonds of water molecules in a carbon nanotube.
AA> I used
AA>
AA> measure hbonds 3.0 30 $selection_O
AA>
AA> which apparently works fine and gives to me the following results
AA>
AA> {1700 1238 2420 1232 443 1985} {563 1700 1238 2420 1232 443} {1701 1239 2422 1234 444 1987}
AA>
AA> each list has 6 elements and actually if I visualize the H-bonds they are six.
AA> Now it comes the stupid question... how can manupulate this list?
AA> I want to count the number of H-bonds since I need to repeat the
AA> measure hbonds command automatically for each frame. All my attempt
AA> ended in something like

you could try:

set nhbnd [llength [lindex [measure hbonds 3.0 30 $selection_O] 0]]

measure hbonds returns a list of three lists. lindex selects the first
of the three and llength counts the number of elements in it and set
assigns the result to nhbnd.

cheers,
   axel.

AA>
AA> invalid command name "{1700 1238 2420 1232 443 1985} {563 1700 1238 2420 1232 443} {1701 1239 2422 1234 444 1987}"
AA>
AA> Thanks guys
AA> Alessio
AA>
AA>
AA> ---------------------------------
AA> Be a better Globetrotter. Get better travel answers from someone who knows.
AA> Yahoo! Answers - Check it out.

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   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.