Sync from GitHub (preserve manual model files)
Browse files- StreamlitApp/StreamlitApp.py +8 -32
- StreamlitApp/utils/peptide_extras.py +21 -11
StreamlitApp/StreamlitApp.py
CHANGED
|
@@ -89,8 +89,6 @@ if "visualize_df" not in st.session_state:
|
|
| 89 |
st.session_state.visualize_df = None
|
| 90 |
if "visualize_peptide_input" not in st.session_state:
|
| 91 |
st.session_state.visualize_peptide_input = ""
|
| 92 |
-
if "viz_peptide_last_computed" not in st.session_state:
|
| 93 |
-
st.session_state.viz_peptide_last_computed = ""
|
| 94 |
|
| 95 |
# SIDEBAR: navigation + global clear
|
| 96 |
st.sidebar.header("Navigation")
|
|
@@ -120,8 +118,6 @@ if st.sidebar.button("Clear All Fields"):
|
|
| 120 |
"visualize_sequences",
|
| 121 |
"visualize_df",
|
| 122 |
"visualize_peptide_input",
|
| 123 |
-
"viz_peptide_last_computed",
|
| 124 |
-
"viz_peptide_auto_run",
|
| 125 |
]
|
| 126 |
for k in keys:
|
| 127 |
if k in st.session_state:
|
|
@@ -361,7 +357,7 @@ elif page == "Analyze":
|
|
| 361 |
"left:50%;"
|
| 362 |
"top:125%;"
|
| 363 |
"transform:translateX(-50%);"
|
| 364 |
-
"max-width:
|
| 365 |
"white-space:normal;"
|
| 366 |
"padding:8px 10px;"
|
| 367 |
"background:rgba(30,30,30,0.95);"
|
|
@@ -588,8 +584,6 @@ elif page == "Visualize Peptide":
|
|
| 588 |
unsafe_allow_html=True,
|
| 589 |
)
|
| 590 |
|
| 591 |
-
st.checkbox("Auto-run when sequence changes", value=False, key="viz_peptide_auto_run")
|
| 592 |
-
|
| 593 |
st.text_input(
|
| 594 |
"Enter a peptide sequence to visualize:",
|
| 595 |
key="visualize_peptide_input",
|
|
@@ -598,23 +592,8 @@ elif page == "Visualize Peptide":
|
|
| 598 |
|
| 599 |
seq_viz = (st.session_state.get("visualize_peptide_input") or "").strip()
|
| 600 |
clean_viz = "".join(c for c in seq_viz.upper() if not c.isspace())
|
| 601 |
-
if
|
| 602 |
-
st.
|
| 603 |
-
else:
|
| 604 |
-
run_viz = st.button("Run visualization", type="primary", key="viz_peptide_run_btn")
|
| 605 |
-
auto_on = bool(st.session_state.get("viz_peptide_auto_run"))
|
| 606 |
-
last_c = st.session_state.get("viz_peptide_last_computed", "") or ""
|
| 607 |
-
need_compute = False
|
| 608 |
-
if run_viz:
|
| 609 |
-
need_compute = True
|
| 610 |
-
elif auto_on and clean_viz != last_c:
|
| 611 |
-
need_compute = True
|
| 612 |
-
|
| 613 |
-
if need_compute:
|
| 614 |
-
with st.spinner("Building 3D view and helical wheel..."):
|
| 615 |
-
st.session_state.viz_peptide_last_computed = clean_viz
|
| 616 |
-
|
| 617 |
-
if clean_viz == st.session_state.get("viz_peptide_last_computed"):
|
| 618 |
warn_len = sequence_length_warning(clean_viz)
|
| 619 |
if warn_len:
|
| 620 |
st.warning(warn_len)
|
|
@@ -655,9 +634,6 @@ elif page == "Visualize Peptide":
|
|
| 655 |
with st.expander("Map · legend", expanded=False):
|
| 656 |
st.markdown(COMPACT_MAP_LEGEND)
|
| 657 |
|
| 658 |
-
elif clean_viz != (st.session_state.get("viz_peptide_last_computed") or ""):
|
| 659 |
-
st.caption("Click **Run visualization** or enable **Auto-run** to update the figures.")
|
| 660 |
-
|
| 661 |
# VISUALIZE t-SNE PAGE
|
| 662 |
elif page == "Visualize t-SNE":
|
| 663 |
st.header("t-SNE Visualizer")
|
|
@@ -760,11 +736,11 @@ elif page == "About":
|
|
| 760 |
PeptideAI is a lightweight Streamlit app for exploring antimicrobial peptide (AMP) sequences.
|
| 761 |
|
| 762 |
It uses a trained neural network to estimate whether a peptide is likely to be antimicrobial, then helps you interpret and improve candidates:
|
| 763 |
-
- **
|
| 764 |
-
- **
|
| 765 |
-
- **
|
| 766 |
-
- **
|
| 767 |
-
- **
|
| 768 |
- **About**: this overview and disclaimer.
|
| 769 |
|
| 770 |
**Disclaimer:** Predictions are model-based heuristics and are **not** a substitute for wet-lab validation or regulatory use.
|
|
|
|
| 89 |
st.session_state.visualize_df = None
|
| 90 |
if "visualize_peptide_input" not in st.session_state:
|
| 91 |
st.session_state.visualize_peptide_input = ""
|
|
|
|
|
|
|
| 92 |
|
| 93 |
# SIDEBAR: navigation + global clear
|
| 94 |
st.sidebar.header("Navigation")
|
|
|
|
| 118 |
"visualize_sequences",
|
| 119 |
"visualize_df",
|
| 120 |
"visualize_peptide_input",
|
|
|
|
|
|
|
| 121 |
]
|
| 122 |
for k in keys:
|
| 123 |
if k in st.session_state:
|
|
|
|
| 357 |
"left:50%;"
|
| 358 |
"top:125%;"
|
| 359 |
"transform:translateX(-50%);"
|
| 360 |
+
"max-width:860px;"
|
| 361 |
"white-space:normal;"
|
| 362 |
"padding:8px 10px;"
|
| 363 |
"background:rgba(30,30,30,0.95);"
|
|
|
|
| 584 |
unsafe_allow_html=True,
|
| 585 |
)
|
| 586 |
|
|
|
|
|
|
|
| 587 |
st.text_input(
|
| 588 |
"Enter a peptide sequence to visualize:",
|
| 589 |
key="visualize_peptide_input",
|
|
|
|
| 592 |
|
| 593 |
seq_viz = (st.session_state.get("visualize_peptide_input") or "").strip()
|
| 594 |
clean_viz = "".join(c for c in seq_viz.upper() if not c.isspace())
|
| 595 |
+
if clean_viz:
|
| 596 |
+
with st.spinner("Building 3D view and helical wheel..."):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
warn_len = sequence_length_warning(clean_viz)
|
| 598 |
if warn_len:
|
| 599 |
st.warning(warn_len)
|
|
|
|
| 634 |
with st.expander("Map · legend", expanded=False):
|
| 635 |
st.markdown(COMPACT_MAP_LEGEND)
|
| 636 |
|
|
|
|
|
|
|
|
|
|
| 637 |
# VISUALIZE t-SNE PAGE
|
| 638 |
elif page == "Visualize t-SNE":
|
| 639 |
st.header("t-SNE Visualizer")
|
|
|
|
| 736 |
PeptideAI is a lightweight Streamlit app for exploring antimicrobial peptide (AMP) sequences.
|
| 737 |
|
| 738 |
It uses a trained neural network to estimate whether a peptide is likely to be antimicrobial, then helps you interpret and improve candidates:
|
| 739 |
+
- **AMP Predictor**: batch predictions from multi-line or FASTA input, length warnings, persisted results, top-candidate highlight, and CSV export.
|
| 740 |
+
- **Peptide Analyzer**: single-sequence numerical and textual analysis — AMP prediction, composition, physicochemical table + radar, similarity to known AMPs, and report export.
|
| 741 |
+
- **Peptide Optimizer**: guided sequence optimization with Enter-to-run input, mutation heatmap, step table, and confidence-vs-step trend.
|
| 742 |
+
- **Peptide Visualizer**: single-sequence 3D approximation + detailed helical wheel + functional region map with consistent residue coloring and concise legend dropdowns.
|
| 743 |
+
- **t-SNE Visualizer**: upload many sequences, embed with the model, run t-SNE, and explore clusters with filters and hover metadata.
|
| 744 |
- **About**: this overview and disclaimer.
|
| 745 |
|
| 746 |
**Disclaimer:** Predictions are model-based heuristics and are **not** a substitute for wet-lab validation or regulatory use.
|
StreamlitApp/utils/peptide_extras.py
CHANGED
|
@@ -173,17 +173,27 @@ Residues are placed using a **100° step** per position (common α-helical wheel
|
|
| 173 |
"""
|
| 174 |
|
| 175 |
# Short blurbs for compact UI expanders (Visualize Peptide page)
|
| 176 |
-
COMPACT_3D_LEGEND: str =
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
)
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
|
| 189 |
def plot_helical_wheel(sequence: str, figsize: Tuple[float, float] = (6.2, 6.2)) -> Any:
|
|
|
|
| 173 |
"""
|
| 174 |
|
| 175 |
# Short blurbs for compact UI expanders (Visualize Peptide page)
|
| 176 |
+
COMPACT_3D_LEGEND: str = """
|
| 177 |
+
**How to read this 3D view**
|
| 178 |
+
- **Blue:** positively charged residues (K, R, H)
|
| 179 |
+
- **Red:** negatively charged residues (D, E)
|
| 180 |
+
- **Green:** hydrophobic residues (A, V, I, L, M, F, W, Y)
|
| 181 |
+
- **Gray:** other / polar residues
|
| 182 |
+
- Backbone is a **helix-like approximation**, not an experimental structure.
|
| 183 |
+
"""
|
| 184 |
+
COMPACT_WHEEL_LEGEND: str = """
|
| 185 |
+
**How to read this helical wheel**
|
| 186 |
+
- **Radial spokes:** residue positions around the helix (100 degrees per residue)
|
| 187 |
+
- **Black connectors:** sequence order (`i -> i+1`) across the wheel
|
| 188 |
+
- **Colored circles:** residue chemistry classes
|
| 189 |
+
- Color mapping matches the 3D view (**blue / red / green / gray**)
|
| 190 |
+
"""
|
| 191 |
+
COMPACT_MAP_LEGEND: str = """
|
| 192 |
+
**How to read this sequence map**
|
| 193 |
+
- Uses the same residue color mapping as 3D and helical wheel
|
| 194 |
+
- Highlights where charged vs hydrophobic residues cluster along the sequence
|
| 195 |
+
- Useful for quick amphipathic pattern checks
|
| 196 |
+
"""
|
| 197 |
|
| 198 |
|
| 199 |
def plot_helical_wheel(sequence: str, figsize: Tuple[float, float] = (6.2, 6.2)) -> Any:
|