Grid

Grid#

The grid submodule generates a ACV point cloud using Python-only functions. While naturally slower than the C++ version implemented in LabelLib it allows for rapid prototyping.

class fretraj.grid.Grid3D(mol_xyzr, attach_xyz, linker_length, linker_width, dye_radii, grid_spacing, simulation_type)[source]#

Class object holding a 3D grid

Parameters:
  • mol_xyzr (ndarray) – array of x-,y-,z-coordinates and VdW radii with a shape [n_atoms, 4]

  • attach_xyz (ndarray) – one-dimensional array of x-,y-,z-coordinates of the attachment point (corresponds to the center of the grid)

  • linker_length (float) – length of the dye linker in Angstrom

  • linker_width (float) – diameter of the dye linker in Angstrom

  • dye_radii (ndarray([3,1])) – array of dye radii in Angstrom with shape [3,1]

  • grid_spacing (float) – spacing between grid points (in A)

Notes

Attributes of the LabelLib class are:
  • discStep : float (the grid spacing)

  • originXYZ : numpy.array (x-/y-/z-coordinate of the grid origin)

  • shape : numpy.array (number of grid points in x-/y-/z-direction)

  • grid : numpy.array (flattened list of grid point values)

static _assignDensity(grid_3d, das_xyzrm, neighbor_list, ijk_atom, distSq, outDistSq, grid_shape)[source]#

Loop through the atom of the biomolecule and reassign those grid value which are within das_xyzrm[m, 3] as they belong to the CV.

Parameters:
  • grid_3d (ndarray) – 3-dimensional array of grid points with a shape given by n_xyz

  • das_xyzrm (ndarray) – array of marked coordinates and padded vdW radii (n_atoms = number of atoms in mdtraj.Trajectory)

  • neighbor_list (list of 2-tuples of ndarray and float) – the tuples contain the ijk indices and the distance from the origin (0,0,0)

  • ijk_atom (array) – ijk grid indices of the atoms of the biomolecule

  • distSq (float) – square of the distance between the grid points to the attachment point

  • outDistSq (float) – square of (halfcubelength + maxVdW_extraClash)

  • grid_shape (array) – number of grid points in x,y and z coordinates

Returns:

ndarray – 3-dimensional array of grid points with a shape given by n_xyz

static _assignRho(grid_3d, mol_xyzr, neighbor_list, ijk_atom, dye_radii_sorted, rhos, distSq, outdistSq, grid_shape)[source]#

Loop through the atoms and radii and reassign the grid values with a number 0 < rho < 1. 0.00: grid point is not compatible with any of the three dye radii (clashes with VdW surface) 0.33: grid point is compatible with the smallest dye radius 0.66: grid point is compatible with the smallest two radii 1.00: grid point is compatible with all three dye radii

Parameters:
  • grid_3d (ndarray) – 3-dimensional array of grid points with a shape given by n_xyz

  • mol_xyzr (ndarray) – array of x-,y-,z-coordinates and VdW radii with a shape [n_atoms, 4]

  • neighbor_list (list of 2-tuples of ndarray and float) – the tuples contain the ijk indices and the distance from the origin (0,0,0)

  • ijk_atom (array) – ijk grid indices of the atoms of the biomolecule

  • dye_radii_sorted (array) – dye radii sorted in ascending order

  • rhos (array) – array of grid values for assignment, for AV3 [0, 0.33, 0.66, 1] and for AV1 [0, 1]

  • distSq (float) – square of the distance between the grid points to the attachment point

  • outdistSq (float) – square of (halfcubelength + maxVdW_extraClash)

  • grid_shape (array) – number of grid points in x,y and z coordinates

static _carve_VdWextraClash(grid_3d, mol_xyzr, neighbor_list, ijk_atom, extraClash, distSq, outDistSq, grid_shape)[source]#

Loop through the atoms and assign -1 to all grid values that are within the atoms VdW radius plus an extraClash value

Parameters:
  • grid_3d (ndarray) – 3-dimensional array of grid points with a shape of 2*adjL+1

  • mol_xyzr (ndarray) – array of x-,y-,z-coordinates and VdW radii with a shape [n_atoms, 4]

  • neighbor_list (list of 2-tuples of ndarray and float) – the tuples contain the ijk indices and the distance from the origin (0,0,0)

  • ijk_atom (array) – ijk grid indices of the atoms of the biomolecule

  • extraClash (float) – clash radius added to the VdW radius

  • distSq (float) – square of the distance between the grid points to the attachment point

  • outDistSq (float) – square of (halfcubelength + maxVdW_extraClash)

  • grid_shape (array) – number of grid points in x,y and z coordinates

static _neighborIdx(maxR, grid_spacing)[source]#

Build a list of neighboring indices to the origin (0,0,0)

Parameters:
  • maxR (float) – radius within which to search for neighbors

  • grid_spacing (float) – spacing between grid points (in A)

Returns:

list of 2-tuples of ndarray and float – the tuples contain the ijk indices and the distance from the origin (0,0,0), e.g. [(1.0,array([-1,0,0]))]

Notes

