next up previous contents index
Next: Combining atom selections Up: Atom selections in Python Previous: An atom selection example   Contents   Index

Changing the selection and the frame

When molecule in VMD contains multiple coordinate sets (frames), atom selections must know which frame they are referring to, especially when you make distance-based atom selections or request time-varying properties like the x, y, or z coordinates. By default, atom selections in Python use frame 0, i.e. the first coordinate set. You can specify the frame either when you create the atom selection, or by using the frame() method. Passing no arguments to frame() returns the current value of the frame.

>>> load('psf','alanin.psf','dcd','alanin.dcd')

>>> resid5 = AtomSel('resid 5', frame=50)
>>> resid5.frame()
50
>>> resid5.frame(22)
>>> resid5.frame()
22

In a similar way, you can change the selected atoms of an atom selection object using the select() operation. Continuing with the previous example:

>>> resid5
resid 5
>>> resid5.select('resid 7')
>>> resid5
resid 7
>>>



vmd@ks.uiuc.edu