m0ksh commited on
Commit
bc25169
·
verified ·
1 Parent(s): 1ef6392

Sync from GitHub (preserve manual model files)

Browse files
StreamlitApp/StreamlitApp.py CHANGED
@@ -155,7 +155,6 @@ if page == "Predict":
155
  if long_cnt:
156
  st.caption(f"Warning: {long_cnt} sequence(s) unusually long (> 50 aa).")
157
 
158
- st.divider()
159
  run = st.button("Run Prediction")
160
 
161
  if run:
@@ -194,14 +193,11 @@ if page == "Predict":
194
  # If user hasn't just run predictions, show the last saved results (if any)
195
  if st.session_state.predictions and not (run and st.session_state.predict_ran is False):
196
  st.divider()
197
- st.write("**Predictions (last run)**")
198
 
199
  top_candidate = choose_top_candidate(st.session_state.predictions)
200
  if top_candidate:
201
  with st.container():
202
- st.markdown(
203
- "<div style='border:1px solid #e6e6e6; border-radius:0.6rem; padding:0.8rem; background:#fafafa;'>"
204
- , unsafe_allow_html=True)
205
  st.write("**Top Candidate**")
206
  seq = top_candidate.get("Sequence", "")
207
  cc = st.columns([9, 1])
@@ -217,7 +213,6 @@ if page == "Predict":
217
  st.success("Copied to clipboard")
218
  st.write(f"Confidence: **{format_conf_percent(top_candidate['predicted_confidence'], digits=1)}**")
219
  st.write(f"Reason: {top_candidate['Reason']}")
220
- st.markdown("</div>", unsafe_allow_html=True)
221
 
222
  st.divider()
223
  # Keep the original dataframe for full overview/download compatibility.
@@ -474,15 +469,10 @@ elif page == "Optimize":
474
  # Optimization Summary box
475
  summary = optimization_summary(orig_seq, orig_conf, improved_seq, improved_conf)
476
  delta_str = f"{summary['delta_conf_pct']:+.2f}%"
477
- st.markdown(
478
- "<div style='border:1px solid #e6e6e6; border-radius:0.6rem; padding:0.8rem; background:#fafafa;'>",
479
- unsafe_allow_html=True,
480
- )
481
  st.subheader("Optimization Summary")
482
  st.write(f"Confidence: **{delta_str}** (final - original)")
483
  st.write(f"Charge: **{summary['charge_change']}** (orig {summary['charge_orig']}, final {summary['charge_final']})")
484
  st.write(f"Hydrophobicity: **{summary['hydro_change']}** (orig {summary['hydro_orig']}, final {summary['hydro_final']})")
485
- st.markdown("</div>", unsafe_allow_html=True)
486
 
487
  st.divider()
488
  # Mutation Heatmap
 
155
  if long_cnt:
156
  st.caption(f"Warning: {long_cnt} sequence(s) unusually long (> 50 aa).")
157
 
 
158
  run = st.button("Run Prediction")
159
 
160
  if run:
 
193
  # If user hasn't just run predictions, show the last saved results (if any)
194
  if st.session_state.predictions and not (run and st.session_state.predict_ran is False):
195
  st.divider()
 
196
 
197
  top_candidate = choose_top_candidate(st.session_state.predictions)
198
  if top_candidate:
199
  with st.container():
200
+
 
 
201
  st.write("**Top Candidate**")
202
  seq = top_candidate.get("Sequence", "")
203
  cc = st.columns([9, 1])
 
213
  st.success("Copied to clipboard")
214
  st.write(f"Confidence: **{format_conf_percent(top_candidate['predicted_confidence'], digits=1)}**")
215
  st.write(f"Reason: {top_candidate['Reason']}")
 
216
 
217
  st.divider()
218
  # Keep the original dataframe for full overview/download compatibility.
 
469
  # Optimization Summary box
470
  summary = optimization_summary(orig_seq, orig_conf, improved_seq, improved_conf)
471
  delta_str = f"{summary['delta_conf_pct']:+.2f}%"
 
 
 
 
472
  st.subheader("Optimization Summary")
473
  st.write(f"Confidence: **{delta_str}** (final - original)")
474
  st.write(f"Charge: **{summary['charge_change']}** (orig {summary['charge_orig']}, final {summary['charge_final']})")
475
  st.write(f"Hydrophobicity: **{summary['hydro_change']}** (orig {summary['hydro_orig']}, final {summary['hydro_final']})")
 
476
 
477
  st.divider()
478
  # Mutation Heatmap
StreamlitApp/utils/ui_helpers.py CHANGED
@@ -198,6 +198,10 @@ def sequence_health_label(conf_prob: float, charge: float, hydro_fraction: float
198
  """
199
  Returns: (label, color_css)
200
  """
 
 
 
 
201
  if conf_prob > 0.75 and charge >= 2 and 0.3 <= hydro_fraction <= 0.6:
202
  return "Strong AMP candidate", "#2ca02c"
203
  if conf_prob > 0.5:
 
198
  """
199
  Returns: (label, color_css)
200
  """
201
+ # If the model is *extremely* confident, treat it as strong regardless
202
+ # of charge/hydrophobicity heuristics (prevents "moderate" at ~99%).
203
+ if conf_prob >= 0.9:
204
+ return "Strong AMP candidate", "#2ca02c"
205
  if conf_prob > 0.75 and charge >= 2 and 0.3 <= hydro_fraction <= 0.6:
206
  return "Strong AMP candidate", "#2ca02c"
207
  if conf_prob > 0.5: