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 the fp object #40

Closed
ale94mleon opened this issue Feb 23, 2022 · 2 comments
Closed

Saving the fp object #40

ale94mleon opened this issue Feb 23, 2022 · 2 comments

Comments

@ale94mleon
Copy link

Hello, excelent work!
I am trying to save the fingerprint (becasue the calculation is expensive). I tried with:

import pickle
with open('fp.pkl', 'wb') as file:
    pickle.dump(fp, file)

However, I got the error:

PicklingError: Can't pickle <function _Distance.detect at 0x7f77fa3725e0>: it's not the same object as prolif.interactions._Distance.detect

Any idea why this? Or even better, how to save the fp for future works?

@cbouy
Copy link
Member

cbouy commented Feb 23, 2022

Hi @ale94mleon and thanks!

I'll have a look into exporting the fingerprint object as a pickle in the future.

In the meantime, you can convert the fingerprint to a dataframe, and then export the dataframe to a pickle object :

df = fp.to_dataframe()
df.to_pickle("dataframe.pkl")

Upon converting the fingerprint to a dataframe, you have several options available to include or exclude some info (namely drop_empty and return_atoms). Type help(fp.to_dataframe) to get more details on that.

So to be safe I would suggest saving both fp.to_dataframe() and fp.to_dataframe(return_atoms=True) just in case you need them later.
Both of these dataframes should contain everything you need for subsequent analysis!

Hope that helps,

Cédric

@ale94mleon
Copy link
Author

Thanks for the advice! That is a good idea.

@ale94mleon ale94mleon changed the title Savinf the fp object Saving the fp object Feb 24, 2022
@cbouy cbouy mentioned this issue Jun 5, 2022
7 tasks
cbouy added a commit that referenced this issue Jun 7, 2022
## [1.0.0] - 2022-06-07

### Added
- Support for multiprocessing, enabled by default (Issue #46). The number of processes can
  be controlled through `n_jobs` in `fp.run` and `fp.run_from_iterable`.
- New interaction: van der Waals contact, based on the sum of vdW radii of two atoms.
- Saving/loading the fingerprint object as a pickle with `fp.to_pickle` and
  `Fingerprint.from_pickle` (Issue #40).
### Changed
- Molecule suppliers can now be indexed, reused and can return their length, instead of
  being single-use generators.
### Fixed
- ProLIF can now be installed through pip and conda (Issue #6).
- If no interaction is detected in the first frame, `to_dataframe` will not complain about
  a `KeyError` anymore (Issue #44).
- When creating a `plf.Fingerprint`, unknown interactions will no longer fail silently.
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

2 participants