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

when generating predictions disable the sidebar

Browse files
Files changed (1) hide show
  1. ProtHGT_app.py +24 -14
ProtHGT_app.py CHANGED
@@ -38,6 +38,8 @@ 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
 
42
  with st.expander("🚀 Upcoming Features"):
43
  st.info("""
@@ -51,6 +53,9 @@ with st.expander("🚀 Upcoming Features"):
51
  """)
52
 
53
  with st.sidebar:
 
 
 
54
  st.markdown("""
55
  <style>
56
  .title {
@@ -90,7 +95,8 @@ with st.sidebar:
90
  # Add protein selection methods
91
  selection_method = st.radio(
92
  "Choose input method:",
93
- ["Use example query", "Search proteins", "Upload protein ID file"]
 
94
  )
95
 
96
  if selection_method == "Use example query":
@@ -98,7 +104,11 @@ with st.sidebar:
98
 
99
  elif selection_method == "Search proteins":
100
  # User enters search term
101
- search_query = st.text_input("Start typing a protein ID (at least 3 characters)", "")
 
 
 
 
102
 
103
  # Apply fuzzy search only if query length is >= 3
104
  filtered_proteins = []
@@ -107,27 +117,24 @@ with st.sidebar:
107
  matches = process.extract(
108
  search_query.upper(),
109
  {p: p.upper() for p in available_proteins},
110
- limit=50,
111
- score_cutoff=50 # Optional: only include matches above 50% similarity
112
  )
113
  filtered_proteins = [match[0] for match in matches] # Show top 50 matches
114
 
115
- # Multi-select for filtered results
116
  selected_proteins = st.multiselect(
117
  "Select proteins from search results",
118
  options=filtered_proteins,
119
  placeholder="Start typing to search...",
120
- max_selections=100
 
121
  )
122
 
123
- if selected_proteins:
124
- st.write(f"Selected {len(selected_proteins)} proteins")
125
-
126
- else:
127
  uploaded_file = st.file_uploader(
128
  "Upload a text file with UniProt IDs (one per line, max 100)*",
129
- type=['txt']
130
- )
 
131
 
132
  if uploaded_file:
133
  protein_list = [line.strip() for line in uploaded_file.read().decode('utf-8').splitlines()]
@@ -174,6 +181,7 @@ with st.sidebar:
174
  Currently, our system can only generate predictions for proteins that are already included in our knowledge graph. **Real-time retrieval of relationship data from external source databases is not yet supported.**
175
  We are actively working on integrating this capability in future updates. Stay tuned!
176
  """)
 
177
  if selected_proteins:
178
  with st.expander("View Selected Proteins"):
179
  st.write(f"Total proteins selected: {len(selected_proteins)}")
@@ -216,7 +224,8 @@ with st.sidebar:
216
  selected_go_category = st.selectbox(
217
  "Select GO Category for predictions",
218
  options=list(go_category_options.keys()),
219
- help="Choose which GO category to generate predictions for. Selecting 'All Categories' will generate predictions for all three categories."
 
220
  )
221
 
222
  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,6 +246,7 @@ with st.sidebar:
237
  st.session_state.submitted = True
238
 
239
  if st.session_state.submitted:
 
240
  with st.spinner("Generating predictions..."):
241
  # Generate predictions only if not already in session state
242
  if st.session_state.predictions_df is None:
@@ -286,12 +296,12 @@ if st.session_state.submitted:
286
 
287
  st.session_state.predictions_df = predictions_df
288
 
 
289
  # Display and filter predictions
290
  st.success("Predictions generated successfully!")
291
  st.markdown("### Filter and View Predictions")
292
 
293
  # Create filters
294
- st.markdown("### Filter Predictions")
295
  col1, col2, col3, col4 = st.columns(4) # Changed to 4 columns
296
 
297
  with col1:
 
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("""
 
53
  """)
54
 
55
  with st.sidebar:
56
+
57
+ disabled = st.session_state.generating_predictions
58
+
59
  st.markdown("""
60
  <style>
61
  .title {
 
95
  # Add protein selection methods
96
  selection_method = st.radio(
97
  "Choose input method:",
98
+ ["Use example query", "Search proteins", "Upload protein ID file"],
99
+ disabled=disabled
100
  )
101
 
102
  if selection_method == "Use example query":
 
104
 
105
  elif selection_method == "Search proteins":
106
  # User enters search term
107
+ search_query = st.text_input(
108
+ "Start typing a protein ID (at least 3 characters)",
109
+ "",
110
+ disabled=disabled
111
+ )
112
 
113
  # Apply fuzzy search only if query length is >= 3
114
  filtered_proteins = []
 
117
  matches = process.extract(
118
  search_query.upper(),
119
  {p: p.upper() for p in available_proteins},
120
+ limit=50
 
121
  )
122
  filtered_proteins = [match[0] for match in matches] # Show top 50 matches
123
 
 
124
  selected_proteins = st.multiselect(
125
  "Select proteins from search results",
126
  options=filtered_proteins,
127
  placeholder="Start typing to search...",
128
+ max_selections=100,
129
+ disabled=disabled
130
  )
131
 
132
+ else: # Upload file option
 
 
 
133
  uploaded_file = st.file_uploader(
134
  "Upload a text file with UniProt IDs (one per line, max 100)*",
135
+ type=['txt'],
136
+ disabled=disabled
137
+ )
138
 
139
  if uploaded_file:
140
  protein_list = [line.strip() for line in uploaded_file.read().decode('utf-8').splitlines()]
 
181
  Currently, our system can only generate predictions for proteins that are already included in our knowledge graph. **Real-time retrieval of relationship data from external source databases is not yet supported.**
182
  We are actively working on integrating this capability in future updates. Stay tuned!
183
  """)
184
+
185
  if selected_proteins:
186
  with st.expander("View Selected Proteins"):
187
  st.write(f"Total proteins selected: {len(selected_proteins)}")
 
224
  selected_go_category = st.selectbox(
225
  "Select GO Category for predictions",
226
  options=list(go_category_options.keys()),
227
+ help="Choose which GO category to generate predictions for. Selecting 'All Categories' will generate predictions for all three categories.",
228
+ disabled=disabled
229
  )
230
 
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.")
 
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:
 
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")
303
 
304
  # Create filters
 
305
  col1, col2, col3, col4 = st.columns(4) # Changed to 4 columns
306
 
307
  with col1: