Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,341 Bytes
89be9f9 54823be 77e4f1f 89be9f9 8134cc8 89be9f9 f606ed7 cf3bd3a 77e4f1f cf3bd3a 77e4f1f cf3bd3a 8134cc8 77e4f1f 8134cc8 f606ed7 89be9f9 77e4f1f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import streamlit as st
import pandas as pd
from run import run, GUIDE_LEN, NUCLEOTIDE_TOKENS
# def run_with_input(reset=False):
# if reset:
# st.write("")
# return 0
# returned_x = run(st.session_state["userInput"])
# csv_x = returned_x.to_csv()
# st.write("model prediction: ", returned_x)
# return csv_x
@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 target transcript (or substring):')
if len(st.session_state['userInput']) < GUIDE_LEN:
st.write('Transcript length must be >= 23 bases. It is {:d} chars'.format(len(st.session_state['userInput'])))
st.write("")
elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st.session_state['userInput']]):
st.write('This is your sequence', st.session_state['userInput'])
predictions = run(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')
else:
st.write('only ACTG is allowed')
|