tiger / app.py
Andrew Stirn
context len added
a1b3810
raw
history blame
1.22 kB
import streamlit as st
from tiger import tiger_predict, TARGET_LEN, NUCLEOTIDE_TOKENS
@st.cache
def convert_df(df):
# IMPORTANT: Cache the conversion to prevent computation on every rerun
return df.to_csv().encode('utf-8')
# title and instructions
st.title('TIGER Cas13 Efficacy Prediction')
st.session_state['userInput'] = ''
st.session_state['userInput'] = st.text_input('Enter a target transcript (or substring thereof):',
placeholder='Upper or lower case')
# input is too short
if len(st.session_state['userInput']) < TARGET_LEN:
transcript_len = len(st.session_state['userInput'])
st.write('Transcript length ({:d}) must be at least {:d} bases.'.format(transcript_len, TARGET_LEN))
# valid input
elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st.session_state['userInput']]):
predictions = tiger_predict(st.session_state['userInput'])
st.write('Model predictions: ', predictions)
csv = convert_df(predictions)
st.download_button(label='Download CSV file', data=csv, file_name='tiger_predictions.csv', mime='text/csv')
# invalid input
else:
st.write('Nucleotides other than ACGT detected!')