Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Type of molecules retrieved with molecules() is inconsistent. #657

Open
cglasner opened this issue May 17, 2020 · 0 comments
Open

Comments

@cglasner
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant