IlPakoZ commited on
Commit
93d5a1f
·
verified ·
1 Parent(s): a285467

Updated app.py and README.md

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +3 -19
README.md CHANGED
@@ -66,7 +66,7 @@ C1=CC=C(C=C1)NC(=O)C2=CC=CC=N2
66
  The model processes each drug–target pair in sequence to predict binding affinity. For visualization, only the final SMILES entry is shown.
67
  If “Remove duplicate SMILES” is enabled, any repeated SMILES strings are filtered out before analysis.
68
  Final results follow the original SMILES order, with adjusted index numbers when duplicates have been removed.
69
- You can only insert **up to 2000 SMILES** at a time in batch processing.
70
 
71
  ### Programmatic usage
72
 
 
66
  The model processes each drug–target pair in sequence to predict binding affinity. For visualization, only the final SMILES entry is shown.
67
  If “Remove duplicate SMILES” is enabled, any repeated SMILES strings are filtered out before analysis.
68
  Final results follow the original SMILES order, with adjusted index numbers when duplicates have been removed.
69
+ You can only insert **up to 2000 SMILES** at a time in batch processing; exceeding lines will be truncated.
70
 
71
  ### Programmatic usage
72
 
app.py CHANGED
@@ -351,9 +351,10 @@ def smiles_preprocessing(drug_smiles, remove_dupl):
351
  kept += 1
352
 
353
  logger.info(f"{kept-len(drugs)} duplicate smiles removed!")
354
- return sorted_drugs
355
- return drugs
356
 
 
 
 
357
  def predict_wrapper(target_seq, drug_smiles, remove_dups):
358
  """Wrapper function for Gradio interface"""
359
  if not target_seq.strip() or not drug_smiles.strip():
@@ -379,16 +380,6 @@ def load_model_wrapper(model_path):
379
  else:
380
  return "Failed to load model. Check the path and files."
381
 
382
- # Add after the other state variables (around line 408)
383
- drug_input_prev_lines = gr.State(value=0)
384
-
385
- def truncate_drug_input(drug_smiles):
386
- """Truncate drug input to maximum 2000 lines"""
387
- lines = drug_smiles.split('\n')
388
- if len(lines) > 2000:
389
- return '\n'.join(lines[:2000])
390
- return drug_smiles
391
-
392
  # Create Gradio interface
393
  with gr.Blocks(title="Drug-Target Interaction Predictor", theme=gr.themes.Soft()) as demo:
394
  gr.HTML("""
@@ -427,13 +418,6 @@ with gr.Blocks(title="Drug-Target Interaction Predictor", theme=gr.themes.Soft()
427
  max_lines=5,
428
  )
429
 
430
- # Auto-truncate to 2000 lines when input changes
431
- drug_input.blur(
432
- fn=truncate_drug_input,
433
- inputs=drug_input,
434
- outputs=drug_input
435
- )
436
-
437
  remove_dups_checkbox = gr.Checkbox(
438
  label="Remove duplicate SMILES",
439
  value=False
 
351
  kept += 1
352
 
353
  logger.info(f"{kept-len(drugs)} duplicate smiles removed!")
 
 
354
 
355
+ drugs = sorted_drugs
356
+ return drugs[:2000]
357
+
358
  def predict_wrapper(target_seq, drug_smiles, remove_dups):
359
  """Wrapper function for Gradio interface"""
360
  if not target_seq.strip() or not drug_smiles.strip():
 
380
  else:
381
  return "Failed to load model. Check the path and files."
382
 
 
 
 
 
 
 
 
 
 
 
383
  # Create Gradio interface
384
  with gr.Blocks(title="Drug-Target Interaction Predictor", theme=gr.themes.Soft()) as demo:
385
  gr.HTML("""
 
418
  max_lines=5,
419
  )
420
 
 
 
 
 
 
 
 
421
  remove_dups_checkbox = gr.Checkbox(
422
  label="Remove duplicate SMILES",
423
  value=False