The neighbor list is built from an origin set at (0,0,0). imaxR defines the number of indices along one axis (i,j or k) to build the index cube. For imaxR=3, first a cube of 7*7*7=343 indices is built (1). This is reduced in a second step to 123 indices that have a distance < imaxR from the origin (2). Finally, they are reduced 74 essential neighbors by the distances in _dist_list (3). (this last reduction speeds up the Dikstra algorithm due to the shorter neighbor list without loosing much accuracy)

static _xyz2idx(xyz, originAdj, grid_spacing, decimals=6)[source]#

Get the ijk grid indices for a set of xyz values

Parameters:
  • xyz (ndarray) – xyz coordinates

  • originAdj (ndarray) – origin of the grid

  • grid_spacing (float) – spacing between grid points (in A)

  • decimals (int) – decimal to round to

Note

Round to n-decimal places (here: 4) before casting to integer

addWeights(das_xyzrm)[source]#

Reassign those grid values which are part of the contact volume.

Parameters:

das_xyzrm (ndarray) – array of xyz coordinates, padded vdW radii and a marking (2.0)

Returns:

ndarray – 3-dimensional array of grid points with a shape given by n_xyz

block_molecule(mol_xyzr, extraClash)[source]#

Block the grid points which are within the VdW radius of any atom of the biomolecule plus an extra clash radius

Parameters:
  • mol_xyzr (ndarray) – array of x-,y-,z-coordinates and VdW radii with a shape [n_atoms, 4]

  • extraClash (float) – clash radius added to the VdW radius

Returns:

ndarray – 3-dimensional array of grid points with a shape of 2*adjL+1

static dijkstra(grid_3d, edges_ess, edges_src, priority_queue, start_ijk)[source]#

Djikstra algorithm with a priority queue

Parameters:
  • grid_3d (ndarray) – 3-dimensional array of grid points with a shape given by n_xyz

  • edges_ess (nb.typed.List of 2-tuples of ndarray and float) – list n essential neighbors from the origin (0,0,0)

  • edges_src (list of 2-tuples of ndarray and float) – nb.typed.List of neighbors in the initialization round of the Dijkstra algorithm

  • priority_queue (list of 2-tuples of ndarray and float) – list with distance and index of origin

  • start_ijk (array) – ijk grid indices of the attachment site

Returns:

ndarray – 3-dimensional array of grid points with a shape given by n_xyz

dijkstra_init(maxR, maxR_source)[source]#

Initialize the Dijkstra search algorithm

Parameters:
  • maxR (float) – radius within to search for neighbors

  • maxRsource (float) – radius within to search for neighbors in the first round of the Dijkstra algorithm

Returns:

ndarray – 3-dimensional array of grid points with a shape of 2*adjL+1

essential_neighbors(idxs, dist_list)[source]#

Reduce the neighbor list to those indices with a distance from the origin featured in dist_list

Parameters:
  • idxs (list of 2-tuples of ndarray and float) – the tuples contain the ijk indices and the distance from the origin (0,0,0)

  • dist_list (list) – list of distances for neighbor search

Notes

If dist_list=sqrt([1, 2, 3, 5, 6]) then the the neighbor list is reduced to 74 neighbors which make up a spherical shape and are a good compromise between neighbor space and time efficiency in the Dijkstra algorithm. The smaller this list the faster the Dijkstra algorithm will run at the expense of the accuracy of the resulting accessible volume (i.e. its “sphericalness”)

excludeConcentricSpheres(mol_xyzr, dye_radii, maxRho)[source]#

Exclude all grid points which are not compatible with any of the dye radii because of clashing with the VdW surface

Parameters:
  • mol_xyzr (ndarray) – array of x-,y-,z-coordinates and VdW radii with a shape [n_atoms, 4]

  • dye_radii (ndarray([3,1])) – array of dye radii in Angstrom with shape [3,1]

  • maxRho (float) – maximum grid value in the free volume

Returns:

ndarray – 3-dimensional array of grid points with a shape given by n_xyz

static make_grid(attach_xyz, linker_length, grid_spacing)[source]#

Build a 3D grid around the attachment point

Parameters:
  • attach_xyz (ndarray) – one-dimensional array of x-,y-,z-coordinates of the attachment point (corresponds to the center of the grid)

  • linker_length (float) – length of the dye linker in Angstrom

  • grid_spacing (float) – spacing between grid points (in A)

Returns:

tuple of ndarray – 3-dimensional array of grid points with a shape of 2*ll_padRound+1, minimum of the grid, origin of the grid

static setAboveTreshold(grid_3d, treshold, new_value)[source]#

Reassign grid values which are above a specified treshold

Parameters:
  • grid_3d (ndarray) – 3-dimensional array of grid points with a shape given by n_xyz

  • treshold (float) – grid values above this treshold are reassigned with new_value

  • new_value (float) – new grid value to be assigned

Returns:

ndarray – 3-dimensional array of grid points with a shape given by n_xyz

sortedNeighborIdx(maxR)[source]#

Build a neighbor list with a maximal extent given by maxR and sorted by increasing distance from the origin

Parameters:

maxR (float) – radius within to search for neighbors

Returns:

list of 2-tuples of ndarray and float – the tuples contain the ijk indices and the distance from the origin (0,0,0)