docstr: Builds the computational graph for Vina.
docstr_tok: ["Builds","the","computational","graph","for","Vina","."]
code: def construct_graph(
      self,
      N_protein=1000,
      N_ligand=100,
      M=50,
      ndim=3,
      k=5,
      nbr_cutoff=6,
  ):
      """Builds the computational graph for Vina."""
      graph = tf.Graph()
      with graph.as_default():
          n_cells = 64
          # TODO(rbharath): Make this handle minibatches
          protein_coords_placeholder = tf.placeholder(
              tf.float32, shape=(N_protein, 3)
          )
          ligand_coords_placeholder = tf.placeholder(
              tf.float32, shape=(N_ligand, 3)
          )
          protein_Z_placeholder = tf.placeholder(
              tf.int32, shape=(N_protein,)
          )
          ligand_Z_placeholder = tf.placeholder(
              tf.int32, shape=(N_ligand,)
          )
  
          label_placeholder = tf.placeholder(tf.float32, shape=(1,))
  
          # Shape (N_protein+N_ligand, 3)
          coords = tf.concat(
              [protein_coords_placeholder, ligand_coords_placeholder],
              axis=0,
          )
          # Shape (N_protein+N_ligand,)
          Z = tf.concat(
              [protein_Z_placeholder, ligand_Z_placeholder], axis=0
          )
  
          # Shape (N_protein+N_ligand, M)
          nbr_list = compute_neighbor_list(
              coords,
              nbr_cutoff,
              N_protein + N_ligand,
              M,
              n_cells,
              ndim=ndim,
              k=k,
          )
          all_interactions = []
  
          # Shape (N_protein+N_ligand,)
          all_atoms = tf.range(N_protein + N_ligand)
          # Shape (N_protein+N_ligand, 3)
          atom_coords = tf.gather(coords, all_atoms)
          # Shape (N_protein+N_ligand,)
          atom_Z = tf.gather(Z, all_atoms)
          # Shape (N_protein+N_ligand, M)
          nbrs = tf.squeeze(tf.gather(nbr_list, all_atoms))
          # Shape (N_protein+N_ligand, M, 3)
          nbr_coords = tf.gather(coords, nbrs)
  
          # Shape (N_protein+N_ligand, M)
          nbr_Z = tf.gather(Z, nbrs)
          # Shape (N_protein+N_ligand, M, 3)
          tiled_atom_coords = tf.tile(
              tf.reshape(atom_coords, (N_protein + N_ligand, 1, 3)),
              (1, M, 1),
          )
  
          # Shape (N_protein+N_ligand, M)
          dists = tf.reduce_sum(
              (tiled_atom_coords - nbr_coords) ** 2, axis=2
          )
  
          # TODO(rbharath): Need to subtract out Van-der-Waals radii from dists
  
          # Shape (N_protein+N_ligand, M)
          atom_interactions = h(dists)
          # Shape (N_protein+N_ligand, M)
          cutoff_interactions = cutoff(dists, atom_interactions)
  
          # TODO(rbharath): Use RDKit to compute number of rotatable bonds in ligand.
          Nrot = 1
  
          # TODO(rbharath): Autodock Vina only uses protein-ligand interactions in
          # computing free-energy. This implementation currently uses all interaction
          # terms. Not sure if this makes a difference.
  
          # Shape (N_protein+N_ligand, M)
          free_energy = g(cutoff_interactions, Nrot)
          # Shape () -- scalar
          energy = tf.reduce_sum(atom_interactions)
  
          loss = 0.5 * (energy - label_placeholder) ** 2
  
      return (
          graph,
          (
              protein_coords_placeholder,
              protein_Z_placeholder,
              ligand_coords_placeholder,
              ligand_Z_placeholder,
          ),
          label_placeholder,
      )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  import warnings
  import numpy
  import tensorflow
  from deepchem.models import Model
  from deepchem.nn import model_ops
  import deepchem.utils.rdkit_util
label_desc: Use image node_id 3 for calling the VinaModel obj's underlying member method code with example usage: obj.construct_graph(N_protein, N_ligand, M, ndim, k, nbr_cutoff) and returns: graph,  protein_coords_placeholder,  protein_Z_placeholder,  ligand_coords_placeholder,  ligand_Z_placeholder,  label_placeholder