class_docstr: Featurizes protein-ligand complex using flat features or a 3D grid (in which
  each voxel is described with a vector of features).
class_docstr_tok: ["Featurizes","protein-ligand","complex","using","flat","features","or","a","3D","grid","(","in","which","each","voxel","is","described","with","a","vector","of","features",")","."]
docstr: Computes grid featurization of protein/ligand complex.
  
  Takes as input filenames pdb of the protein, pdb of the ligand.
  
  This function then computes the centroid of the ligand; decrements this
  centroid from the atomic coordinates of protein and ligand atoms, and then
  merges the translated protein and ligand. This combined system/complex is
  then saved.
  
  This function then computes a featurization with scheme specified by the user.
  
  Parameters
  ----------
  complex: Tuple[str, str]
      Filenames for molecule and protein.
docstr_tok: ["Computes","grid","featurization","of","protein\/ligand","complex",".","Takes","as","input","filenames","pdb","of","the","protein",",","pdb","of","the","ligand",".","This","function","then","computes","the","centroid","of","the","ligand",";","decrements","this","centroid","from","the","atomic","coordinates","of","protein","and","ligand","atoms",",","and","then","merges","the","translated","protein","and","ligand",".","This","combined","system\/complex","is","then","saved",".","This","function","then","computes","a","featurization","with","scheme","specified","by","the","user",".","Parameters","--","--","--","--","--","complex",":","Tuple","[","str",",","str","]","Filenames","for","molecule","and","protein","."]
code: def _featurize(self, complex):
      """Computes grid featurization of protein/ligand complex.
  
      Takes as input filenames pdb of the protein, pdb of the ligand.
  
      This function then computes the centroid of the ligand; decrements this
      centroid from the atomic coordinates of protein and ligand atoms, and then
      merges the translated protein and ligand. This combined system/complex is
      then saved.
  
      This function then computes a featurization with scheme specified by the user.
  
      Parameters
      ----------
      complex: Tuple[str, str]
          Filenames for molecule and protein.
      """
      try:
          mol_pdb_file, protein_pdb_file = complex
          time1 = time.time()
  
          protein_xyz, protein_rdk = load_molecule(
              protein_pdb_file,
              calc_charges=True,
              sanitize=self.sanitize,
          )
          time2 = time.time()
          logger.info(
              "TIMING: Loading protein coordinates took %0.3f s"
              % (time2 - time1),
              self.verbose,
          )
          time1 = time.time()
          ligand_xyz, ligand_rdk = load_molecule(
              mol_pdb_file, calc_charges=True, sanitize=self.sanitize
          )
          time2 = time.time()
          logger.info(
              "TIMING: Loading ligand coordinates took %0.3f s"
              % (time2 - time1),
              self.verbose,
          )
      except MoleculeLoadException:
          logger.warning(
              "Some molecules cannot be loaded by Rdkit. Skipping"
          )
          return None
  
      time1 = time.time()
      centroid = compute_centroid(ligand_xyz)
      ligand_xyz = subtract_centroid(ligand_xyz, centroid)
      protein_xyz = subtract_centroid(protein_xyz, centroid)
      time2 = time.time()
      logger.info(
          "TIMING: Centroid processing took %0.3f s" % (time2 - time1),
          self.verbose,
      )
  
      pairwise_distances = compute_pairwise_distances(
          protein_xyz, ligand_xyz
      )
  
      transformed_systems = {}
      transformed_systems[(0, 0)] = [protein_xyz, ligand_xyz]
  
      for i in range(self.nb_rotations):
          rotated_system = rotate_molecules([protein_xyz, ligand_xyz])
          transformed_systems[(i + 1, 0)] = rotated_system
  
      features_dict = {}
      for system_id, (
          protein_xyz,
          ligand_xyz,
      ) in transformed_systems.items():
          feature_arrays = []
          for is_flat, function_name in self.feature_types:
              result = self._compute_feature(
                  function_name,
                  protein_xyz,
                  protein_rdk,
                  ligand_xyz,
                  ligand_rdk,
                  pairwise_distances,
              )
              feature_arrays += result
  
              if self.flatten:
                  features_dict[system_id] = np.concatenate(
                      [
                          feature_array.flatten()
                          for feature_array in feature_arrays
                      ]
                  )
              else:
                  features_dict[system_id] = np.concatenate(
                      feature_arrays, axis=-1
                  )
  
      features = np.concatenate(list(features_dict.values()))
      return features
  
file_path: deepchem/deepchem/feat/complex_featurizers/rdkit_grid_featurizer.py
imports: import logging
  import time
  from deepchem.utils.rdkit_utils import MoleculeLoadException, load_molecule, compute_ecfp_features
  from deepchem.utils.geometry_utils import rotate_molecules, compute_pairwise_distances, compute_centroid, subtract_centroid
  from deepchem.utils.hash_utils import hash_ecfp, hash_ecfp_pair, hash_sybyl, vectorize
  from deepchem.utils.noncovalent_utils import compute_hydrogen_bonds, compute_salt_bridges, compute_binding_pocket_cation_pi
  from deepchem.utils.voxel_utils import convert_atom_to_voxel, convert_atom_pair_to_voxel, voxelize, voxelize_pi_stack
  from deepchem.feat.complex_featurizers.contact_fingerprints import featurize_contacts_ecfp, featurize_binding_pocket_sybyl
  from deepchem.feat.complex_featurizers.splif_fingerprints import featurize_splif
  from deepchem.feat.complex_featurizers.grid_featurizers import compute_charge_dictionary
  import numpy
  from deepchem.feat import ComplexFeaturizer
label_desc: Use image node_id 3 for calling the RdkitGridFeaturizer obj's underlying member method code with example usage: obj._featurize(complex) and returns: features, None