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

Can't load biotite.structure.AtomArray after pickle.dump(...) #349

Closed
entropybit opened this issue Aug 26, 2021 · 1 comment · Fixed by #352
Closed

Can't load biotite.structure.AtomArray after pickle.dump(...) #349

entropybit opened this issue Aug 26, 2021 · 1 comment · Fixed by #352

Comments

@entropybit
Copy link
Contributor

entropybit commented Aug 26, 2021

Hi,

I encountered the problem that it does not seem possible to load a structure once it has been dumped using pickle.
That poses a a problem as you might want to have a AtomArray as a member in some object, for which you then have the exact same problem. A minimum example is :

import biotite.structure.io as strucio
import biotite.database.rcsb as rcsb
from tempfile import gettempdir
import pickle

file = rcsb.fetch("1l2y", "pdb",gettempdir())
struc = strucio.load_structure(file)
pickle.dump(struc, open("struc.pckl", "wb"))
struc2 = pickle.load(open("struc.pckl", "rb"))

which yields

Traceback (most recent call last):
  File "pickle_test.py", line 9, in <module>
    struc2 = pickle.load(open("struc.pckl", "rb"))
  File "/home/mayer/miniconda3_rdkit/lib/python3.7/site-packages/biotite/structure/atoms.py", line 268, in __getattr__
    elif attr in self._annot:
  File "/home/mayer/miniconda3_rdkit/lib/python3.7/site-packages/biotite/structure/atoms.py", line 268, in __getattr__
    elif attr in self._annot:
  File "/home/mayer/miniconda3_rdkit/lib/python3.7/site-packages/biotite/structure/atoms.py", line 268, in __getattr__
    elif attr in self._annot:
  [Previous line repeated 495 more times]
  File "/home/mayer/miniconda3_rdkit/lib/python3.7/site-packages/biotite/structure/atoms.py", line 262, in __getattr__
    if attr == "coord":
RecursionError: maximum recursion depth exceeded in comparison

EDIT:

As I also had problems with distribution of multiple structures via MPI I was going to write a simple test.
However, as I was to lazy to produce a list of structures I just tried to make a list made from copies of the already loaded structure. This yields the same error as above:

import biotite.structure.io as strucio
from tempfile import gettempdir
import biotite.database.rcsb as rcsb
import copy

file = rcsb.fetch("1l2y", "pdb",gettempdir())
struc = strucio.load_structure(file)
strucs = [copy.copy(struc) for i in range(20)]
@padix-key
Copy link
Member

Thank you for the report. I created a PR to fix this issue.

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

Successfully merging a pull request may close this issue.

2 participants