From f152ce213912ec631e3af442771427071db5773d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20B=C5=99inda?= Date: Wed, 6 Mar 2024 12:21:28 +0100 Subject: [PATCH] Make attotree read the list of input files from a file --- workflow/rules/asm.smk | 17 ++++++++++++++++- workflow/rules/init.smk | 11 +++++++++++ workflow/rules/tree.smk | 4 ++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/workflow/rules/asm.smk b/workflow/rules/asm.smk index 8ee354e..ed82906 100644 --- a/workflow/rules/asm.smk +++ b/workflow/rules/asm.smk @@ -3,7 +3,22 @@ ## -rule asm_list: +rule asm_list_unsorted: + """ + Make an unsorted list of input assemblies + """ + output: + list=fn_asm_list_unsorted(_batch="{batch}"), + input: + fa=w_batch_asms, + run: + dump_file_list( + input.fa, + output.list, + ) + + +rule asm_list_sorted: """ Make a list of assemblies as they will appear in the .tar.xz archive """ diff --git a/workflow/rules/init.smk b/workflow/rules/init.smk index c0609be..d149668 100644 --- a/workflow/rules/init.smk +++ b/workflow/rules/init.smk @@ -148,6 +148,10 @@ def fn_hist_summary(_batch, _protocol): # ASM +def fn_asm_list_unsorted(_batch): + return f"{dir_intermediate()}/asm/{_batch}.asm.list_unsorted" + + def fn_asm_seq_dir(_batch): return f"{dir_intermediate()}/asm/{_batch}" @@ -235,6 +239,13 @@ def generate_file_list(input_list_fn, output_list_fn, filename_function): g.write(fn + "\n") +# dump list of files into a file +def dump_file_list(input_files, output_list_fn): + with open(output_list_fn, "w") as g: + for x in input_files: + g.write(x + "\n") + + def load_list(fn): try: with open(fn) as f: diff --git a/workflow/rules/tree.smk b/workflow/rules/tree.smk index 87e9f4e..79ce4c7 100644 --- a/workflow/rules/tree.smk +++ b/workflow/rules/tree.smk @@ -71,7 +71,7 @@ if not config["trees_required"]: output: nw=fn_tree_dirty(_batch="{batch}"), input: - w_batch_asms, + nw=fn_asm_list_unsorted(_batch="{batch}"), threads: config["attotree_threads"] params: k=config["attotree_kmer_length"], @@ -85,6 +85,6 @@ if not config["trees_required"]: -t {params.t} \\ -k {params.k} \\ -s {params.s} \\ - {input} \\ + -L {input.nw} \\ | tee {output.nw} """