# moleculekit.tools.voxeldescriptors module¶

moleculekit.tools.voxeldescriptors.getCenters(mol=None, buffer=0, boxsize=None, center=None, voxelsize=1)

Get a set of centers for voxelization.

Parameters: mol (Molecule or SmallMol object) – Use this together with the buffer option. buffer (float) – The buffer space to add to the bounding box. This adds zeros to the grid around the protein so that properties which are at the edge of the box can be found in the center of one. Should be usually set to localimagesize/2. boxsize (list) – If this argument is None, the function will calculate the bounding box of the molecule, add to that the buffer argument to expand the bounding box in all dimensions and discretize it into voxels of voxelsize xyz length. In this case, the center argument is ignored. If a list of [x, y, z] lengths is given in Angstrom, it will create a box of those dimensions centered around the center argument. center (list) – The [x, y, z] coordinates of the center. Use this only in combination with the boxsize argument. voxelsize (float) – The voxel size in A
moleculekit.tools.voxeldescriptors.getChannels(mol, aromaticNitrogen=False, version=2, validitychecks=True)
moleculekit.tools.voxeldescriptors.getVoxelDescriptors(mol, boxsize=None, voxelsize=1, buffer=0, center=None, usercenters=None, userchannels=None, usercoords=None, aromaticNitrogen=False, method='C', version=2, validitychecks=True)

Calculate descriptors of atom properties for voxels in a grid bounding the Molecule object.

Parameters: mol (Molecule or SmallMol object) – A molecule boxsize (list) – If this argument is None, the function will calculate the bounding box of the molecule, add to that the buffer argument to expand the bounding box in all dimensions and discretize it into voxels of voxelsize xyz length. In this case, the center argument is ignored. If a list of [x, y, z] lengths is given in Angstrom, it will create a box of those dimensions centered around the center argument. voxelsize (float) – The voxel size in A buffer (float) – The buffer space to add to the bounding box. This adds zeros to the grid around the protein so that properties which are at the edge of the box can be found in the center of one. Should be usually set to localimagesize/2. center (list) – The [x, y, z] coordinates of the center. Use this only in combination with the boxsize argument. usercenters (np.ndarray) – A 2D array specifying the centers of the voxels. If None is given, it will calculate the centers from the above options userchannels (np.ndarray) – A 2D array of size (mol.numAtoms, nchannels) where nchannels is the number of channels we want to have. Each column i then has True (or a float) in the rows of the atoms which belong to channel i and False (or 0) otherwise. Such boolean arrays can be obtained for example by using mol.atomselect. If the array is boolean, each atom will get assigned its VdW radius. If the array is float, these floats will be used as the corresponding atom radii. Make sure the numpy array is of dtype=bool if passing boolean values. If no channels are given, the default (‘hydrophobic’, ‘aromatic’, ‘hbond_acceptor’, ‘hbond_donor’, ‘positive_ionizable’, ‘negative_ionizable’, ‘metal’, ‘occupancies’) channels will be used. usercoords (np.ndarray) – A numpy array containing the molecule coordinates. You can use this with userchannels and usercenters instead of passing a mol object (set it to None if that’s the case). aromaticNitrogen (bool) – Set to True if you want nitrogens in aromatic rings to be added to the aromatic channel. method (str) – Voxel descriptors can be calculated either with our C implementation or CUDA or NUMBA implementations. version (int) – Setting version to 1 will use the old voxelization code which requires you to first obtain pdbqt atom types for the protein. By default it uses version 2 which does the atom typing internally. validitychecks (bool) – Set to False to disable validity checks for atomtyping. This improves performance but only use it if you are sure you have properly prepared your molecules. features (np.ndarray) – A 2D array of size (centers, channels) containing the effect of each channel in the voxel with that center. centers (np.ndarray) – A list of the centers of all boxes N (np.ndarray) – Is returned only when no user centers are passed. It corresponds to the number of centers in each of the x,y,z dimensions

Examples

>>> mol = Molecule('3PTB')
>>> mol.filter('protein')
>>> features, centers, N = getVoxelDescriptors(mol, buffer=8)
>>> # Features can be reshaped to a 4D array (3D for each grid center in xyz, 1D for the properties) like this:
>>> features = features.reshape(N[0], N[1], N[2], features.shape[1])
>>> # The user can provide his own centers
>>> features, centers = getVoxelDescriptors(mol, usercenters=[[0, 0, 0], [16, 24, -5]])

moleculekit.tools.voxeldescriptors.rotateCoordinates(coords, rotations, center)
moleculekit.tools.voxeldescriptors.viewVoxelFeatures(features, centers, nvoxels, voxelsize=None, draw='wireframe')

Visualize in VMD the voxel features produced by getVoxelDescriptors.

Parameters: features (np.ndarray) – An array of (n_centers, n_features) shape containing the voxel features of each center centers (np.ndarray) – An array of (n_centers, 3) shape containing the coordinates of each voxel center nvoxels (np.ndarray) – An array of (3,) shape containing the number of voxels in each X, Y, Z dimension

Example

>>> feats, centers, N = getVoxelDescriptors(mol)
>>> viewVoxelFeatures(feats, centers, N)