From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Wed Jan 14 2009 - 11:11:45 CST

On Wed, 14 Jan 2009, Michael Kreim wrote:

MK> Hello,

hello michael,

MK> My problem is, that I don't understand how I can update the frame of an
MK> atomselection.
MK> I tried
MK> atoms.frame(fi)
MK> but this results in the error message:
MK> Traceback (most recent call last):
MK> File "VMD", line 73, in ?
MK> TypeError: 'int' object is not callable
MK>
MK> Do I have misunderstood the syntax or is my concept wrong? Maybe I have
MK> to create a new atomselection in each step of the second loop?
MK>
MK> Thanks for your help.
MK>
MK> With best regards,
MK>
MK> Michael Kreim
MK>
MK>
MK> My python script (using VMD 1.8.6 on linux with python 2.2.3):
MK>
MK> from molecule import *
MK> from atomsel import *
MK> import sys
MK>
MK> psffile = 'md.psf'
MK> dcds = 'md.'
MK> asel = 'water and name OH2 and z>15'
MK> firstdcd = 1
MK> lastdcd = 35
MK>
MK> for dcdi in range(firstdcd,lastdcd+1):
MK>
MK> mid=load('psf',psffile)
MK> dcdfile=dcds+str(dcdi)+'.dcd'
MK> read(molid=mid, type='dcd', filename=dcdfile, beg=0, end=-1, skip=1,

here is an error. this should be:
read(mid, 'dcd', dcdfile, ....)
check the documentation.

MK> waitfor=-1)
MK>
MK> N=numframes(mid)
MK>
MK> atoms=atomsel(asel,molid=mid)
MK>
MK> for fi in range(0,N):
MK>
MK> atoms.frame(fi)

have a look at the documentation again:

frame is a data object and not a method,
so to move to another frame, you have to do.

         atoms.frame=fi

one more remark:
whether you need to run the update() method
depends on the selection text. if it is not
using any "area" operator (e.g. 'within')
then the update can be avoided and this can
speed up the analysis significantly.

MK> atoms.update()

cheers,
   axel.

MK>
MK> # start the analysis
MK>
MK>
MK> delete(mid)
MK>
MK> sys.exit()
MK>

-- 
=======================================================================
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.