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

numpy bool call throws exception for identification of hydration sites #16

Open
blakemertz opened this issue May 17, 2024 · 1 comment

Comments

@blakemertz
Copy link

blakemertz commented May 17, 2024

I went to use the provided python script at the end of the example workflow and it threw an exception. Code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from gridData import Grid
from waterkit.analysis import HydrationSites
from waterkit.analysis import blur_map

gO = Grid("gist-gO.dx")
esw = Grid('gist-Esw-dens.dx')
eww = Grid('gist-Eww-dens.dx')
tst = Grid('gist-dTStrans-dens.dx')
tso = Grid('gist-dTSorient-dens.dx')
dg = (esw + 2 * eww) - (tst + tso)

# Identification of hydration site positions using gO
hs = HydrationSites(gridsize=0.5, water_radius=1.4, min_water_distance=2.5, min_density=2.0)
hydration_sites = hs.find(gO) # can pass "gist-gO.dx" directly also

# Get Gaussian smoothed energy for hydration sites only
dg_energy = hs.hydration_sites_energy(dg, water_radius=1.4)
hs.export_to_pdb("hydration_sites_dG_smoothed.pdb", hydration_sites, dg_energy)

# ... or get the whole Gaussian smoothed map
map_smooth = blur_map(dg, radius=1.4)
map_smooth.export("gist-dG-dens_smoothed.dx")

Error when trying to run:

python hydration.py 
Traceback (most recent call last):
  File "/media/bak11/modulus/MDH/waterkit/mdh-258-xtal/hydration.py", line 17, in <module>
    hydration_sites = hs.find(gO) # can pass "gist-gO.dx" directly also
                      ^^^^^^^^^^^
  File "/media/bak11/binaries/git/waterkit/waterkit/analysis/hydration_sites.py", line 117, in find
    hydration_sites, self._isocontour, self._cluster_ids = _hydration_sites(xyz, values, self._min_density,
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/bak11/binaries/git/waterkit/waterkit/analysis/hydration_sites.py", line 26, in _hydration_sites
    mask = np.ones(tmp_values.shape, dtype=np.bool)
                                           ^^^^^^^
  File "/media/bak11/binaries/miniconda3/envs/waterkit/lib/python3.11/site-packages/numpy/__init__.py", line 324, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?

I changed np.bool to bool in line 26 of hydration_sites.py and it completed successfully.

@jeeberhardt
Copy link
Contributor

Thanks for your feedback @blakemertz, this is now fixed!

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