Erva Ulusoy commited on
Commit
fb8112c
·
1 Parent(s): abddf21

new function to disable sidebar when generating predictions

Browse files
Files changed (1) hide show
  1. ProtHGT_app.py +16 -2
ProtHGT_app.py CHANGED
@@ -38,9 +38,14 @@ if 'submitted' not in st.session_state:
38
  st.session_state.submitted = False
39
  if 'previous_inputs' not in st.session_state:
40
  st.session_state.previous_inputs = None
 
41
  if 'generating_predictions' not in st.session_state:
42
  st.session_state.generating_predictions = False
43
 
 
 
 
 
44
  with st.expander("🚀 Upcoming Features"):
45
  st.info("""
46
  We are actively working on enhancing ProtHGT application with new capabilities:
@@ -231,6 +236,14 @@ with st.sidebar:
231
  st.warning("⚠️ Due to memory and computational constraints, the maximum number of proteins that can be processed at once is limited to 100 proteins. For larger datasets, please consider running the model locally using our GitHub repository.")
232
 
233
  if selected_proteins and selected_go_category:
 
 
 
 
 
 
 
 
234
  # Create a tuple of current inputs to track changes
235
  current_inputs = (tuple(selected_proteins), selected_go_category)
236
 
@@ -246,8 +259,8 @@ with st.sidebar:
246
  st.session_state.submitted = True
247
 
248
  if st.session_state.submitted:
249
- st.session_state.generating_predictions = True
250
  with st.spinner("Generating predictions..."):
 
251
  # Generate predictions only if not already in session state
252
  if st.session_state.predictions_df is None:
253
 
@@ -296,7 +309,8 @@ if st.session_state.submitted:
296
 
297
  st.session_state.predictions_df = predictions_df
298
 
299
- st.session_state.generating_predictions = False
 
300
  # Display and filter predictions
301
  st.success("Predictions generated successfully!")
302
  st.markdown("### Filter and View Predictions")
 
38
  st.session_state.submitted = False
39
  if 'previous_inputs' not in st.session_state:
40
  st.session_state.previous_inputs = None
41
+ # Initialize session state variables
42
  if 'generating_predictions' not in st.session_state:
43
  st.session_state.generating_predictions = False
44
 
45
+ def set_generating_predictions():
46
+ st.session_state.generating_predictions = True
47
+ st.session_state.submitted = True
48
+
49
  with st.expander("🚀 Upcoming Features"):
50
  st.info("""
51
  We are actively working on enhancing ProtHGT application with new capabilities:
 
236
  st.warning("⚠️ Due to memory and computational constraints, the maximum number of proteins that can be processed at once is limited to 100 proteins. For larger datasets, please consider running the model locally using our GitHub repository.")
237
 
238
  if selected_proteins and selected_go_category:
239
+
240
+ button_disabled = st.session_state.submitted
241
+ if st.button("Generate Predictions",
242
+ disabled=button_disabled,
243
+ key="generate_predictions",
244
+ on_click=set_generating_predictions):
245
+ pass
246
+
247
  # Create a tuple of current inputs to track changes
248
  current_inputs = (tuple(selected_proteins), selected_go_category)
249
 
 
259
  st.session_state.submitted = True
260
 
261
  if st.session_state.submitted:
 
262
  with st.spinner("Generating predictions..."):
263
+
264
  # Generate predictions only if not already in session state
265
  if st.session_state.predictions_df is None:
266
 
 
309
 
310
  st.session_state.predictions_df = predictions_df
311
 
312
+ st.session_state.generating_predictions = False
313
+
314
  # Display and filter predictions
315
  st.success("Predictions generated successfully!")
316
  st.markdown("### Filter and View Predictions")