Commit 9ffcb82a authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Fixing binding pocket tests

parent d54147be
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ def extract_active_site(protein_file, ligand_file, cutoff=4):
  cutoff: int, optional
    The distance in angstroms from the protein pocket to
    consider for featurization.

  Returns
  -------
  A tuple of `(CoordinateBox, np.ndarray)` where the second entry is
  of shape `(N, 3)` with `N` the number of atoms in the active site.
  """
  protein = rdkit_util.load_molecule(
      protein_file, add_hydrogens=False)
+2 −21
Original line number Diff line number Diff line
@@ -37,24 +37,6 @@ class TestBindingPocket(unittest.TestCase):
    for pocket in boxes:
      assert isinstance(pocket, box_utils.CoordinateBox)

  def test_boxes_to_atoms(self):
    """Test that mapping of protein atoms to boxes is meaningful."""
    current_dir = os.path.dirname(os.path.realpath(__file__))
    protein_file = os.path.join(current_dir, "1jld_protein.pdb")
    ligand_file = os.path.join(current_dir, "1jld_ligand.sdf")
    coords = rdkit_util.load_molecule(protein_file)[0]
    boxes = box_utils.get_face_boxes(coords)

    mapping = dc.dock.binding_pocket.boxes_to_atoms(coords, boxes)
    assert isinstance(mapping, dict)
    for box, box_atoms in mapping.items():
      (x_min, x_max), (y_min, y_max), (z_min, z_max) = box.x_range, box.y_range, box.z_range
      for atom_ind in box_atoms:
        atom = coords[atom_ind]
        assert x_min <= atom[0] and atom[0] <= x_max
        assert y_min <= atom[1] and atom[1] <= y_max
        assert z_min <= atom[2] and atom[2] <= z_max

  def test_convex_find_pockets(self):
    """Test that some pockets are filtered out."""
    current_dir = os.path.dirname(os.path.realpath(__file__))
@@ -66,8 +48,7 @@ class TestBindingPocket(unittest.TestCase):

    finder = dc.dock.ConvexHullPocketFinder()
    all_pockets = finder.find_all_pockets(protein_file)
    pockets = finder.find_pockets(
        protein_file, ligand_file)
    pockets = finder.find_pockets(protein_file)
    # Test that every atom in pocket maps exists
    n_protein_atoms = protein.xyz.shape[1]
    for pocket in pockets:
@@ -84,6 +65,6 @@ class TestBindingPocket(unittest.TestCase):
    active_site_box, active_site_coords = (
        dc.dock.binding_pocket.extract_active_site(protein_file, ligand_file))
    finder = dc.dock.ConvexHullPocketFinder()
    pockets = finder.find_pockets(protein_file, ligand_file)
    pockets = finder.find_pockets(protein_file)

    assert len(pockets) > 0
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ def load_molecule(molecule_file,
        str(molecule_file), sanitize=False, removeHs=False)
    from_pdb = True
  else:
    raise ValueError("Unrecognized file type")
    raise ValueError("Unrecognized file type for %s" % str(molecule_file))

  if my_mol is None:
    raise ValueError("Unable to read non None Molecule Object")