supercat666 commited on
Commit
adf804d
1 Parent(s): 66c57f6

fixed cas9off

Browse files
Files changed (2) hide show
  1. app.py +3 -4
  2. cas9off.py +6 -11
app.py CHANGED
@@ -131,10 +131,11 @@ if selected_model == 'Cas9':
131
  )
132
 
133
  # prediction button
134
- if st.button('Predict off-target effects'):
135
  if st.session_state.entry_method == ENTRY_METHODS['manual']:
136
  user_input = st.session_state.manual_entry
137
- predictions = cas9off.process_input_and_predict(user_input, input_type='manual')
 
138
  elif st.session_state.entry_method == ENTRY_METHODS['txt']:
139
  uploaded_file = st.session_state.txt_entry
140
  if uploaded_file is not None:
@@ -144,9 +145,7 @@ if selected_model == 'Cas9':
144
 
145
  st.session_state.off_target_results = predictions
146
  else:
147
- # Ensure that 'predictions' is defined even if the button hasn't been clicked
148
  predictions = None
149
-
150
  progress = st.empty()
151
 
152
  # input error display
 
131
  )
132
 
133
  # prediction button
134
+ if st.button('Predict off-target'):
135
  if st.session_state.entry_method == ENTRY_METHODS['manual']:
136
  user_input = st.session_state.manual_entry
137
+ if user_input: # Check if user_input is not empty
138
+ predictions = cas9off.process_input_and_predict(user_input, input_type='manual')
139
  elif st.session_state.entry_method == ENTRY_METHODS['txt']:
140
  uploaded_file = st.session_state.txt_entry
141
  if uploaded_file is not None:
 
145
 
146
  st.session_state.off_target_results = predictions
147
  else:
 
148
  predictions = None
 
149
  progress = st.empty()
150
 
151
  # input error display
cas9off.py CHANGED
@@ -108,17 +108,6 @@ def CRISPR_net_predict(X_test):
108
  return y_pred
109
 
110
  def process_input_and_predict(input_data, input_type='manual'):
111
- """
112
- Process the user input and predict.
113
-
114
- Args:
115
- input_data: A string of manual input or the path to an input file.
116
- input_type: 'manual' for manual input, 'file' for file input.
117
-
118
- Returns:
119
- A DataFrame with the off-target predictions.
120
- """
121
-
122
  if input_type == 'manual':
123
  # Process manual input string into DataFrame
124
  sequences = [seq.split(',') for seq in input_data.split('\n')]
@@ -132,6 +121,12 @@ def process_input_and_predict(input_data, input_type='manual'):
132
  for idx, row in inputs.iterrows():
133
  on_seq = row['on_seq']
134
  off_seq = row['off_seq']
 
 
 
 
 
 
135
  en = Encoder(on_seq=on_seq, off_seq=off_seq)
136
  input_codes.append(en.on_off_code)
137
 
 
108
  return y_pred
109
 
110
  def process_input_and_predict(input_data, input_type='manual'):
 
 
 
 
 
 
 
 
 
 
 
111
  if input_type == 'manual':
112
  # Process manual input string into DataFrame
113
  sequences = [seq.split(',') for seq in input_data.split('\n')]
 
121
  for idx, row in inputs.iterrows():
122
  on_seq = row['on_seq']
123
  off_seq = row['off_seq']
124
+
125
+ # Validate on_seq and off_seq
126
+ if not on_seq or not off_seq:
127
+ # Skip the current row if either on_seq or off_seq is missing or empty
128
+ continue
129
+
130
  en = Encoder(on_seq=on_seq, off_seq=off_seq)
131
  input_codes.append(en.on_off_code)
132