Commit 3e40b41c authored by leswing's avatar leswing
Browse files

CR Comments

parent 8fc59143
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ import numpy as np
from rdkit import Chem
from deepchem.feat import Featurizer
from deepchem.feat import ComplexFeaturizer
from deepchem.utils import pad_array
from deepchem.utils import pad_array, rdkit_util


def get_cells(coords, neighbor_cutoff):
@@ -153,9 +153,8 @@ def compute_neighbor_cell_map(N_x, N_y, N_z):
        for x_offset in offsets:
          for y_offset in offsets:
            for z_offset in offsets:
              neighbors.append(
                  ((x_ind + x_offset) % N_x, (y_ind + y_offset) % N_y,
                   (z_ind + z_offset) % N_z))
              neighbors.append(((x_ind + x_offset) % N_x, (y_ind + y_offset) %
                                N_y, (z_ind + z_offset) % N_z))
        neighbor_cell_map[(x_ind, y_ind, z_ind)] = neighbors
  return neighbor_cell_map

@@ -245,6 +244,7 @@ class NeighborListAtomicCoordinates(Featurizer):
      Molecule

    """
    print(mol)
    N = mol.GetNumAtoms()
    coords = get_coords(mol)

@@ -394,10 +394,10 @@ class ComplexNeighborListFragmentAtomicCoordinates(ComplexFeaturizer):
    """

    try:
      frag1_mol = Chem.MolFromPDBFile(
          frag1_pdb_file, sanitize=False, removeHs=False)
      frag2_mol = Chem.MolFromPDBFile(
          frag2_pdb_file, sanitize=False, removeHs=False)
      frag1_mol = rdkit_util.load_molecule(
          frag1_pdb_file, add_hydrogens=False, calc_charges=False)[1]
      frag2_mol = rdkit_util.load_molecule(
          frag2_pdb_file, add_hydrogens=False, calc_charges=False)[1]
    except:
      frag1_mol = None
      frag2_mol = None
+2 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ from __future__ import unicode_literals
import os
import numpy as np
import pandas as pd
import deepchem as dc
from atomicnet_coordinates import ComplexNeighborListFragmentAtomicCoordinates


@@ -68,7 +69,7 @@ def compute_pdbbind_coordinate_features(complex_featurizer, pdb_subdir,
  """

  protein_file = os.path.join(pdb_subdir, "%s_pocket.pdb" % pdb_code)
  ligand_file = os.path.join(pdb_subdir, "%s_ligand.pdb" % pdb_code)
  ligand_file = os.path.join(pdb_subdir, "%s_ligand.sdf" % pdb_code)
  feature = complex_featurizer._featurize_complex(
      str(ligand_file), str(protein_file))
  return feature
+5 −8
Original line number Diff line number Diff line
@@ -9,16 +9,13 @@ __license__ = "MIT"
import os
import sys
from subprocess import call
from atomicnet_pdbbind_datasets import load_core_pdbbind_fragment_coordinates
from atomicnet_pdbbind_datasets import load_pdbbind_fragment_coordinates

call([
    "wget",
    "wget", "-c",
    "http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/pdbbind_v2015.tar.gz"
])
call(["tar", "-xvzf", "pdbbind_v2015.tar.gz"])

# This could be done with openbabel in python
call(["convert_ligand_sdf_to_pdb.sh"])
# call(["tar", "-xvzf", "pdbbind_v2015.tar.gz"])

base_dir = os.getcwd()
pdbbind_dir = os.path.join(base_dir, "v2015")
@@ -30,6 +27,6 @@ complex_num_atoms = 908
max_num_neighbors = 8
neighbor_cutoff = 12.0

pdbbind_tasks, dataset, transformers = load_core_pdbbind_fragment_coordinates(
pdbbind_tasks, dataset, transformers = load_pdbbind_fragment_coordinates(
    frag1_num_atoms, frag2_num_atoms, complex_num_atoms, max_num_neighbors,
    neighbor_cutoff, pdbbind_dir, base_dir, datafile)
    neighbor_cutoff, pdbbind_dir, base_dir, str(datafile))
+1 −1
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ class Weights(Input):
    super(Weights, self).__init__(**kwargs)


class LossLayer(Layer):
class L2LossLayer(Layer):

  def __init__(self, **kwargs):
    super(LossLayer, self).__init__(**kwargs)
+13 −21
Original line number Diff line number Diff line
@@ -231,17 +231,17 @@ class TensorGraph(Model):
      retval = np.expand_dims(from_one_hot(retval, axis=2), axis=1)
    return retval

  def predict_proba_on_generator(self, generator, sess=None):
  def predict_proba_on_generator(self, generator):
    """
    TODO: Do transformers even make sense here?

    Returns:
      y_pred: numpy ndarray of shape (n_samples, n_classes*n_tasks)
    """
    if not self.built:
      self.build()

    def predict_closure(session):
    with self._get_tf("Graph").as_default():
      with tf.Session() as sess:
        saver = tf.train.Saver()
        saver.restore(sess, self.last_checkpoint)
        out_tensors = [x.out_tensor for x in self.outputs]
        results = []
        for feed_dict in generator:
@@ -249,20 +249,12 @@ class TensorGraph(Model):
              self.layers[k.name].out_tensor: v
              for k, v in six.iteritems(feed_dict)
          }
        result = np.array(session.run(out_tensors, feed_dict=feed_dict))
          result = np.array(sess.run(out_tensors, feed_dict=feed_dict))
          if len(result.shape) == 3:
            result = np.transpose(result, axes=[1, 0, 2])
          results.append(result)
        return np.concatenate(results, axis=0)

    if sess is not None:
      return predict_closure(sess)
    with self._get_tf("Graph").as_default():
      with tf.Session() as sess:
        saver = tf.train.Saver()
        saver.restore(sess, self.last_checkpoint)
        return predict_closure(sess)

  def predict_on_batch(self, X, sess=None):
    """Generates output predictions for the input samples,
      processing the samples in a batched way.
Loading