Commit 4ac84a61 authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Changes

parent 936cf801
Loading
Loading
Loading
Loading
+2 −63
Original line number Diff line number Diff line
@@ -41,69 +41,6 @@ class Docker(object):
        (featurizer is None and scoring_model is not None)):
      raise ValueError(
          "featurizer/scoring_model must both be set or must both be None.")
    self.base_dir = tempfile.mkdtemp()
    self.pose_generator = pose_generator
    self.featurizer = featurizer
    self.scoring_model = scoring_model

  def dock(self,
           molecular_complex,
           centroid=None,
           box_dims=None,
           exhaustiveness=10,
           num_modes=9,
           num_pockets=None,
           out_dir=None,
           use_pose_generator_scores=False):
    """Generic docking function.

    This docking function uses this object's featurizer, pose
    generator, and scoring model to make docking predictions. This
    function is written in generic style so  

    Parameters
    ----------
    molecular_complex: Object
      Some representation of a molecular complex.
    exhaustiveness: int, optional (default 10)
      Tells pose generator how exhaustive it should be with pose
      generation.
    num_modes: int, optional (default 9)
      Tells pose generator how many binding modes it should generate at
      each invocation.
    num_pockets: int, optional (default None)
      If specified, `self.pocket_finder` must be set. Will only
      generate poses for the first `num_pockets` returned by
      `self.pocket_finder`.
    out_dir: str, optional (default None)
      If specified, write generated poses to this directory.
    use_pose_generator_scores: bool, optional (default False)
      If `True`, ask pose generator to generate scores. This cannot be
      `True` if `self.featurizer` and `self.scoring_model` are set
      since those will be used to generate scores in that case. 

    Returns
    -------
    A generator. If `use_pose_generator_scores==True` or
    `self.scoring_model` is set, then will yield tuples
    `(posed_complex, score)`. Else will yield `posed_complex`.
    """
    if self.scoring_model is not None and use_pose_generator_scores:
      raise ValueError(
          "Cannot set use_pose_generator_scores=True when self.scoring_model is set (since both generator scores for complexes)."
      )
    outputs = self.pose_generator.generate_poses(
        molecular_complex,
        centroid=centroid,
        box_dims=box_dims,
        exhaustiveness=exhaustiveness,
        num_modes=num_modes,
        num_pockets=num_pockets,
        out_dir=out_dir,
        generate_scores=use_pose_generator_scores)
    if use_pose_generator_scores:
      complexes, scores = outputs
    else:
      complexes = outputs
    # We know use_pose_generator_scores == False in this case
    if self.scoring_model is not None:
@@ -119,3 +56,5 @@ class Docker(object):
    else:
      for posed_complex in complexes:
        yield posed_complex
      score = np.zeros((1,))
    return (score, (protein_docked, ligand_docked))
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ from deepchem.utils import download_url

logger = logging.getLogger(__name__)

DATA_DIR = deepchem.utils.get_data_dir()


class PoseGenerator(object):
  """A Pose Generator computes low energy conformations for molecular complexes.
+16 −14
Original line number Diff line number Diff line
@@ -185,20 +185,22 @@ class NeighborListComplexAtomicCoordinates(ComplexFeaturizer):
class ComplexNeighborListFragmentAtomicCoordinates(ComplexFeaturizer):
  """This class computes the featurization that corresponds to AtomicConvModel.

  This class computes featurizations needed for AtomicConvModel. Given a
  two molecular structures, it computes a number of useful geometric
  features. In particular, for each molecule and the global complex, it
  computes a coordinates matrix of size (N_atoms, 3) where N_atoms is the
  number of atoms. It also computes a neighbor-list, a dictionary with
  N_atoms elements where neighbor-list[i] is a list of the atoms the i-th
  atom has as neighbors. In addition, it computes a z-matrix for the
  molecule which is an array of shape (N_atoms,) that contains the atomic
  number of that atom.

  Since the featurization computes these three quantities for each of the
  two molecules and the complex, a total of 9 quantities are returned for
  each complex. Note that for efficiency, fragments of the molecules can be
  provided rather than the full molecules themselves.
  This class computes featurizations needed for AtomicConvModel.
  Given a two molecular structures, it computes a number of
  useful geometric features. In particular, for each molecule
  and the global complex, it computes a coordinates matrix of
  size (N_atoms, 3) where N_atoms is the number of atoms. It
  also computes a neighbor-list, a dictionary with N_atoms
  elements where neighbor-list[i] is a list of the atoms the
  i-th atom has as neighbors. In addition, it computes a
  z-matrix for the molecule which is an array of shape
  (N_atoms,) that contains the atomic number of that atom.

  Since the featurization computes these three quantities for
  each of the two molecules and the complex, a total of 9
  quantities are returned for each complex. Note that for
  efficiency, fragments of the molecules can be provided rather
  than the full molecules themselves.
  """

  def __init__(self,
+5 −0
Original line number Diff line number Diff line
@@ -106,6 +106,8 @@ class ComplexFeaturizer(Featurizer):
      List of PDB filenames for molecules.
    protein_pdbs: list
      List of PDB filenames for proteins.
    parallelize: bool
      Use multiprocessing to parallelize

    Returns
    -------
@@ -126,7 +128,10 @@ class ComplexFeaturizer(Featurizer):
    features = []
    failures = []
    for ind, result in enumerate(results):
      if parallelize:
        new_features = result.get()
      else:
        new_features = result
      # Handle loading failures which return None
      if new_features is not None:
        features.append(new_features)
+5 −3
Original line number Diff line number Diff line
@@ -190,10 +190,12 @@ class AtomicConvModel(KerasModel):
    atom_types: list
      List of atoms recognized by model. Atoms are indicated by their
      nuclear numbers.
    radial: list
      TODO: add description
    radial: list of lists of floats
      List of length l, where l is the number of radial filters
      learned. These are the values used at initialization, but
      values are learned afterwards.
    layer_sizes: list
      TODO: add description
      List specifying the number of fully connected layers on top of atomic convolutions.
    learning_rate: float
      Learning rate for the model.
    """
Loading