@@ -0,0 +1,2268 @@
+%0A%0Afrom __future__ import absolute_import%0Afrom __future__ import division%0Afrom __future__ import print_function%0A%0Aimport os%0Aimport sys%0Aimport time%0Aimport numpy as np%0Aimport datetime%0Aimport tensorflow as tf%0Afrom matplotlib import pyplot as plt%0A%0A%0Aimport dnn_model%0Asys.path.append(%22/home/scw4750/Documents/chembl/data_files/%22)%0Aimport chembl_input as ci%0A%0A%0Adef virtual_screening_chemdiv(target, g_step, gpu_num=0):%0A  t_0 = time.time()%0A  %0A  # dataset%0A  d = ci.DatasetChemDiv(target)%0A  # batch size%0A  batch_size = 128%0A  # input vec_len%0A  input_vec_len = d.num_features%0A  # keep prob%0A  keep_prob = 0.8%0A  # weight decay%0A  wd = 0.004%0A  # g_step%0A  #g_step = 2236500 %0A%0A  # virtual screen pred file%0A  pred_dir = %22pred_files/%25s%22 %25 target%0A  if not os.path.exists(pred_dir):%0A    os.makedirs(pred_dir)%0A  pred_path = os.path.join(pred_dir, %22vs_chemdiv_%25s_%25d_%254.3f_%254.3e_%25d.pred%22 %25 (target, batch_size, keep_prob, wd, g_step))%0A  predfile = open(pred_path, 'w')%0A  print(%22virtual screen ChemDiv starts at: %25s%5Cn%22 %25 datetime.datetime.now())%0A%0A  # checkpoint file%0A  ckpt_dir = %22ckpt_files/%25s%22 %25 target%0A  ckpt_path = os.path.join(ckpt_dir, '%25d_%254.3f_%254.3e.ckpt' %25 (batch_size, keep_prob, wd))%0A%0A  # screening%0A  with tf.Graph().as_default(), tf.device(%22/gpu: %25d%22 %25 gpu_num):%0A    # the input%0A    input_placeholder = tf.placeholder(tf.float32, shape = (None, input_vec_len))%0A    # the term%0A    base = dnn_model.term(input_placeholder, in_units=input_vec_len, wd=wd, keep_prob=1.0)%0A    # the branches%0A    softmax = dnn_model.branch(target, base, wd=wd, keep_prob=1.0)%0A    # create a saver.%0A    saver = tf.train.Saver(tf.trainable_variables())%0A    # Start screen%0A    config=tf.ConfigProto(allow_soft_placement=True)%0A    config.gpu_options.per_process_gpu_memory_fraction = 0.35%0A%0A%0A    with tf.Session(config=config) as sess:%0A      # Restores variables from checkpoint%0A      saver.restore(sess, ckpt_path + %22-%25d%22 %25 g_step)%0A      while True:%0A        ids, features = d.generate_batch(batch_size)%0A        sm = sess.run(softmax, feed_dict = %7Binput_placeholder: features.toarray()%7D)%0A        for id_, sm_v in zip(ids, sm%5B:, 1%5D):%0A          predfile.write(%22%25s%5Ct%25f%5Cn%22 %25 (id_, sm_v))%0A%0A  print(%22duration: %25.3f%22 %25 (time.time() - t_0))%0A%0A%0Avirtual_screening_chemdiv(target=%22CHEMBL203%22, g_step=2161371, gpu_num=0)%0A%0A%0A%0A%0A%0A%0A

add vs for ChemDiv compound library