Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Andrew Stirn
commited on
Commit
·
cb8c873
1
Parent(s):
f606ed7
cleanup
Browse files
app.py
CHANGED
|
@@ -1,17 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
-
from run import run, GUIDE_LEN, NUCLEOTIDE_TOKENS
|
| 4 |
|
| 5 |
|
| 6 |
-
# def run_with_input(reset=False):
|
| 7 |
-
# if reset:
|
| 8 |
-
# st.write("")
|
| 9 |
-
# return 0
|
| 10 |
-
# returned_x = run(st.session_state["userInput"])
|
| 11 |
-
# csv_x = returned_x.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
|
|
@@ -29,7 +19,7 @@ if len(st.session_state['userInput']) < GUIDE_LEN:
|
|
| 29 |
st.write("")
|
| 30 |
elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st.session_state['userInput']]):
|
| 31 |
st.write('This is your sequence', st.session_state['userInput'])
|
| 32 |
-
predictions =
|
| 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')
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from run import tiger_predict, GUIDE_LEN, NUCLEOTIDE_TOKENS
|
|
|
|
| 3 |
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
@st.cache
|
| 6 |
def convert_df(df):
|
| 7 |
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
|
|
|
| 19 |
st.write("")
|
| 20 |
elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st.session_state['userInput']]):
|
| 21 |
st.write('This is your sequence', st.session_state['userInput'])
|
| 22 |
+
predictions = tiger_predict(st.session_state['userInput'])
|
| 23 |
st.write('Model predictions: ', predictions)
|
| 24 |
csv = convert_df(predictions)
|
| 25 |
st.download_button(label='Download CSV file', data=csv, file_name='tiger_predictions.csv', mime='text/csv')
|
run.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
import sys
|
| 3 |
import tensorflow as tf
|
| 4 |
import pandas as pd
|
| 5 |
|
|
@@ -37,22 +36,10 @@ def gen_report_table(input_gens, res):
|
|
| 37 |
return tbl
|
| 38 |
|
| 39 |
|
| 40 |
-
def
|
| 41 |
input_gens, model_input_x = process_data(x)
|
| 42 |
# print("input gene: ", input_gens)
|
| 43 |
# print("model_input: ", model_input_x)
|
| 44 |
res = tiger.predict_step(model_input_x)
|
| 45 |
# print("res: ", res)
|
| 46 |
return gen_report_table(input_gens, res)
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# if __name__ == "__main__":
|
| 50 |
-
# if len(sys.argv) == 1:
|
| 51 |
-
# print("you need to specify 23 character gen information")
|
| 52 |
-
# exit()
|
| 53 |
-
# x = sys.argv[1]
|
| 54 |
-
# if len(x) != 23:
|
| 55 |
-
# print("you need to specify 23 character gen information. You typed %s chars" % len(x))
|
| 56 |
-
# exit()
|
| 57 |
-
# elif all([True if item in "ACGT" else False for item in x]):
|
| 58 |
-
# print("run succesfully: ", run(x))
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import tensorflow as tf
|
| 3 |
import pandas as pd
|
| 4 |
|
|
|
|
| 36 |
return tbl
|
| 37 |
|
| 38 |
|
| 39 |
+
def tiger_predict(x):
|
| 40 |
input_gens, model_input_x = process_data(x)
|
| 41 |
# print("input gene: ", input_gens)
|
| 42 |
# print("model_input: ", model_input_x)
|
| 43 |
res = tiger.predict_step(model_input_x)
|
| 44 |
# print("res: ", res)
|
| 45 |
return gen_report_table(input_gens, res)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|