Andrew Stirn commited on
Commit
f606ed7
·
1 Parent(s): 8134cc8

let's try something

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -12,6 +12,11 @@ from run import run, GUIDE_LEN, NUCLEOTIDE_TOKENS
12
  # st.write("model prediction: ", returned_x)
13
  # return csv_x
14
 
 
 
 
 
 
15
 
16
  # title and instructions
17
  st.title('TIGER Cas13 Efficacy Prediction')
@@ -19,7 +24,6 @@ st.session_state['userInput'] = ''
19
  st.session_state['userInput'] = st.text_input('Enter target transcript (or substring):')
20
 
21
 
22
- predictions = pd.DataFrame.from_dict({'Target Site': [''], 'Normalized LFC': [0.0]})
23
  if len(st.session_state['userInput']) < GUIDE_LEN:
24
  st.write('Transcript length must be >= 23 bases. It is {:d} chars'.format(len(st.session_state['userInput'])))
25
  st.write("")
@@ -27,6 +31,7 @@ elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st
27
  st.write('This is your sequence', st.session_state['userInput'])
28
  predictions = run(st.session_state['userInput'])
29
  st.write('Model predictions: ', predictions)
 
 
30
  else:
31
  st.write('only ACTG is allowed')
32
- st.download_button(label='Download as CVS File', data=predictions.to_csv())
 
12
  # st.write("model prediction: ", returned_x)
13
  # return csv_x
14
 
15
+ @st.cache
16
+ def convert_df(df):
17
+ # IMPORTANT: Cache the conversion to prevent computation on every rerun
18
+ return df.to_csv().encode('utf-8')
19
+
20
 
21
  # title and instructions
22
  st.title('TIGER Cas13 Efficacy Prediction')
 
24
  st.session_state['userInput'] = st.text_input('Enter target transcript (or substring):')
25
 
26
 
 
27
  if len(st.session_state['userInput']) < GUIDE_LEN:
28
  st.write('Transcript length must be >= 23 bases. It is {:d} chars'.format(len(st.session_state['userInput'])))
29
  st.write("")
 
31
  st.write('This is your sequence', st.session_state['userInput'])
32
  predictions = run(st.session_state['userInput'])
33
  st.write('Model predictions: ', predictions)
34
+ csv = convert_df(predictions)
35
+ st.download_button(label='Download CSV file', data=csv, file_name='tiger_predictions.csv', mime='text/csv')
36
  else:
37
  st.write('only ACTG is allowed')