Sync from GitHub (preserve manual model files)
Browse files- StreamlitApp/StreamlitApp.py +14 -3
StreamlitApp/StreamlitApp.py
CHANGED
|
@@ -99,6 +99,8 @@ if "analyze_output" not in st.session_state:
|
|
| 99 |
st.session_state.analyze_output = None # (label, conf_display, comp, props, analysis)
|
| 100 |
if "optimize_input" not in st.session_state:
|
| 101 |
st.session_state.optimize_input = "" # last optimize input
|
|
|
|
|
|
|
| 102 |
if "optimize_output" not in st.session_state:
|
| 103 |
st.session_state.optimize_output = None # (orig_seq, orig_conf, improved_seq, improved_conf, history)
|
| 104 |
if "optimize_last_ran_input" not in st.session_state:
|
|
@@ -109,6 +111,8 @@ if "visualize_df" not in st.session_state:
|
|
| 109 |
st.session_state.visualize_df = None
|
| 110 |
if "visualize_peptide_input" not in st.session_state:
|
| 111 |
st.session_state.visualize_peptide_input = ""
|
|
|
|
|
|
|
| 112 |
|
| 113 |
# Sidebar route selector drives top-level page rendering.
|
| 114 |
st.sidebar.header("Navigation")
|
|
@@ -134,11 +138,13 @@ if st.sidebar.button("Clear All Fields"):
|
|
| 134 |
"analyze_input",
|
| 135 |
"analyze_output",
|
| 136 |
"optimize_input",
|
|
|
|
| 137 |
"optimize_output",
|
| 138 |
"optimize_last_ran_input",
|
| 139 |
"visualize_sequences",
|
| 140 |
"visualize_df",
|
| 141 |
"visualize_peptide_input",
|
|
|
|
| 142 |
]
|
| 143 |
for rk in ("_rl_predict", "_rl_analyze", "_rl_optimize", "_rl_tsne"):
|
| 144 |
keys.append(rk)
|
|
@@ -507,10 +513,13 @@ elif page == "Optimize":
|
|
| 507 |
st.header("Peptide Optimizer")
|
| 508 |
|
| 509 |
with st.container(border=True):
|
| 510 |
-
|
| 511 |
"Enter a peptide sequence to optimize:",
|
| 512 |
-
key="
|
| 513 |
)
|
|
|
|
|
|
|
|
|
|
| 514 |
|
| 515 |
warn_opt = sequence_length_warning(seq) if seq else None
|
| 516 |
if warn_opt:
|
|
@@ -588,9 +597,11 @@ elif page == "Visualize":
|
|
| 588 |
with st.container(border=True):
|
| 589 |
st.text_input(
|
| 590 |
"Enter a peptide sequence to visualize:",
|
| 591 |
-
key="
|
| 592 |
)
|
| 593 |
|
|
|
|
|
|
|
| 594 |
seq_viz = (st.session_state.get("visualize_peptide_input") or "").strip()
|
| 595 |
clean_viz = "".join(c for c in seq_viz.upper() if not c.isspace())
|
| 596 |
if clean_viz:
|
|
|
|
| 99 |
st.session_state.analyze_output = None # (label, conf_display, comp, props, analysis)
|
| 100 |
if "optimize_input" not in st.session_state:
|
| 101 |
st.session_state.optimize_input = "" # last optimize input
|
| 102 |
+
if "optimize_input_widget" not in st.session_state:
|
| 103 |
+
st.session_state.optimize_input_widget = st.session_state.optimize_input
|
| 104 |
if "optimize_output" not in st.session_state:
|
| 105 |
st.session_state.optimize_output = None # (orig_seq, orig_conf, improved_seq, improved_conf, history)
|
| 106 |
if "optimize_last_ran_input" not in st.session_state:
|
|
|
|
| 111 |
st.session_state.visualize_df = None
|
| 112 |
if "visualize_peptide_input" not in st.session_state:
|
| 113 |
st.session_state.visualize_peptide_input = ""
|
| 114 |
+
if "visualize_peptide_input_widget" not in st.session_state:
|
| 115 |
+
st.session_state.visualize_peptide_input_widget = st.session_state.visualize_peptide_input
|
| 116 |
|
| 117 |
# Sidebar route selector drives top-level page rendering.
|
| 118 |
st.sidebar.header("Navigation")
|
|
|
|
| 138 |
"analyze_input",
|
| 139 |
"analyze_output",
|
| 140 |
"optimize_input",
|
| 141 |
+
"optimize_input_widget",
|
| 142 |
"optimize_output",
|
| 143 |
"optimize_last_ran_input",
|
| 144 |
"visualize_sequences",
|
| 145 |
"visualize_df",
|
| 146 |
"visualize_peptide_input",
|
| 147 |
+
"visualize_peptide_input_widget",
|
| 148 |
]
|
| 149 |
for rk in ("_rl_predict", "_rl_analyze", "_rl_optimize", "_rl_tsne"):
|
| 150 |
keys.append(rk)
|
|
|
|
| 513 |
st.header("Peptide Optimizer")
|
| 514 |
|
| 515 |
with st.container(border=True):
|
| 516 |
+
st.text_input(
|
| 517 |
"Enter a peptide sequence to optimize:",
|
| 518 |
+
key="optimize_input_widget",
|
| 519 |
)
|
| 520 |
+
seq = (st.session_state.get("optimize_input_widget") or "")
|
| 521 |
+
# Keep a stable saved value across page switches/reruns.
|
| 522 |
+
st.session_state.optimize_input = seq
|
| 523 |
|
| 524 |
warn_opt = sequence_length_warning(seq) if seq else None
|
| 525 |
if warn_opt:
|
|
|
|
| 597 |
with st.container(border=True):
|
| 598 |
st.text_input(
|
| 599 |
"Enter a peptide sequence to visualize:",
|
| 600 |
+
key="visualize_peptide_input_widget",
|
| 601 |
)
|
| 602 |
|
| 603 |
+
# Mirror widget value into a stable saved key for persistence parity with other pages.
|
| 604 |
+
st.session_state.visualize_peptide_input = st.session_state.get("visualize_peptide_input_widget", "")
|
| 605 |
seq_viz = (st.session_state.get("visualize_peptide_input") or "").strip()
|
| 606 |
clean_viz = "".join(c for c in seq_viz.upper() if not c.isspace())
|
| 607 |
if clean_viz:
|