Andrew Stirn commited on
Commit
7b58b1f
1 Parent(s): ff943ce

results clear on rerun

Browse files
Files changed (1) hide show
  1. app.py +54 -50
app.py CHANGED
@@ -92,63 +92,61 @@ if __name__ == '__main__':
92
  st.session_state.off_target = None
93
 
94
  # title and documentation
95
- with st.container():
96
- st.title('TIGER Cas13 Efficacy Prediction')
97
 
98
  # mode selection
99
- with st.container():
100
- col1, col2 = st.columns([0.65, 0.35])
101
- with col1:
102
- st.radio(
103
- label='What do you want to predict?',
104
- options=tuple(tiger.RUN_MODES.values()),
105
- key='mode',
106
- on_change=mode_change_callback,
107
- disabled=st.session_state.transcripts is not None,
108
- )
109
- with col2:
110
- st.checkbox(
111
- label='Find off-target effects (slow)',
112
- key='check_off_targets',
113
- disabled=st.session_state.disable_off_target_checkbox or st.session_state.transcripts is not None
114
- )
115
 
116
  # transcript entry
117
- with st.container():
118
- st.selectbox(
119
- label='How would you like to provide transcript(s) of interest?',
120
- options=ENTRY_METHODS.values(),
121
- key='entry_method',
 
 
 
 
 
 
 
 
 
 
 
 
122
  disabled=st.session_state.transcripts is not None
123
  )
124
- if st.session_state.entry_method == ENTRY_METHODS['manual']:
125
- st.text_input(
126
- label='Enter a target transcript:',
127
- key='manual_entry',
128
- placeholder='Upper or lower case',
129
- disabled=st.session_state.transcripts is not None
130
- )
131
- elif st.session_state.entry_method == ENTRY_METHODS['fasta']:
132
- st.file_uploader(
133
- label='Upload a fasta file:',
134
- key='fasta_entry',
135
- disabled=st.session_state.transcripts is not None
136
- )
137
-
138
- # runtime
139
- with st.container():
140
- st.button(label='Get predictions!', on_click=initiate_run, disabled=st.session_state.transcripts is not None)
141
- progress = st.empty()
142
 
143
- # results
144
- with st.container():
 
145
 
146
- # input error
147
- if st.session_state.input_error is not None:
148
- st.error(st.session_state.input_error, icon="🚨")
 
 
 
149
 
150
- # on-target results
151
- if st.session_state.on_target is not None:
 
 
152
  st.write('On-target predictions:', st.session_state.on_target)
153
  st.download_button(
154
  label='Download on-target predictions',
@@ -156,9 +154,13 @@ if __name__ == '__main__':
156
  file_name='on_target.csv',
157
  mime='text/csv'
158
  )
 
 
159
 
160
- # off-target results
161
- if st.session_state.off_target is not None:
 
 
162
  if len(st.session_state.off_target) > 0:
163
  st.write('Off-target predictions:', st.session_state.off_target)
164
  st.download_button(
@@ -169,6 +171,8 @@ if __name__ == '__main__':
169
  )
170
  else:
171
  st.write('We did not find any off-target effects!')
 
 
172
 
173
  # keep trying to run model until we clear inputs (streamlit UI changes can induce race-condition reruns)
174
  if st.session_state.transcripts is not None:
 
92
  st.session_state.off_target = None
93
 
94
  # title and documentation
95
+ st.title('TIGER Cas13 Efficacy Prediction')
 
96
 
97
  # mode selection
98
+ col1, col2 = st.columns([0.65, 0.35])
99
+ with col1:
100
+ st.radio(
101
+ label='What do you want to predict?',
102
+ options=tuple(tiger.RUN_MODES.values()),
103
+ key='mode',
104
+ on_change=mode_change_callback,
105
+ disabled=st.session_state.transcripts is not None,
106
+ )
107
+ with col2:
108
+ st.checkbox(
109
+ label='Find off-target effects (slow)',
110
+ key='check_off_targets',
111
+ disabled=st.session_state.disable_off_target_checkbox or st.session_state.transcripts is not None
112
+ )
 
113
 
114
  # transcript entry
115
+ st.selectbox(
116
+ label='How would you like to provide transcript(s) of interest?',
117
+ options=ENTRY_METHODS.values(),
118
+ key='entry_method',
119
+ disabled=st.session_state.transcripts is not None
120
+ )
121
+ if st.session_state.entry_method == ENTRY_METHODS['manual']:
122
+ st.text_input(
123
+ label='Enter a target transcript:',
124
+ key='manual_entry',
125
+ placeholder='Upper or lower case',
126
+ disabled=st.session_state.transcripts is not None
127
+ )
128
+ elif st.session_state.entry_method == ENTRY_METHODS['fasta']:
129
+ st.file_uploader(
130
+ label='Upload a fasta file:',
131
+ key='fasta_entry',
132
  disabled=st.session_state.transcripts is not None
133
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
+ # let's go!
136
+ st.button(label='Get predictions!', on_click=initiate_run, disabled=st.session_state.transcripts is not None)
137
+ progress = st.empty()
138
 
139
+ # input error
140
+ error = st.empty()
141
+ if st.session_state.input_error is not None:
142
+ error.error(st.session_state.input_error, icon="🚨")
143
+ else:
144
+ error.empty()
145
 
146
+ # on-target results
147
+ on_target_results = st.empty()
148
+ if st.session_state.on_target is not None:
149
+ with on_target_results.container():
150
  st.write('On-target predictions:', st.session_state.on_target)
151
  st.download_button(
152
  label='Download on-target predictions',
 
154
  file_name='on_target.csv',
155
  mime='text/csv'
156
  )
157
+ else:
158
+ on_target_results.empty()
159
 
160
+ # off-target results
161
+ off_target_results = st.empty()
162
+ if st.session_state.off_target is not None:
163
+ with off_target_results.container():
164
  if len(st.session_state.off_target) > 0:
165
  st.write('Off-target predictions:', st.session_state.off_target)
166
  st.download_button(
 
171
  )
172
  else:
173
  st.write('We did not find any off-target effects!')
174
+ else:
175
+ off_target_results.empty()
176
 
177
  # keep trying to run model until we clear inputs (streamlit UI changes can induce race-condition reruns)
178
  if st.session_state.transcripts is not None: