Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
89ee386
1
Parent(s):
6216d88
enable status bar
Browse files
app.py
CHANGED
|
@@ -16,7 +16,9 @@ st.session_state['userInput'] = st.text_input(
|
|
| 16 |
label='Enter a target transcript:',
|
| 17 |
# value='ATGCAGGACGCGGAGAACGTGGCGGTGCCCGAGGCGGCCGAGGAGCGCGC',
|
| 18 |
placeholder='Upper or lower case')
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
# input is too short
|
| 21 |
if len(st.session_state['userInput']) < TARGET_LEN:
|
| 22 |
transcript_len = len(st.session_state['userInput'])
|
|
@@ -24,7 +26,8 @@ if len(st.session_state['userInput']) < TARGET_LEN:
|
|
| 24 |
|
| 25 |
# valid input
|
| 26 |
elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st.session_state['userInput']]):
|
| 27 |
-
on_target, off_target = tiger_exhibit(pd.DataFrame(dict(id=['ManualEntry'], seq=[st.session_state['userInput']]))
|
|
|
|
| 28 |
st.write('On-target predictions: ', on_target)
|
| 29 |
st.download_button(label='Download', data=convert_df(on_target), file_name='on_target.csv', mime='text/csv')
|
| 30 |
if len(off_target) > 0:
|
|
|
|
| 16 |
label='Enter a target transcript:',
|
| 17 |
# value='ATGCAGGACGCGGAGAACGTGGCGGTGCCCGAGGCGGCCGAGGAGCGCGC',
|
| 18 |
placeholder='Upper or lower case')
|
| 19 |
+
#status bar
|
| 20 |
+
status_text = st.empty()
|
| 21 |
+
status_bar = st.progress(0)
|
| 22 |
# input is too short
|
| 23 |
if len(st.session_state['userInput']) < TARGET_LEN:
|
| 24 |
transcript_len = len(st.session_state['userInput'])
|
|
|
|
| 26 |
|
| 27 |
# valid input
|
| 28 |
elif all([True if nt.upper() in NUCLEOTIDE_TOKENS.keys() else False for nt in st.session_state['userInput']]):
|
| 29 |
+
on_target, off_target = tiger_exhibit(pd.DataFrame(dict(id=['ManualEntry'], seq=[st.session_state['userInput']])),
|
| 30 |
+
status_bar, status_text)
|
| 31 |
st.write('On-target predictions: ', on_target)
|
| 32 |
st.download_button(label='Download', data=convert_df(on_target), file_name='on_target.csv', mime='text/csv')
|
| 33 |
if len(off_target) > 0:
|
tiger.py
CHANGED
|
@@ -112,7 +112,7 @@ def predict_on_target(transcript_seq: str, model: tf.keras.Model):
|
|
| 112 |
return predictions
|
| 113 |
|
| 114 |
|
| 115 |
-
def find_off_targets(top_guides: pd.DataFrame):
|
| 116 |
|
| 117 |
# load reference transcripts
|
| 118 |
reference_transcripts = load_transcripts([os.path.join('transcripts', f) for f in REFERENCE_TRANSCRIPTS])
|
|
@@ -166,6 +166,8 @@ def find_off_targets(top_guides: pd.DataFrame):
|
|
| 166 |
off_targets = pd.concat([off_targets, pd.DataFrame(dict_off_targets)])
|
| 167 |
|
| 168 |
# progress update
|
|
|
|
|
|
|
| 169 |
print('\rPercent complete: {:.2f}%'.format(100 * min(i / len(reference_transcripts), 1)), end='')
|
| 170 |
print('')
|
| 171 |
|
|
@@ -186,7 +188,7 @@ def predict_off_target(off_targets: pd.DataFrame, model: tf.keras.Model):
|
|
| 186 |
return off_targets.sort_values('Normalized LFC')
|
| 187 |
|
| 188 |
|
| 189 |
-
def tiger_exhibit(transcripts: pd.DataFrame):
|
| 190 |
|
| 191 |
# load model
|
| 192 |
if os.path.exists('model'):
|
|
@@ -204,11 +206,13 @@ def tiger_exhibit(transcripts: pd.DataFrame):
|
|
| 204 |
on_target_predictions = pd.concat([on_target_predictions, df.iloc[:NUM_TOP_GUIDES]])
|
| 205 |
|
| 206 |
# progress update
|
|
|
|
|
|
|
| 207 |
print('\rPercent complete: {:.2f}%'.format(100 * min((i + 1) / len(transcripts), 1)), end='')
|
| 208 |
print('')
|
| 209 |
|
| 210 |
# predict off-target effects for top guides
|
| 211 |
-
off_targets = find_off_targets(on_target_predictions)
|
| 212 |
off_target_predictions = predict_off_target(off_targets, model=tiger)
|
| 213 |
|
| 214 |
return on_target_predictions.reset_index(drop=True), off_target_predictions.reset_index(drop=True)
|
|
|
|
| 112 |
return predictions
|
| 113 |
|
| 114 |
|
| 115 |
+
def find_off_targets(top_guides: pd.DataFrame, status_bar, status_text):
|
| 116 |
|
| 117 |
# load reference transcripts
|
| 118 |
reference_transcripts = load_transcripts([os.path.join('transcripts', f) for f in REFERENCE_TRANSCRIPTS])
|
|
|
|
| 166 |
off_targets = pd.concat([off_targets, pd.DataFrame(dict_off_targets)])
|
| 167 |
|
| 168 |
# progress update
|
| 169 |
+
status_text.text("Scanning for off-targets Percent complete: {:.2f}%".format(int(100 * min(i / len(reference_transcripts), 1))))
|
| 170 |
+
status_bar.progress(int(100 * min(i / len(reference_transcripts), 1)))
|
| 171 |
print('\rPercent complete: {:.2f}%'.format(100 * min(i / len(reference_transcripts), 1)), end='')
|
| 172 |
print('')
|
| 173 |
|
|
|
|
| 188 |
return off_targets.sort_values('Normalized LFC')
|
| 189 |
|
| 190 |
|
| 191 |
+
def tiger_exhibit(transcripts: pd.DataFrame, status_bar, status_text):
|
| 192 |
|
| 193 |
# load model
|
| 194 |
if os.path.exists('model'):
|
|
|
|
| 206 |
on_target_predictions = pd.concat([on_target_predictions, df.iloc[:NUM_TOP_GUIDES]])
|
| 207 |
|
| 208 |
# progress update
|
| 209 |
+
status_text.text("Scanning for on-targets Percent complete: {:.2f}%".format(100 * min((i + 1) / len(transcripts), 1)))
|
| 210 |
+
status_bar.progress(int(100 * min((i + 1) / len(transcripts), 1)))
|
| 211 |
print('\rPercent complete: {:.2f}%'.format(100 * min((i + 1) / len(transcripts), 1)), end='')
|
| 212 |
print('')
|
| 213 |
|
| 214 |
# predict off-target effects for top guides
|
| 215 |
+
off_targets = find_off_targets(on_target_predictions, status_bar, status_text)
|
| 216 |
off_target_predictions = predict_off_target(off_targets, model=tiger)
|
| 217 |
|
| 218 |
return on_target_predictions.reset_index(drop=True), off_target_predictions.reset_index(drop=True)
|