Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
99a0d01
1
Parent(s):
9f169cd
prevent crash when off target is empty and add option for on target only
Browse files
app.py
CHANGED
|
@@ -15,6 +15,11 @@ st.session_state["fasta_seq"] = ""
|
|
| 15 |
st.session_state["text_seq"] = ""
|
| 16 |
status_bar, status_text = None, None
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# UserInput Form from text input
|
| 19 |
text_form = st.form("text")
|
| 20 |
text_input = text_form.text_input(
|
|
@@ -73,7 +78,7 @@ else:
|
|
| 73 |
# valid input
|
| 74 |
if src_seq and all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in src_seq]):
|
| 75 |
on_target, off_target = tiger_exhibit(pd.DataFrame(dict(id=['ManualEntry'], seq=[src_seq])),
|
| 76 |
-
status_bar, status_text)
|
| 77 |
st.write('On-target predictions: ', on_target)
|
| 78 |
st.download_button(label='Download', data=convert_df(on_target), file_name='on_target.csv', mime='text/csv')
|
| 79 |
if len(off_target) > 0:
|
|
|
|
| 15 |
st.session_state["text_seq"] = ""
|
| 16 |
status_bar, status_text = None, None
|
| 17 |
|
| 18 |
+
with st.form(key='calc_options'):
|
| 19 |
+
c1_names = ['On Target Only', 'On and Off Target']
|
| 20 |
+
option = st.radio('Calculation Options', c1_names, index=0)
|
| 21 |
+
submitButton = st.form_submit_button(label='Choose Options')
|
| 22 |
+
|
| 23 |
# UserInput Form from text input
|
| 24 |
text_form = st.form("text")
|
| 25 |
text_input = text_form.text_input(
|
|
|
|
| 78 |
# valid input
|
| 79 |
if src_seq and all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in src_seq]):
|
| 80 |
on_target, off_target = tiger_exhibit(pd.DataFrame(dict(id=['ManualEntry'], seq=[src_seq])),
|
| 81 |
+
status_bar, status_text, option)
|
| 82 |
st.write('On-target predictions: ', on_target)
|
| 83 |
st.download_button(label='Download', data=convert_df(on_target), file_name='on_target.csv', mime='text/csv')
|
| 84 |
if len(off_target) > 0:
|
tiger.py
CHANGED
|
@@ -188,7 +188,7 @@ def predict_off_target(off_targets: pd.DataFrame, model: tf.keras.Model):
|
|
| 188 |
return off_targets.sort_values('Normalized LFC')
|
| 189 |
|
| 190 |
|
| 191 |
-
def tiger_exhibit(transcripts: pd.DataFrame, status_bar=None, status_text=None):
|
| 192 |
|
| 193 |
# load model
|
| 194 |
if os.path.exists('model'):
|
|
@@ -213,8 +213,15 @@ def tiger_exhibit(transcripts: pd.DataFrame, status_bar=None, status_text=None):
|
|
| 213 |
print('')
|
| 214 |
|
| 215 |
# predict off-target effects for top guides
|
| 216 |
-
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
return on_target_predictions.reset_index(drop=True), off_target_predictions.reset_index(drop=True)
|
| 220 |
|
|
|
|
| 188 |
return off_targets.sort_values('Normalized LFC')
|
| 189 |
|
| 190 |
|
| 191 |
+
def tiger_exhibit(transcripts: pd.DataFrame, status_bar=None, status_text=None, option=''):
|
| 192 |
|
| 193 |
# load model
|
| 194 |
if os.path.exists('model'):
|
|
|
|
| 213 |
print('')
|
| 214 |
|
| 215 |
# predict off-target effects for top guides
|
| 216 |
+
off_target_predictions = pd.DataFrame()
|
| 217 |
+
if option=='On and Off Target':
|
| 218 |
+
off_targets = find_off_targets(on_target_predictions, status_bar, status_text)
|
| 219 |
+
off_target_predictions = predict_off_target(off_targets, model=tiger)
|
| 220 |
+
|
| 221 |
+
# reverse guide sequences
|
| 222 |
+
on_target_predictions['Guide'] = on_target_predictions['Guide'].apply(lambda s: s[::-1])
|
| 223 |
+
if option=='On and Off Target' and len(off_target_predictions) > 0:
|
| 224 |
+
off_target_predictions['Guide'] = off_target_predictions['Guide'].apply(lambda s: s[::-1])
|
| 225 |
|
| 226 |
return on_target_predictions.reset_index(drop=True), off_target_predictions.reset_index(drop=True)
|
| 227 |
|