ccsb-scripps / AutoDock-Vina

AutoDock Vina
http://vina.scripps.edu
Apache License 2.0
562 stars 199 forks source link

Error Conversion array in new numpy version #196

Closed iaggocapitanio1 closed 1 year ago

iaggocapitanio1 commented 1 year ago

For numpy==1.24.3, this error occurs in compute_vina_maps:

image

def compute_vina_maps(self, center, box_size, spacing=0.375, force_even_voxels=False):
    """Compute affinity maps using Vina scoring function.

    Args:
        center (list): center position
        box_size (list): size of the box in Angstrom
        spacing (float): grid spacing (default: 0.375)
        force_even_voxels (boolean): Force the number of voxels (NPTS/NELEMENTS) to be an even number
            (and forcing the number of grid points to be odd) (default: False)

    """
    if len(center) != 3:
        raise ValueError('Error: center of the box needs to be defined by (x, y, z) in Angstrom.')
    elif len(box_size) != 3:
        raise ValueError('Error: box size needs to be defined by (a, b, c) in Angstrom.')
    elif not all([i > 0 for i in box_size]):
        raise ValueError('Error: box dimensions are required to be positive.')
    elif spacing <= 0:
        raise ValueError('Error: spacing should be greater than zero.')

    x, y, z = center
    a, b, c = box_size

    self._vina.compute_vina_maps(x, y, z, a, b, c, spacing, force_even_voxels)

    self._center = center
    self._box_size = box_size
    self._spacing = spacing
    self._voxels = np.ceil(np.array(box_size) / self._spacing).astype(np.int)

    # Necessary step to know if we can write maps or not later
    if force_even_voxels:
        self._voxels[0] += int(self._voxels[0] % 2 == 1)
        self._voxels[1] += int(self._voxels[1] % 2 == 1)
        self._voxels[2] += int(self._voxels[2] % 2 == 1)

The solution is to replace np.int with np.int64.

diogomart commented 1 year ago

Fixed by #167