From: Pawel Kedzierski (
Date: Thu May 07 2009 - 07:31:25 CDT

On Wed, May 06, 2009 at 07:18:54PM -0400, Axel Kohlmeyer wrote:
> On Wed, 2009-05-06 at 20:50 +0200, Pawel Kedzierski wrote:
> > mol = VMD.atomsel.atomsel('all')
> > vec = (10.0, 0.0, 0.0)
> > mol.moveby(vec)
> >
> > the (top) molecule selected does not move in the OpenGL window.
> pawel,
> it works for me in the tcl script interface of version 1.8.6 and
> with a self-compiled version of the current development sources
> using the native python installation.

I know that it does work in Tcl, and I'm glad it's fixed in new verion,
thanks. For now I came up with a workaround myself, that is, I use
Molecule.reps() to save the representations, remove them from the
molecule prior to moving it, and then I recreate the reps afterwards.

Vorgive me complaints, I do really like VMD and I appreciate the hard
work of the developers. But since I like Python too, I would gladly see
improvements in VMD Python API, and therefore I am reporting odds I've
bumped into ;-)
And there are a couple more:
 - VMD.atomsel.atomsel(text_selection, molid=#)
   always selects from top molecule, ignoring molid.
 - the following code fails (M is a VMD.Molecule.Molecule instance):
     Mreps = M.reps()
     for rep in Mreps: M.addRep(rep)
   The reason is that every rep keeps a back reference to M even after
   M.clearReps(), so one must add e.g.:
     for rep in Mreps: rep.remove_molecule(

Sadly enough, I think the Python interface in VMD has less functionality
and more bugs than the Tcl due to smaller user base. This situation
is probably going to persist as new users or new projects choose the
better supported and documented interface, with many examples around.
For example, I don't see a single Extension plugin written in Python, at
least in the standard VMD package. Although the API was probably there
for years, it may possibly be mostly untested. And even a single example
would be helpful for programming users to start playing with.

But the probably most important obstacle for potential writers of
Python plugins is that the standard Python library and Numeric are
external to VMD, which means that for most users they are likely not
installed at all. The old python version and Numeric required by VMD is
another problem. Numeric is no longer supported and it would be good if
VMD switched to numpy instead. I was biten by bugs in Numeric which are
fixed in numpy. But of course I understand this may be nontrivial, and
if there is small user base indeed, it means low priority, too.


> > However, the coordinates _are_ affected within VMD: if there are any
> > Labels, the Labels do shift according to the translation vector or the
> > transformation applied. Also, when I create a new graphical
> > representation, it appears in the new position. Therefore I tried to
> > do:
> > VMD.molrep.set_autoupdate(molid, rep_num, 1)
> > prior to moving the molecule, but it didn't help, either.
> > As it seem to me, the only way to go is to:
> > 1) delete all representations;
> > 2) move; and then
> > 3) create representation(s) again.
> >
> > Is there a better way to get the graphical representations to move with
> > the molecular coordinates, or have I just discovered a bug?
> >
> > With many thanks for the great program,
> > Pawel
> --
> =======================================================================
> 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.

--> Paweł Kędzierski    Molecular Modelling and Quantum Chemistry Laboratory
                        Institute of Physical and Theoretical Chemistry I-30
                        Wroclaw University of Technology
                        Wroclaw, POLAND