Bug/feature of findContacts

Konrad Hinsen hinsen@cnrs-orleans.fr
Wed, 12 Aug 1998 14:46:07 +0200 (DFT)

> Anyway, I think that this is really undesired behaviour. IMHO, the
> renumbering should be done as soon as an object is added to the respective
> universe... What do you think? Konrad, what's your opinion here? I think we
> should put this in the manual at least.

I certainly agree that the behaviour should be documented; in fact, it's
a perfect topic for the (largely to-be-written) developer's guide.

Here's how it works at the moment:

Philosophy: Atom indices are an implementation detail introduced for
the convenience of the C routines. User code should not use them, nor
ever have to use them, for anything at all. In an object-oriented
system, every object has a well-defined identity, and additional
identity schemes only add confusion.

Design: MMTK has a two-level structure: the top level consists of
Python objects and methods, and the low level of C code working on
C-style arrays. The two levels are linked by the use of NumPy arrays,
whose data space equals the C arrays. At the C level, each atom is
identified by an index into the arrays that store the atom-related
quantities (position, velocity, charge, etc.).

Implementation: Before a C-level routine is called, the
configuration() method for the universe object must be called to
ensure the assignment of indices and the construction of the
configuration array. Without that call, there is no guarantee that a
configuration array exists, and no guarantee that atom indices exist
and/or are correct.

The index assignment and configuration array construction could happen
during the construction of the universe, and this would have some
advantages. But the cost is significant, both in CPU time and in
memory fragmentation (for each atom added, a new configuration array
would have to be allocated). Bookkeeping would also get more
complicated. All that means that I'd rather stick to the current

Finally, a comment about the PDB indices: when a molecule is created
from a PDB file, the PDB index is stored for each atom. When the final
atom indices are assigned, MMTK tries to keep the PDB indices whenever
possible. This makes MMTK more compatible with other programs that use
indices as the only atom identification approach, at least when your
universe corresponds exactly to a PDB file. In more general
situations, you should never make any assumption about PDB indices.
Atoms that are not created from a PDB file don't have one, and in
systems not corresponding exactly to a PDB file the MMTK indices are
different from PDB indices.

Moral: liberate your mind from thinking in terms of indices.  ;-)

Konrad Hinsen                            | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-
Rue Charles Sadron                       | Fax:  +33-
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais