Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -437,7 +437,7 @@ def mutate_smiles(smiles):
|
|
| 437 |
def check_constraints(mol, motifs, limit_aromatic, max_mw):
|
| 438 |
if not mol: return False
|
| 439 |
|
| 440 |
-
if not motifs or motifs == "None":
|
| 441 |
active_motifs = []
|
| 442 |
|
| 443 |
elif isinstance(motifs, str):
|
|
@@ -661,7 +661,7 @@ with gr.Blocks(title="PolymerDesignAI") as demo:
|
|
| 661 |
|
| 662 |
def on_gen_complete(num, mode, view, motifs, limit_aro, max_mw, progress=gr.Progress()):
|
| 663 |
progress(0, desc="🔍 Initializing Generative AI...")
|
| 664 |
-
df,
|
| 665 |
|
| 666 |
def get_dropdown_icon(status_text):
|
| 667 |
if "Excellent" in status_text: return "🟢"
|
|
@@ -677,7 +677,7 @@ with gr.Blocks(title="PolymerDesignAI") as demo:
|
|
| 677 |
|
| 678 |
img, bar = explain_polymer(first_smiles, "Strength")
|
| 679 |
|
| 680 |
-
return (df,
|
| 681 |
gr.Dropdown(choices=dropdown_choices, value=first_choice), df, img, bar)
|
| 682 |
|
| 683 |
def on_refine_start(seed_with_icon, num, mode, view, motifs, limit_aro, max_mw):
|
|
@@ -688,7 +688,7 @@ with gr.Blocks(title="PolymerDesignAI") as demo:
|
|
| 688 |
|
| 689 |
gr.Info(f"Evolving molecules similar to: {seed[:15]}... while respecting constraints")
|
| 690 |
|
| 691 |
-
df,
|
| 692 |
|
| 693 |
# Use your new icon-logic for the refined dropdown results too
|
| 694 |
def get_dropdown_icon(status_text):
|
|
@@ -706,7 +706,7 @@ with gr.Blocks(title="PolymerDesignAI") as demo:
|
|
| 706 |
|
| 707 |
img, bar = explain_polymer(first_smiles, "Strength")
|
| 708 |
|
| 709 |
-
return (df,
|
| 710 |
|
| 711 |
def filter_table(df, mode):
|
| 712 |
if df is None: return None
|
|
@@ -751,7 +751,7 @@ with gr.Blocks(title="PolymerDesignAI") as demo:
|
|
| 751 |
)
|
| 752 |
|
| 753 |
sort_dropdown.change(sort_table, [results_df, sort_dropdown], results_df)
|
| 754 |
-
rank_btn.click(calculate_weighted_rank, [results_df, app_mode, w_strength, w_tg, w_degrad, w_sa], [results_df])
|
| 755 |
refine_btn.click(
|
| 756 |
on_refine_start,
|
| 757 |
[selection_dropdown, num, app_mode, toggle_view, must_have, exclude_aromatic, max_mol_wt],
|
|
|
|
| 437 |
def check_constraints(mol, motifs, limit_aromatic, max_mw):
|
| 438 |
if not mol: return False
|
| 439 |
|
| 440 |
+
if not motifs or motifs == "None" or not motifs:
|
| 441 |
active_motifs = []
|
| 442 |
|
| 443 |
elif isinstance(motifs, str):
|
|
|
|
| 661 |
|
| 662 |
def on_gen_complete(num, mode, view, motifs, limit_aro, max_mw, progress=gr.Progress()):
|
| 663 |
progress(0, desc="🔍 Initializing Generative AI...")
|
| 664 |
+
df, fig = generate_and_screen(num, mode, view, motifs, limit_aro, max_mw)
|
| 665 |
|
| 666 |
def get_dropdown_icon(status_text):
|
| 667 |
if "Excellent" in status_text: return "🟢"
|
|
|
|
| 677 |
|
| 678 |
img, bar = explain_polymer(first_smiles, "Strength")
|
| 679 |
|
| 680 |
+
return (df, fig,
|
| 681 |
gr.Dropdown(choices=dropdown_choices, value=first_choice), df, img, bar)
|
| 682 |
|
| 683 |
def on_refine_start(seed_with_icon, num, mode, view, motifs, limit_aro, max_mw):
|
|
|
|
| 688 |
|
| 689 |
gr.Info(f"Evolving molecules similar to: {seed[:15]}... while respecting constraints")
|
| 690 |
|
| 691 |
+
df, fig = generate_and_screen(num, mode, view, motifs=motifs, limit_aro=limit_aro, max_mw=max_mw, seed=seed)
|
| 692 |
|
| 693 |
# Use your new icon-logic for the refined dropdown results too
|
| 694 |
def get_dropdown_icon(status_text):
|
|
|
|
| 706 |
|
| 707 |
img, bar = explain_polymer(first_smiles, "Strength")
|
| 708 |
|
| 709 |
+
return (df, fig, gr.Dropdown(choices=dropdown_choices, value=first_choice), df, img, bar)
|
| 710 |
|
| 711 |
def filter_table(df, mode):
|
| 712 |
if df is None: return None
|
|
|
|
| 751 |
)
|
| 752 |
|
| 753 |
sort_dropdown.change(sort_table, [results_df, sort_dropdown], results_df)
|
| 754 |
+
rank_btn.click(calculate_weighted_rank, [results_df, app_mode, w_strength, w_tg, w_degrad, w_sa], [results_df, download_csv])
|
| 755 |
refine_btn.click(
|
| 756 |
on_refine_start,
|
| 757 |
[selection_dropdown, num, app_mode, toggle_view, must_have, exclude_aromatic, max_mol_wt],
|