Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Andrew Stirn
commited on
Commit
·
4e66e6b
1
Parent(s):
592b51c
cleanup
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from tiger import
|
| 3 |
|
| 4 |
|
| 5 |
@st.cache
|
|
@@ -23,9 +23,9 @@ if len(st.session_state['userInput']) < TARGET_LEN:
|
|
| 23 |
|
| 24 |
# valid input
|
| 25 |
elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st.session_state['userInput']]):
|
| 26 |
-
|
| 27 |
-
st.write('Model predictions: ',
|
| 28 |
-
csv = convert_df(
|
| 29 |
st.download_button(label='Download CSV file', data=csv, file_name='tiger_predictions.csv', mime='text/csv')
|
| 30 |
|
| 31 |
# invalid input
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from tiger import tiger_exhibit, TARGET_LEN, NUCLEOTIDE_TOKENS
|
| 3 |
|
| 4 |
|
| 5 |
@st.cache
|
|
|
|
| 23 |
|
| 24 |
# valid input
|
| 25 |
elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st.session_state['userInput']]):
|
| 26 |
+
on_target_predictions, off_target_predictions = tiger_exhibit(st.session_state['userInput'])
|
| 27 |
+
st.write('Model predictions: ', on_target_predictions)
|
| 28 |
+
csv = convert_df(on_target_predictions)
|
| 29 |
st.download_button(label='Download CSV file', data=csv, file_name='tiger_predictions.csv', mime='text/csv')
|
| 30 |
|
| 31 |
# invalid input
|
tiger.py
CHANGED
|
@@ -65,7 +65,7 @@ def process_data(transcript_seq: str):
|
|
| 65 |
return target_seq, guide_seq, model_inputs
|
| 66 |
|
| 67 |
|
| 68 |
-
def
|
| 69 |
|
| 70 |
# load model
|
| 71 |
if os.path.exists('model'):
|
|
@@ -132,16 +132,21 @@ def find_off_targets(guides, batch_size=1000):
|
|
| 132 |
return df_off_targets
|
| 133 |
|
| 134 |
|
| 135 |
-
|
| 136 |
|
| 137 |
-
#
|
| 138 |
-
|
| 139 |
-
sorted_predictions = tiger_predict(transcript_sequence)
|
| 140 |
|
| 141 |
-
#
|
| 142 |
-
|
| 143 |
-
print(sorted_predictions)
|
| 144 |
|
| 145 |
# scan for off-targets for top guides
|
| 146 |
-
off_targets = find_off_targets(
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
return target_seq, guide_seq, model_inputs
|
| 66 |
|
| 67 |
|
| 68 |
+
def predict_on_target(transcript_seq: str):
|
| 69 |
|
| 70 |
# load model
|
| 71 |
if os.path.exists('model'):
|
|
|
|
| 132 |
return df_off_targets
|
| 133 |
|
| 134 |
|
| 135 |
+
def tiger_exhibit(transcript):
|
| 136 |
|
| 137 |
+
# on-target predictions
|
| 138 |
+
on_target_predictions = predict_on_target(transcript)
|
|
|
|
| 139 |
|
| 140 |
+
# keep only top guides
|
| 141 |
+
on_target_predictions = on_target_predictions.iloc[:NUM_TOP_GUIDES]
|
|
|
|
| 142 |
|
| 143 |
# scan for off-targets for top guides
|
| 144 |
+
off_targets = find_off_targets(on_target_predictions.index.values.tolist())
|
| 145 |
+
|
| 146 |
+
return on_target_predictions, off_targets
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
if __name__ == '__main__':
|
| 150 |
+
|
| 151 |
+
# simple test case
|
| 152 |
+
print(tiger_exhibit('ATGCAGGACGCGGAGAACGTGGCGGTGCCCGAGGCGGCCGAGGAGCGCGC'.lower())) # first 50 from EIF3B-003's CDS
|