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

Finds all possible binding pockets on protein.

parent e9e11d4d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12,3 +12,4 @@ from deepchem.dock.pose_scoring import GridPoseScorer
from deepchem.dock.docking import Docker
from deepchem.dock.docking import VinaGridRFDocker
from deepchem.dock.docking import VinaGridDNNDocker
from deepchem.dock.binding_pocket import ConvexHullRFPocketFinder
+56 −0
Original line number Diff line number Diff line
"""
Generates protein-ligand docked poses using Autodock Vina.
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals

__author__ = "Bharath Ramsundar"
__copyright__ = "Copyright 2016, Stanford University"
__license__ = "GPL"

import numpy as np
import os
import pybel
import tempfile
from scipy.spatial import ConvexHull
from deepchem.feat import hydrogenate_and_compute_partial_charges
from deepchem.feat.atomic_coordinates import AtomicCoordinates
from deepchem.feat.grid_featurizer import load_molecule
from subprocess import call

class BindingPocketFinder(object):
  """Abstract superclass for binding pocket detection"""

  def find_pockets(self, protein_file):
    """Finds potential binding pockets in proteins."""
    raise NotImplementedError

class ConvexHullRFPocketFinder(BindingPocketFinder):
  """Implementation that uses convex hull of protein to find pockets.

  Based on https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4112621/pdf/1472-6807-14-18.pdf
  """
  def __init__(self):
    pass

  def find_all_pockets(self, protein_file):
    """Find list of binding pockets on protein."""
    # protein_coords is (N, 3) tensor
    coords = load_molecule(protein_file)[0]
    hull = ConvexHull(coords)
    faces = []
    for triangle in hull.simplices:
      # coords[triangle, 0] gives the x-dimension of all triangle points
      # Take transpose to make sure rows correspond to atoms.
      points = np.array(
          [coords[triangle, 0], coords[triangle, 1], coords[triangle, 2]]).T
      x_min, x_max = np.amin(points[:, 0]), np.amax(points[:, 0])
      y_min, y_max = np.amin(points[:, 1]), np.amax(points[:, 1])
      z_min, z_max = np.amin(points[:, 2]), np.amax(points[:, 2])
      faces.append([(x_min, x_max), (y_min, y_max), (z_min, z_max)])
    return faces

  def find_pockets(self, protein_file):
    """Find list of suitable binding pockets on protein."""
    return self.find_all_pockets(protein_file)
+54 −0
Original line number Diff line number Diff line
"""
Tests for Pose Generation 
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals

__author__ = "Bharath Ramsundar"
__copyright__ = "Copyright 2016, Stanford University"
__license__ = "GPL"

import unittest
import tempfile
import os
import shutil
import numpy as np
import deepchem as dc

class TestPoseGeneration(unittest.TestCase):
  """
  Does sanity checks on pose generation. 
  """

  def test_convex_rf_init(self):
    """Tests that ConvexHullRFPocketFinder can be initialized."""
    finder = dc.dock.ConvexHullRFPocketFinder()

  def test_convex_rf_find_all_pockets(self):
    """Tests that binding pockets are detected."""
    current_dir = os.path.dirname(os.path.realpath(__file__))
    protein_file = os.path.join(current_dir, "1jld_protein.pdb")

    finder = dc.dock.ConvexHullRFPocketFinder()

    all_pockets = finder.find_all_pockets(protein_file)
    assert isinstance(all_pockets, list)
    # Pocket is of form [(x_min, x_max), (y_min, y_max), (z_min, z_max)]
    for pocket in all_pockets:
      assert len(pocket) == 3
      assert len(pocket[0]) == 2
      assert len(pocket[1]) == 2
      assert len(pocket[2]) == 2

  def test_convex_rf_find_pockets(self):
    """Test that some pockets are filtered out."""
    current_dir = os.path.dirname(os.path.realpath(__file__))
    protein_file = os.path.join(current_dir, "1jld_protein.pdb")

    finder = dc.dock.ConvexHullRFPocketFinder()

    all_pockets = finder.find_all_pockets(protein_file)
    pockets = finder.find_pockets(protein_file)

    assert len(pockets) < len(all_pockets)