jiaxianustc commited on
Commit
b412584
·
1 Parent(s): 231a101
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -9,6 +9,7 @@ warnings.filterwarnings("ignore")
9
 
10
  model_dir = './workdir/gradio/'
11
  checkpoint = 'checkpointbest_valid_1.ckp'
 
12
 
13
  def get_config(model_dir):
14
  # get config
@@ -108,21 +109,23 @@ def get_models(model_config, model_dir, checkpoint):
108
  return model
109
 
110
  def mbp_scoring(ligand_path, protein_path):
111
- model_config = get_config(model_dir)
112
  data_example = get_data(model_config, ligand_path, protein_path)
113
- model = get_models(model_config, model_dir, checkpoint)
114
  _, (affinity_pred_IC50, affinity_pred_K), _ = model(data_example, ASRP=False)
115
  return affinity_pred_IC50.item(), affinity_pred_K.item()
116
 
117
 
118
  def test(ligand, protein):
 
 
 
119
  try:
120
  IC50, K = mbp_scoring(ligand.name, protein.name)
121
- # print(f'ligand file name: {os.path.basename(ligand)},'
122
- # f' protein file name: {os.path.basename(protein)},'
123
- # f' IC50: {IC50}, K: {K}')
124
  return '{:.2f}'.format(IC50), '{:.2f}'.format(K)
125
  except Exception as e:
 
126
  return e, e
127
 
128
  with gr.Blocks() as demo:
@@ -134,4 +137,8 @@ with gr.Blocks() as demo:
134
  submit_btn = gr.Button("Submit")
135
  submit_btn.click(fn=test, inputs=[ligand, protein], outputs=[IC50, K], api_name="MBP_Scoring")
136
 
137
- demo.launch(share=True)
 
 
 
 
 
9
 
10
  model_dir = './workdir/gradio/'
11
  checkpoint = 'checkpointbest_valid_1.ckp'
12
+ total_num = 0
13
 
14
  def get_config(model_dir):
15
  # get config
 
109
  return model
110
 
111
  def mbp_scoring(ligand_path, protein_path):
 
112
  data_example = get_data(model_config, ligand_path, protein_path)
 
113
  _, (affinity_pred_IC50, affinity_pred_K), _ = model(data_example, ASRP=False)
114
  return affinity_pred_IC50.item(), affinity_pred_K.item()
115
 
116
 
117
  def test(ligand, protein):
118
+ global total_num
119
+ total_num = total_num + 1
120
+ print(f'total num: {total_num}')
121
  try:
122
  IC50, K = mbp_scoring(ligand.name, protein.name)
123
+ print(f'ligand file name: {os.path.basename(ligand.name)},'
124
+ f' protein file name: {os.path.basename(protein.name)},'
125
+ f' IC50: {IC50}, K: {K}')
126
  return '{:.2f}'.format(IC50), '{:.2f}'.format(K)
127
  except Exception as e:
128
+ # print(e)
129
  return e, e
130
 
131
  with gr.Blocks() as demo:
 
137
  submit_btn = gr.Button("Submit")
138
  submit_btn.click(fn=test, inputs=[ligand, protein], outputs=[IC50, K], api_name="MBP_Scoring")
139
 
140
+ model_config = get_config(model_dir)
141
+ data_example = get_data(model_config, './workdir/gradio/1a0q_ligand.sdf', './workdir/gradio/1a0q_protein.pdb')
142
+ model = get_models(model_config, model_dir, checkpoint)
143
+
144
+ demo.launch(share=False)