Andrew Stirn commited on
Commit
0450f78
·
1 Parent(s): 53c486e

memory leak plugged

Browse files
Files changed (1) hide show
  1. tiger.py +11 -7
tiger.py CHANGED
@@ -168,7 +168,6 @@ def find_off_targets(top_guides: pd.DataFrame):
168
  # progress update
169
  print('\rPercent complete: {:.2f}%'.format(100 * min(i / len(reference_transcripts), 1)), end='')
170
  print('')
171
- del reference_transcripts
172
 
173
  return off_targets
174
 
@@ -239,15 +238,20 @@ if __name__ == '__main__':
239
  df_transcripts = load_transcripts([os.path.join(args.fasta_path, f) for f in os.listdir(args.fasta_path)])
240
 
241
  # process in batches
242
- batch = 1
243
  num_batches = len(df_transcripts) // BATCH_SIZE_TRANSCRIPTS
244
  num_batches += (len(df_transcripts) % BATCH_SIZE_TRANSCRIPTS > 0)
245
- for t in range(0, len(df_transcripts), BATCH_SIZE_TRANSCRIPTS):
 
246
  print('Batch {:d} of {:d}'.format(batch, num_batches))
247
- t_stop = min(t + BATCH_SIZE_TRANSCRIPTS, len(df_transcripts))
248
- df_on_target, df_off_target = tiger_exhibit(df_transcripts[t:t_stop])
 
 
 
 
249
  df_on_target.to_csv('on_target_{:d}.csv'.format(batch), index=False)
250
  df_off_target.to_csv('off_target_{:d}.csv'.format(batch), index=False)
251
- del df_on_target, df_off_target
252
- batch += 1
253
 
 
 
 
168
  # progress update
169
  print('\rPercent complete: {:.2f}%'.format(100 * min(i / len(reference_transcripts), 1)), end='')
170
  print('')
 
171
 
172
  return off_targets
173
 
 
238
  df_transcripts = load_transcripts([os.path.join(args.fasta_path, f) for f in os.listdir(args.fasta_path)])
239
 
240
  # process in batches
241
+ batch = 0
242
  num_batches = len(df_transcripts) // BATCH_SIZE_TRANSCRIPTS
243
  num_batches += (len(df_transcripts) % BATCH_SIZE_TRANSCRIPTS > 0)
244
+ for idx in range(0, len(df_transcripts), BATCH_SIZE_TRANSCRIPTS):
245
+ batch += 1
246
  print('Batch {:d} of {:d}'.format(batch, num_batches))
247
+
248
+ # run batch
249
+ idx_stop = min(idx + BATCH_SIZE_TRANSCRIPTS, len(df_transcripts))
250
+ df_on_target, df_off_target = tiger_exhibit(df_transcripts[idx:idx_stop])
251
+
252
+ # save batch results
253
  df_on_target.to_csv('on_target_{:d}.csv'.format(batch), index=False)
254
  df_off_target.to_csv('off_target_{:d}.csv'.format(batch), index=False)
 
 
255
 
256
+ # clear session to prevent memory blow up
257
+ tf.keras.backend.clear_session()