supercat666 commited on
Commit
dd69d15
1 Parent(s): cb692e5
Files changed (1) hide show
  1. app.py +24 -36
app.py CHANGED
@@ -92,43 +92,31 @@ if selected_model == 'Cas9':
92
 
93
  # Actions based on the selected enzyme
94
  if target_selection == 'on-target':
95
- # app initialization for Cas9 on-target
96
- if 'gene_symbol' not in st.session_state:
97
- st.session_state.gene_symbol = None
98
- if 'on_target_results' not in st.session_state:
99
- st.session_state.on_target_results = None
100
-
101
  # Gene symbol entry
102
- st.text_input(
103
- label='Enter a Gene Symbol:',
104
- key='gene_symbol_entry',
105
- placeholder='e.g., BRCA1'
106
- )
107
-
108
- # prediction button
109
- if st.button('Predict on-target'):
110
- gene_symbol = st.session_state.gene_symbol_entry
111
- if gene_symbol: # Check if gene_symbol is not empty
112
- predictions = cas9on.process_gene(gene_symbol, cas9on_path)
113
- st.session_state.on_target_results = predictions[:10] # Store only first 10 for display
114
-
115
- # on-target results display
116
- on_target_results = st.empty()
117
- if st.session_state.on_target_results is not None:
118
- with on_target_results.container():
119
- if len(st.session_state.on_target_results) > 0:
120
- st.write('On-target predictions:', st.session_state.on_target_results)
121
- full_predictions = cas9on.process_gene(gene_symbol, cas9on_path) # Get full predictions for download
122
- st.download_button(
123
- label='Download on-target predictions',
124
- data=cas9on.convert_df(full_predictions),
125
- file_name='on_target_results.csv',
126
- mime='text/csv'
127
- )
128
- else:
129
- st.write('No significant on-target effects detected!')
130
- else:
131
- on_target_results.empty()
132
 
133
  elif target_selection == 'off-target':
134
  ENTRY_METHODS = dict(
 
92
 
93
  # Actions based on the selected enzyme
94
  if target_selection == 'on-target':
 
 
 
 
 
 
95
  # Gene symbol entry
96
+ gene_symbol = st.text_input('Enter a Gene Symbol:', key='gene_symbol')
97
+
98
+ # Prediction button
99
+ predict_button = st.button('Predict on-target')
100
+
101
+ # Process predictions
102
+ if predict_button and gene_symbol:
103
+ predictions = cas9on.process_gene(gene_symbol, cas9on_path)
104
+ # Store only first 10 for display and save full predictions for download
105
+ st.session_state['on_target_results'] = predictions[:10]
106
+ st.session_state['full_on_target_results'] = predictions
107
+
108
+ # On-target results display
109
+ if 'on_target_results' in st.session_state and st.session_state['on_target_results']:
110
+ st.write('On-target predictions:', st.session_state['on_target_results'])
111
+ if 'full_on_target_results' in st.session_state:
112
+ # Provide a download button for the full results
113
+ full_predictions_csv = cas9on.convert_df(st.session_state['full_on_target_results'])
114
+ st.download_button(
115
+ label='Download on-target predictions',
116
+ data=full_predictions_csv,
117
+ file_name='on_target_results.csv',
118
+ mime='text/csv'
119
+ )
 
 
 
 
 
 
120
 
121
  elif target_selection == 'off-target':
122
  ENTRY_METHODS = dict(