Commit 42c439e1 authored by Carlos de Lannoy's avatar Carlos de Lannoy
Browse files

additional args for inference

parent a0ad25a4
......@@ -110,6 +110,11 @@ inference_mode = ('--inference-mode', {
'help': 'Run inference [once] on fast5s available in folder, or [watch] folder indefinitely for new reads [default: watch]'
})
copy_reads = ('--copy-reads', {
'action': 'store_true',
'help': 'Copy reads to the output directory before starting processing'
})
# --- output ---
out_dir = ('--out-dir', {
'type': lambda x: parse_output_path(x),
......@@ -289,7 +294,7 @@ def get_training_parser():
def get_run_inference_parser():
parser = argparse.ArgumentParser(description='Start up inference routine and watch a fast5 directory for reads.')
for arg in (fast5_in, out_dir, model, inference_mode, mem, batch_size):
for arg in (fast5_in, out_dir, model, inference_mode, mem, batch_size, copy_reads):
parser.add_argument(arg[0], **arg[1])
# parser.add_argument('--continuous-nn', action='store_true',help='Used RNN can handle continuous reads.')
return parser
......
......@@ -6,7 +6,7 @@ channels:
dependencies:
- python=3.8.10
- matplotlib=3.5.1 # avoid issues with heatmaps
- tensorflow=2.4.1
- tensorflow-gpu=2.4.1
- pandas=1.3.1
- bokeh=2.3.3
- snakemake=5.26.1
......
import sys, signal, os, h5py
import sys, signal, os, h5py, shutil
from pathlib import Path
from datetime import datetime
import tensorflow as tf
......@@ -94,7 +94,9 @@ def main(args):
run_time = datetime.now() - start_time
read_manager_process.terminate()
read_manager_process.join()
print(f'runtime was {run_time.seconds} s')
with open(args.out_dir + 'run_stats.log', 'w') as fh:
fh.write(f'wall_time: {run_time.seconds}s')
print(f'wall time was {run_time.seconds} s')
if abundance_mode:
freq_array = abundance_array / max(abundance_array.sum(), 1)
abundance_txt = 'kmer,abundance,frequency\n' + \
......@@ -105,5 +107,8 @@ def main(args):
if __name__ == '__main__':
parser = get_run_inference_parser()
args = parser.parse_args()
if args.copy_reads:
fast5_in_new = parse_output_path(args.out_dir + 'fast5_in/', clean=True)
shutil.copytree(args.fast5_in, fast5_in_new, dirs_exist_ok=True)
args.fast5_in = fast5_in_new
main(args)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment