Spaces:
Sleeping
Sleeping
Fixed implementation
Browse files
app.py
CHANGED
|
@@ -334,23 +334,25 @@ class DrugTargetInteractionApp:
|
|
| 334 |
# Initialize the app
|
| 335 |
app = DrugTargetInteractionApp()
|
| 336 |
|
| 337 |
-
def smiles_preprocessing(drug_smiles):
|
| 338 |
drugs = drug_smiles.strip().split("\n")
|
| 339 |
|
| 340 |
# Remove molecule duplicates in O(n) while preserving the order
|
| 341 |
-
|
| 342 |
-
|
|
|
|
| 343 |
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
|
| 352 |
-
|
| 353 |
-
|
|
|
|
| 354 |
|
| 355 |
def predict_wrapper(target_seq, drug_smiles, remove_dups):
|
| 356 |
"""Wrapper function for Gradio interface"""
|
|
@@ -417,7 +419,7 @@ with gr.Blocks(title="Drug-Target Interaction Predictor", theme=gr.themes.Soft()
|
|
| 417 |
|
| 418 |
remove_dups_checkbox = gr.Checkbox(
|
| 419 |
label="Remove duplicate SMILES",
|
| 420 |
-
value=
|
| 421 |
)
|
| 422 |
|
| 423 |
with gr.Row():
|
|
|
|
| 334 |
# Initialize the app
|
| 335 |
app = DrugTargetInteractionApp()
|
| 336 |
|
| 337 |
+
def smiles_preprocessing(drug_smiles, remove_dupl):
|
| 338 |
drugs = drug_smiles.strip().split("\n")
|
| 339 |
|
| 340 |
# Remove molecule duplicates in O(n) while preserving the order
|
| 341 |
+
if remove_dupl:
|
| 342 |
+
seen = set()
|
| 343 |
+
sorted_drugs = []
|
| 344 |
|
| 345 |
+
kept = 0
|
| 346 |
+
|
| 347 |
+
for x in drugs:
|
| 348 |
+
if x not in seen:
|
| 349 |
+
seen.add(x)
|
| 350 |
+
sorted_drugs.append(x)
|
| 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"""
|
|
|
|
| 419 |
|
| 420 |
remove_dups_checkbox = gr.Checkbox(
|
| 421 |
label="Remove duplicate SMILES",
|
| 422 |
+
value=False
|
| 423 |
)
|
| 424 |
|
| 425 |
with gr.Row():
|