class_docstr: Adjacency List of neighbors in 3-space
  Neighbors determined by user-defined distance cutoff [in Angstrom].
  
  https://en.wikipedia.org/wiki/Cell_list
  Ref: http://www.cs.cornell.edu/ron/references/1989/Calculations%20of%20a%20List%20of%20Neighbors%20in%20Molecular%20Dynamics%20Si.pdf
  
  Example:
  
  >>> n_atoms = 6
  >>> n_neighbors = 6
  >>> cutoff = 12.0
  >>> boxsize = None
  >>> input_file = "test.sdf"
  >>> tasks = ["energy"]
  >>> featurizers = NeighborListAtomicCoordinates(n_atoms, n_neighbors, cutoff, boxsize)
  >>> featurizer = dc.data.SDFLoader(tasks, smiles_field="smiles", mol_field="mol",
                      featurizer=featurizers)
  >>> dataset = featurizer.featurize(input_file) 
class_docstr_tok: ["Adjacency","List","of","neighbors","in","3-space","Neighbors","determined","by","user-defined","distance","cutoff","[","in","Angstrom","]",".","https",":","\/\/en.wikipedia.org\/wiki\/Cell_list","Ref",":","http",":","\/\/www.cs.cornell.edu\/ron\/references\/1989\/Calculations","%","20of","%","20a","%","20List","%","20of","%","20Neighbors","%","20in","%","20Molecular","%","20Dynamics","%","20Si.pdf","Example",":",">",">",">","n_atoms","=","6",">",">",">","n_neighbors","=","6",">",">",">","cutoff","=","12.0",">",">",">","boxsize","=","None",">",">",">","input_file","=","``","test.sdf","''",">",">",">","tasks","=","[","``","energy","''","]",">",">",">","featurizers","=","NeighborListAtomicCoordinates","(","n_atoms",",","n_neighbors",",","cutoff",",","boxsize",")",">",">",">","featurizer","=","dc.data.SDFLoader","(","tasks",",","smiles_field=","''","smiles","''",",","mol_field=","''","mol","''",",","featurizer=featurizers",")",">",">",">","dataset","=","featurizer.featurize","(","input_file",")"]
docstr: Compute neighbor list.
  
  Parameters
  ----------
  mol: rdkit.Chem.rdchem.mol
    Molecule
docstr_tok: ["Compute","neighbor","list",".","Parameters","--","--","--","--","--","mol",":","rdkit.Chem.rdchem.mol","Molecule"]
code: def _featurize(self, mol):
      """Compute neighbor list.
  
      Parameters
      ----------
      mol: rdkit.Chem.rdchem.mol
        Molecule
  
      """
      N = mol.GetNumAtoms()
      coords = get_coords(mol)
  
      x_bins, y_bins, z_bins = get_cells(coords, self.neighbor_cutoff)
  
      # Associate each atom with cell it belongs to. O(N)
      cell_to_atoms, atom_to_cell = put_atoms_in_cells(
          coords, x_bins, y_bins, z_bins
      )
  
      # Associate each cell with its neighbor cells. Assumes periodic boundary
      # conditions, so does wrapround. O(constant)
      N_x, N_y, N_z = len(x_bins), len(y_bins), len(z_bins)
      neighbor_cell_map = compute_neighbor_cell_map(N_x, N_y, N_z)
  
      # For each atom, loop through all atoms in its cell and neighboring cells.
      # Accept as neighbors only those within threshold. This computation should be
      # O(Nm), where m is the number of atoms within a set of neighboring-cells.
      neighbor_list = {}
      if self.boxsize is not None:
          for atom in range(N):
              cell = atom_to_cell[atom]
              neighbor_cells = neighbor_cell_map[cell]
              neighbor_list[atom] = set()
              for neighbor_cell in neighbor_cells:
                  atoms_in_cell = cell_to_atoms[neighbor_cell]
                  for neighbor_atom in atoms_in_cell:
                      if neighbor_atom == atom:
                          continue
                      dist = np.linalg.norm(
                          coords[atom] - coords[neighbor_atom]
                      )
                      dist = dist - self.boxsize * np.round(
                          dist / self.boxsize
                      )
                      if dist < self.neighbor_cutoff:
                          neighbor_list[atom].add((neighbor_atom, dist))
              # Sort neighbors by distance
              closest_neighbors = sorted(
                  list(neighbor_list[atom]), key=lambda elt: elt[1]
              )
              closest_neighbors = [
                  nbr for (nbr, dist) in closest_neighbors
              ]
              # Pick up to max_num_neighbors
              closest_neighbors = closest_neighbors[
                  : self.max_num_neighbors
              ]
              neighbor_list[atom] = closest_neighbors
      else:
          for atom in range(N):
              cell = atom_to_cell[atom]
              neighbor_cells = neighbor_cell_map[cell]
              neighbor_list[atom] = set()
              for neighbor_cell in neighbor_cells:
                  atoms_in_cell = cell_to_atoms[neighbor_cell]
                  for neighbor_atom in atoms_in_cell:
                      if neighbor_atom == atom:
                          continue
                      dist = np.linalg.norm(
                          coords[atom] - coords[neighbor_atom]
                      )
                      if dist < self.neighbor_cutoff:
                          neighbor_list[atom].add((neighbor_atom, dist))
              closest_neighbors = sorted(
                  list(neighbor_list[atom]), key=lambda elt: elt[1]
              )
              closest_neighbors = [
                  nbr for (nbr, dist) in closest_neighbors
              ]
              closest_neighbors = closest_neighbors[
                  : self.max_num_neighbors
              ]
              neighbor_list[atom] = closest_neighbors
      Z = pad_array(
          np.array([atom.GetAtomicNum() for atom in mol.GetAtoms()]),
          self.max_num_atoms,
      )
      coords = pad_array(coords, (self.max_num_atoms, 3))
      return (coords, neighbor_list, Z)
  
file_path: deepchem/contrib/atomicconv/feat/atomicnet_coordinates.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  import numpy
  from rdkit import Chem
  from deepchem.feat import Featurizer
  from deepchem.feat import ComplexFeaturizer
  from deepchem.utils import pad_array
label_desc: Use image node_id 2 for calling the NeighborListAtomicCoordinates obj's underlying member method code with example usage: obj._featurize(mol) and returns: coords,  neighbor_list,  Z