From 015097c25527ce18f50a7d49e8f942dfc2d69a98 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 3 Aug 2023 14:36:11 +0200 Subject: [PATCH 1/2] summary processes don't modify input file, fixing resume --- CHANGELOG.md | 2 ++ modules/local/alignment_summary.nf | 2 +- modules/local/clustering_summary.nf | 2 +- modules/local/merging_summary.nf | 2 +- templates/alignment_summary.py | 3 ++- templates/clustering_summary.py | 3 ++- templates/merging_summary.py | 2 +- workflows/crisprseq_targeted.nf | 9 +++++++++ 8 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5d26623..76d9871a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Summary processes don't modify the input file anymore, allowing resuming these processes ([#65](https://github.com/nf-core/crisprseq/pull/65)) + ### Deprecated ## [v2.0.0 - Paprika Lovelace](https://github.com/nf-core/crisprseq/releases/tag/2.0.0) - [05.07.2023] diff --git a/modules/local/alignment_summary.nf b/modules/local/alignment_summary.nf index 2805cd92..3520689f 100644 --- a/modules/local/alignment_summary.nf +++ b/modules/local/alignment_summary.nf @@ -11,7 +11,7 @@ process ALIGNMENT_SUMMARY { tuple val(meta), path(reads), path(summary) output: - tuple val(meta), path(summary), emit: summary + tuple val(meta), path("*_alignment_summary.csv"), emit: summary when: task.ext.when == null || task.ext.when diff --git a/modules/local/clustering_summary.nf b/modules/local/clustering_summary.nf index a134bdaf..b31d4f36 100644 --- a/modules/local/clustering_summary.nf +++ b/modules/local/clustering_summary.nf @@ -11,7 +11,7 @@ process CLUSTERING_SUMMARY { tuple val(meta), path(reads), path(summary) output: - tuple val(meta), path(summary), emit: summary + tuple val(meta), path("*_clustering_summary.csv"), emit: summary when: task.ext.when == null || task.ext.when diff --git a/modules/local/merging_summary.nf b/modules/local/merging_summary.nf index dcd31e04..cf9c158b 100644 --- a/modules/local/merging_summary.nf +++ b/modules/local/merging_summary.nf @@ -12,7 +12,7 @@ process MERGING_SUMMARY { output: - tuple val(meta), path("*_summary.csv"), emit: summary + tuple val(meta), path("*_merging_summary.csv"), emit: summary when: task.ext.when == null || task.ext.when diff --git a/templates/alignment_summary.py b/templates/alignment_summary.py index 5adedf93..12dd6109 100644 --- a/templates/alignment_summary.py +++ b/templates/alignment_summary.py @@ -12,7 +12,8 @@ summary_lines = summary.readlines() add_line = True -with open("$summary", "w") as output_file: +outname = "$summary".replace("_clustering_summary.csv", "_alignment_summary.csv") +with open(outname, "w") as output_file: for line in summary_lines: if "aligned-reads" not in line: output_file.write(line) diff --git a/templates/clustering_summary.py b/templates/clustering_summary.py index 208b089b..ea501964 100644 --- a/templates/clustering_summary.py +++ b/templates/clustering_summary.py @@ -12,7 +12,8 @@ summary_lines = summary.readlines() add_line = True -with open("$summary", "w") as output_file: +outname = "$summary".replace("_merging_summary.csv", "_clustering_summary.csv") +with open(outname, "w") as output_file: for line in summary_lines: if "clustered-reads" not in line: output_file.write(line) diff --git a/templates/merging_summary.py b/templates/merging_summary.py index 804a5be3..2d88e24a 100755 --- a/templates/merging_summary.py +++ b/templates/merging_summary.py @@ -34,7 +34,7 @@ else: prefix = "$meta.id" -with open(f"{prefix}_summary.csv", "w") as output_file: +with open(f"{prefix}_merging_summary.csv", "w") as output_file: output_file.write("class, count\\n") output_file.write(f"raw-reads, {raw_reads_count} (100.0%)\\n") output_file.write( diff --git a/workflows/crisprseq_targeted.nf b/workflows/crisprseq_targeted.nf index 6556d79d..90917137 100644 --- a/workflows/crisprseq_targeted.nf +++ b/workflows/crisprseq_targeted.nf @@ -341,6 +341,15 @@ workflow CRISPRSEQ_TARGETED { .join(PEAR.out.assembled, remainder: true) .join(SEQTK_SEQ_MASK.out.fastx) .join(CUTADAPT.out.log) + .map { meta, reads, assembled, masked, trimmed -> + if (assembled == null) { + assembled = file('null_a') + } + if (trimmed == "null") { + trimmed = file('null_t') + } + return [ meta, reads, assembled, masked, trimmed ] + } .set { ch_merging_summary_data } } else { ch_cat_fastq.paired From 7463aadcf562fdb0f33bfda55d009a5c8fc070f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Thu, 3 Aug 2023 14:59:12 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76d9871a..573ec572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Summary processes don't modify the input file anymore, allowing resuming these processes ([#65](https://github.com/nf-core/crisprseq/pull/65)) +- Summary processes don't modify the input file anymore, allowing resuming these processes ([#66](https://github.com/nf-core/crisprseq/pull/66)) ### Deprecated