-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Version: v1.4.79 Windows binaries provided here. Afaik this issue is also reproducible when compiling from current source.
Hello!
When using the python bindings, iterating over a system's molecules with molecules(system) returns molecules with inconsistent types. The following code snippet demonstrates this behavior, using the .pdb file with ID 1GZX (see here):
import BALL as b
f = b.PDBFile("models/1gzx.pdb")
system = b.System()
f.read(system)
for i, molecule in enumerate(b.molecules(system)):
print "molecule {}: {}".format(i, type(molecule))
some_name = system.getProtein(0)
for i, molecule in enumerate(b.molecules(system)):
print "molecule {}: {}".format(i, type(molecule))Output:
molecule 0: <class 'BALLCore.Molecule'>
molecule 0: <class 'BALLCore.Protein'>
Even though we iterate over the same molecules both times, type(molecule) is returned as BALLCore.Molecule the first time and as BALLCore.Protein the second time. As far as I can tell, as soon as a molecule has been accessed and bound to a variable via system.getProtein() at some point, its type will remain BALLCore.Protein. Prior to this, however, Protein-type methods, i.e. getResidue(), are not available when iterating via molecules(system). This problem seems to be specific to the Python bindings and cannot be reproduced in C++ (according to @jeleclaire - my setup only allows me to use the python bindings, so I can't test this myself).
Expected behavior imo would be for a molecule's type to not depend on whether or not it has previously been accessed via system.getProtein(). Personally I feel that having it consistently be BALLCore.Protein (when it actually IS a protein) would be most useful, although that's not my call to make.