Anton Bushuiev commited on
Commit
538375d
·
1 Parent(s): c09238a

Add simple logging

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -1,7 +1,9 @@
 
1
  import copy
2
  import random
3
  import tempfile
4
  import shutil
 
5
  from pathlib import Path
6
  from functools import partial
7
 
@@ -26,6 +28,12 @@ from ppiformer.utils.torch import fill_diagonal
26
  from ppiformer.definitions import PPIFORMER_WEIGHTS_DIR
27
 
28
 
 
 
 
 
 
 
29
  random.seed(0)
30
 
31
 
@@ -248,6 +256,8 @@ def plot_3dmol(pdb_path, ppi_path, mut, attn, attn_mut_id=0):
248
 
249
 
250
  def predict(models, temp_dir, *inputs):
 
 
251
  # Process input
252
  pdb_path, ppi_path, muts, muts_on_interface = process_inputs(inputs, temp_dir)
253
 
@@ -269,9 +279,12 @@ def predict(models, temp_dir, *inputs):
269
  muts_not_on_interface += f'... (and {n_muts_not_on_interface - n_muts_warn} more)'
270
  gr.Warning((
271
  f"{muts_not_on_interface} {'is' if n_muts_not_on_interface == 1 else 'are'} not on the interface. "
272
- "The model will predict the effects of mutations on the whole complex. "
273
- "This may lead to less accurate predictions."
 
274
  ))
 
 
275
 
276
  # Predict using interface for mutations on the interface and using the whole complex otherwise
277
  attn_ppi, attn_pdb = None, None
@@ -300,6 +313,7 @@ def predict(models, temp_dir, *inputs):
300
  attn_pdb = attn
301
  df['Attn Id'] = df['Attn Id'].astype(int)
302
 
 
303
 
304
  # Round ddG values
305
  df['ddG [kcal/mol]'] = df['ddG [kcal/mol]'].round(3)
@@ -343,6 +357,8 @@ def predict(models, temp_dir, *inputs):
343
  col_count=(2, 'fixed'),
344
  )
345
 
 
 
346
  return df, path, dropdown, dropdown_choices_to_plot_args
347
 
348
 
 
1
+ import sys
2
  import copy
3
  import random
4
  import tempfile
5
  import shutil
6
+ import logging
7
  from pathlib import Path
8
  from functools import partial
9
 
 
28
  from ppiformer.definitions import PPIFORMER_WEIGHTS_DIR
29
 
30
 
31
+ logging.basicConfig(
32
+ level=logging.INFO,
33
+ format='%(asctime)s - %(levelname)s - %(message)s',
34
+ handlers=[logging.StreamHandler(sys.stdout)]
35
+ )
36
+
37
  random.seed(0)
38
 
39
 
 
256
 
257
 
258
  def predict(models, temp_dir, *inputs):
259
+ logging.info('Starting prediction')
260
+
261
  # Process input
262
  pdb_path, ppi_path, muts, muts_on_interface = process_inputs(inputs, temp_dir)
263
 
 
279
  muts_not_on_interface += f'... (and {n_muts_not_on_interface - n_muts_warn} more)'
280
  gr.Warning((
281
  f"{muts_not_on_interface} {'is' if n_muts_not_on_interface == 1 else 'are'} not on the interface. "
282
+ f"The model will predict the effect{'s' if n_muts_not_on_interface > 1 else ''} of "
283
+ f"mutation{'s' if n_muts_not_on_interface > 1 else ''} on the whole complex. "
284
+ f"This may lead to less accurate predictions."
285
  ))
286
+
287
+ logging.info('Inputs processed')
288
 
289
  # Predict using interface for mutations on the interface and using the whole complex otherwise
290
  attn_ppi, attn_pdb = None, None
 
313
  attn_pdb = attn
314
  df['Attn Id'] = df['Attn Id'].astype(int)
315
 
316
+ logging.info('Predictions made')
317
 
318
  # Round ddG values
319
  df['ddG [kcal/mol]'] = df['ddG [kcal/mol]'].round(3)
 
357
  col_count=(2, 'fixed'),
358
  )
359
 
360
+ logging.info('Prediction results prepared')
361
+
362
  return df, path, dropdown, dropdown_choices_to_plot_args
363
 
364