Commit 3a70ec24 authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Changes

parent 2f144e31
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
"""
Tests that FASTA files can be loaded.
"""
__author__ = "Bharath Ramsundar"
__license__ = "MIT"

import os
import unittest

+12 −19
Original line number Diff line number Diff line
@@ -366,13 +366,6 @@ class HydrogenBondCounter(ComplexFeaturizer):
      self.angle_cutoffs = HBOND_ANGLE_CUTOFFS
    else:
      self.angle_cutoffs = angle_cutoffs
    ######################################################
    print("constructor")
    print("self.distance_bins")
    print(self.distance_bins)
    print("self.angle_cutoffs")
    print(self.angle_cutoffs)
    ######################################################

  def _featurize_complex(self, mol, protein):
    """
@@ -387,12 +380,6 @@ class HydrogenBondCounter(ComplexFeaturizer):
    """
    (lig_xyz, lig_rdk), (prot_xyz, prot_rdk) = mol, protein
    distances = compute_pairwise_distances(prot_xyz, lig_xyz)
    ######################################################
    print("self.distance_bins")
    print(self.distance_bins)
    print("self.angle_cutoffs")
    print(self.angle_cutoffs)
    ######################################################
    return [
        vectorize(
            hash_ecfp_pair, feature_list=hbond_list, size=1)
@@ -416,8 +403,8 @@ class HydrogenBondVoxelizer(ComplexFeaturizer):
  the number of hydrogen bonds at each voxel.
  """
  def __init__(self, 
               distance_cutoff=5.0,
               angle_cutoff=40.0,
               distance_bins=None,
               angle_cutoffs=None,
               box_width=16.0,
               voxel_width=1.0):
    """
@@ -438,8 +425,14 @@ class HydrogenBondVoxelizer(ComplexFeaturizer):
    voxel_width: float, optional (default 1.0)
      Size of a 3D voxel in a grid.
    """
    self.distance_cutoff = distance_cutoff
    self.angle_cutoff = angle_cutoff
    if distance_bins is None:
      self.distance_bins = HBOND_DIST_BINS
    else:
      self.distance_bins = distance_bins
    if angle_cutoffs is None:
      self.angle_cutoffs = HBOND_ANGLE_CUTOFFS
    else:
      self.angle_cutoffs = angle_cutoffs
    self.box_width = box_width
    self.voxel_width = voxel_width
    self.voxels_per_edge = int(self.box_width / self.voxel_width)
@@ -467,6 +460,6 @@ class HydrogenBondVoxelizer(ComplexFeaturizer):
            feature_list=hbond_list,
            nb_channel=1) for hbond_list in compute_hydrogen_bonds(
                prot_xyz, prot_rdk, lig_xyz, lig_rdk,
                distances, self.distance_cutoff,
                self.angle_cutoff)
                distances, self.distance_bins,
                self.angle_cutoffs)
    ]
+6 −20
Original line number Diff line number Diff line
@@ -124,8 +124,6 @@ class RdkitGridFeaturizer(ComplexFeaturizer):
    pi_stack_angle_cutoff: 30.0
    cation_pi_dist_cutoff: 6.5
    cation_pi_angle_cutoff: 30.0
    hbond_dist_cutoff: 4.0
    hbond_angle_cutoff: 40.0
    """

    # list of features that require sanitized molecules
@@ -149,8 +147,6 @@ class RdkitGridFeaturizer(ComplexFeaturizer):
        'pi_stack_angle_cutoff': 30.0,
        'cation_pi_dist_cutoff': 6.5,
        'cation_pi_angle_cutoff': 30.0,
        'hbond_dist_cutoff': 4.0,
        'hbond_angle_cutoff': 40.0
    }

    # update with cutoffs specified by the user
@@ -215,11 +211,11 @@ class RdkitGridFeaturizer(ComplexFeaturizer):
        box_width=self.box_width,
        voxel_width=self.voxel_width)
    self.hbond_counter = HydrogenBondCounter(
        distance_bins=self.cutoffs['hbond_dist_cutoff'],
        angle_cutoffs=self.cutoffs['hbond_angle_cutoff'])
        distance_bins=self.cutoffs['hbond_dist_bins'],
        angle_cutoffs=self.cutoffs['hbond_angle_cutoffs'])
    self.hbond_voxelizer = HydrogenBondVoxelizer(
        distance_cutoff=self.cutoffs['hbond_dist_cutoff'],
        angle_cutoff=self.cutoffs['hbond_angle_cutoff'],
        distance_bins=self.cutoffs['hbond_dist_bins'],
        angle_cutoffs=self.cutoffs['hbond_angle_cutoffs'],
        box_width=self.box_width,
        voxel_width=self.voxel_width)

@@ -291,18 +287,8 @@ class RdkitGridFeaturizer(ComplexFeaturizer):
      return self.charge_voxelizer._featurize_complex((lig_xyz, lig_rdk),
                                                      (prot_xyz, prot_rdk))
    if feature_name == 'hbond':
      return [
          voxelize(
              convert_atom_pair_to_voxel,
              self.voxels_per_edge,
              self.box_width,
              self.voxel_width,
              None, (prot_xyz, lig_xyz),
              feature_list=hbond_list,
              nb_channel=1) for hbond_list in compute_hydrogen_bonds(
                  prot_xyz, prot_rdk, lig_xyz, lig_rdk, distances, self.cutoffs[
                      'hbond_dist_bins'], self.cutoffs['hbond_angle_cutoffs'])
      ]
      return self.hbond_voxelizer._featurize_complex((lig_xyz, lig_rdk),
                                                     (prot_xyz, prot_rdk))
    if feature_name == 'pi_stack':
      return self.pi_stack_voxelizer._featurize_complex((lig_xyz, lig_rdk),
                                                        (prot_xyz, prot_rdk))
+0 −3
Original line number Diff line number Diff line
@@ -331,14 +331,11 @@ class TestRdkitGridFeaturizer(unittest.TestCase):
        'hbond_angle_cutoffs': [5, 90],
        'splif_contact_bins': [(0, 3.5), (3.5, 6.0)],
        'ecfp_cutoff': 5.0,
        #'sybyl_cutoff': 3.0,
        'salt_bridges_cutoff': 4.0,
        'pi_stack_dist_cutoff': 5.0,
        'pi_stack_angle_cutoff': 15.0,
        'cation_pi_dist_cutoff': 5.5,
        'cation_pi_angle_cutoff': 20.0,
        'hbond_dist_cutoff': 4.0,
        'hbond_angle_cutoff': 40.0
    }
    rgf_featurizer = rgf.RdkitGridFeaturizer(**custom_cutoffs)
    self.assertEqual(rgf_featurizer.cutoffs, custom_cutoffs)
+17 −19
Original line number Diff line number Diff line
@@ -185,8 +185,6 @@ def load_pdbbind(reload=True,

  pdbbind_tasks = ["-logKd/Ki"]

  deepchem_dir = deepchem.utils.get_data_dir()

  if data_dir == None:
    data_dir = DEFAULT_DIR
  data_folder = os.path.join(data_dir, "pdbbind", "v2015")
Loading