Commit d896de6e authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Changes

parent 9941c40f
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
import os
import unittest
import deepchem as dc

class TestContactFeaturizers(unittest.TestCase):
  """Test Contact Fingerprints and Voxelizers."""

  def setUp(self):
    # TODO test more formats for ligand
    current_dir = os.path.dirname(os.path.realpath(__file__))
    self.protein_file = os.path.join(current_dir,
                                     '3ws9_protein_fixer_rdkit.pdb')
    self.ligand_file = os.path.join(current_dir, '3ws9_ligand.sdf')
    self.complex_files = [(self.protein_file, self.ligand_file)]

  def test_contact_fingerprint_shape(self):
    size = 8
    featurizer = dc.feat.ContactCircularFingerprint(size=size)
    features, failures = featurizer.featurize_complexes(
        self.complex_files)
    assert features.shape == (1, 2*size)
    
  def test_contact_voxels_shape(self):
    box_width = 48 
    voxel_width = 2
    voxels_per_edge = box_width/voxel_width
    size = 8
    voxelizer = dc.feat.ContactCircularVoxelizer(box_width=box_width,
      voxel_width=voxel_width, size=size)
    features, failures = voxelizer.featurize_complexes(
        self.complex_files)
    assert features.shape == (1, voxels_per_edge, voxels_per_edge, voxels_per_edge, size)
    
+3 −2
Original line number Diff line number Diff line
@@ -873,8 +873,9 @@ def is_hydrogen_bond(frag1,
    for hydrogen_xyz in hydrogens:
      hydrogen_to_frag2 = frag2_atom_xyz - hydrogen_xyz
      hydrogen_to_frag1 = frag1_atom_xyz - hydrogen_xyz
      if np.abs(180 - angle_between(hydrogen_to_frag1, hydrogen_to_frag2) * 180.0 / np.pi) <= hbond_angle_cutoff:
        return True
      #if np.abs(180 - angle_between(hydrogen_to_frag1, hydrogen_to_frag2) * 180.0 / np.pi) <= hbond_angle_cutoff:
      #  return True
      return is_angle_within_cutoff(hydrgoen_to_frag2, hydrogen_to_frag1, hbond_angle_cutoff)
  return False