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

Is it possible to store in data or somewhere else files or paths to them? #80

Open
sperezconesa opened this issue Jan 6, 2020 · 8 comments

Comments

@sperezconesa
Copy link

Hello,
I am considering using MDSynthesis in my projects but I was wondering a couple of things:
-Is it possible to store in simulations files (or maybe only their paths) like you do dataframes, for example a dssp.pdf file that I make from a trajectory.
-Can you store any arbitrary object in a sim, like a dictionary, a list or even a function?
Best regards and thank you,
Sergio

@orbeckst
Copy link
Contributor

@sperezconesa development on MDSynthesis has largely halted – @dotsdl is not really maintaining it anymore. Instead we suggest to used datreant directly.

MDSynthesis was a good idea but it turned out to be more useful and easier to maintain to just abstract it more and make it datreant. @dotsdl can say more.

@kain88-de
Copy link
Contributor

You can save everything that you can serialize in a sim object. In the end, they are just files on your hard drive. You can write objects to disk using the pickle module like this.

with open(treant['some_file_name'], 'w') as fh:
    pickle.dump(some_dic, fh)

and reading

with open(treant['some_file_name']) as fh:
    some_dic = pickle.load(fh)

With pickle functions should be possible to serialize too.

@sperezconesa
Copy link
Author

Thanks for the help! I will try to get into datreant. Is datreant still mantained?

@kain88-de
Copy link
Contributor

kain88-de commented Jan 23, 2020 via email

orbeckst added a commit that referenced this issue Jan 23, 2020
Development has stopped. See #67 and #80. 
Encourage new users to choose datreant.
@sperezconesa
Copy link
Author

I am having problems pickling universe objects. How was this done in MDSynthesis, so I can do it in datreant?

@orbeckst
Copy link
Contributor

orbeckst commented Feb 3, 2020

Pickling universes is a hard problem, see MDAnalysis/mdanalysis#878 (and a whole bunch of somewhat related issues) so it does not work yet in MDAnalysis. (But we would really like it to work...)

In MDS we just stored the topology and trajectory and made Simulation.universe a managed attribute that would do a return mda.Universe(self.topology, self.trajectory) every time it was accessed. This worked (if you didn't care about any changes to the universe) but also was a bit problematic when people used in their code sim.universe instead of assigning it to a variableu = sim.universe because the former would load the universe every time, with poor performance. (I suppose, we really should have made it a function Simulation.get_Universe() to make clear that it does something expensive... poor UI choice.)

But the bottom line is that your best approach at the moment is to store in your Treant Universe.filename and Universe.trajectory.filename and then rebuild the Universe when you need it.

Feel free to ask questions on the MDAnalysis user list, people might also be able to give advice.

@orbeckst
Copy link
Contributor

orbeckst commented Feb 3, 2020

The lines in the MDS code

@property
def universe(self):
"""The universe of the Sim.
Universes are interfaces to raw simulation data, with stored selections
for this universe directly available via ``Sim.selections``.
Setting this to a :class:`MDAnalysis.Universe` will set that as the
universe definition for this Sim. Setting to ``None`` will remove
the universe definition entirely.
"""
_args = self.universedef._args
if _args != self._args:
self._args = _args
kwargs = self.universedef.kwargs
if _args is None:
self._universe = None
else:
self._universe = mda.Universe(*_args, **kwargs)
return self._universe

@sperezconesa
Copy link
Author

Ok, that clarifies things!
Thanks, I am really liking the library :)

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

3 participants