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

Saving (pickling) Topology between sessions #253

Closed
richardjgowers opened this issue Apr 14, 2015 · 4 comments
Closed

Saving (pickling) Topology between sessions #253

richardjgowers opened this issue Apr 14, 2015 · 4 comments

Comments

@richardjgowers
Copy link
Member

It would be nice if we could save the current state of the Universe topology so it could be saved and loaded (possible with another trajectory) again.
Eg something like

u.save_topology('out.pkl')

# Then load a new Universe, which instead of reading a Topology file,
# just unpickles an old topology
u2 = mda.Universe('out.pkl', 'other.traj')

The current way for doing this would be to make a .pdb or something and load the new Universe with that, but that puts you at the mercy of the limits of the given format.

It will also have to work with selections of a Universe too:

ag = u.atoms[:100]

ag.save_topology('out.pkl')
with mda.Writer('out.trr', numatoms=len(ag)) as w:
    for ts in u.trajectory:
        w.write(ag)

unew = mda.Universe('out.pkl', 'out.trr')

Thinking about it, this is kind of a step towards Issue #173 which is the pickling of everything. This should be possible because it sidesteps the problems in Issue #173 which is reinitialising the Reader object.

@orbeckst
Copy link
Member

  1. Why pickle instead of an existing format such as (extended) PSF?
  2. Is this meant to be a "stable" way to save all the topology information or more like a cache (similar to the XTC index) so that we don't have to recompute e.g. guessed bonds?

Somewhat related when reading through your use case: Would it make sense to have a Universe.topology object similar to Universe.trajectory and bundle a lot of the topology-related stuff there?

@richardjgowers
Copy link
Member Author

It's just to avoid having to fit in to an existing format and losing information. Eg maybe PSF doesn't do something I want. There should be a 100% way of moving topology info.

Could definitely do a .topology object and try and tidy the distinction between trajectory and topology.

@richardjgowers
Copy link
Member Author

But having a PSF (and all other formats) writer isn't a terrible idea either.

@richardjgowers
Copy link
Member Author

Closed, go see #643 for more coherent ideas on this :D

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

No branches or pull requests

2 participants