From 4f078b5d068b7d954af7066fbaad4026b0e4c291 Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:43:00 +0000 Subject: [PATCH 1/8] test: add nf-test to `starfusion` --- modules/local/starfusion/detect/main.nf | 3 +- .../starfusion/detect/tests/main.nf.test | 87 ++++++++++++++ .../starfusion/detect/tests/main.nf.test.snap | 112 ++++++++++++++++++ 3 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 modules/local/starfusion/detect/tests/main.nf.test create mode 100644 modules/local/starfusion/detect/tests/main.nf.test.snap diff --git a/modules/local/starfusion/detect/main.nf b/modules/local/starfusion/detect/main.nf index 27396770..10bc6582 100644 --- a/modules/local/starfusion/detect/main.nf +++ b/modules/local/starfusion/detect/main.nf @@ -18,12 +18,13 @@ process STARFUSION { script: def prefix = task.ext.prefix ?: "${meta.id}" def fasta = meta.single_end ? "--left_fq ${reads[0]}" : "--left_fq ${reads[0]} --right_fq ${reads[1]}" + def junction_arg = junction ? "-J ${junction}": "" def args = task.ext.args ?: '' """ STAR-Fusion \\ --genome_lib_dir $reference \\ $fasta \\ - -J $junction \\ + $junction_arg \\ --CPU $task.cpus \\ --examine_coding_effect \\ --output_dir . \\ diff --git a/modules/local/starfusion/detect/tests/main.nf.test b/modules/local/starfusion/detect/tests/main.nf.test new file mode 100644 index 00000000..75e0bfdd --- /dev/null +++ b/modules/local/starfusion/detect/tests/main.nf.test @@ -0,0 +1,87 @@ +nextflow_process { + + name "Test Process STARFUSION" + script "../main.nf" + process "STARFUSION" + + setup { + run("STARFUSION_BUILD") { + script "../../../starfusion/build/main.nf" + process { + """ + input[0] = [ + [ id:'minigenome fasta' ], + file("https://github.com/STAR-Fusion/STAR-Fusion-Tutorial/raw/master/minigenome.fa") + ] + input[1] = [ + [ id:'minigenome gtf' ], + file("https://github.com/STAR-Fusion/STAR-Fusion-Tutorial/raw/master/minigenome.gtf") + ] + + input [2] = file("https://github.com/STAR-Fusion/STAR-Fusion-Tutorial/raw/master/CTAT_HumanFusionLib.mini.dat.gz") + input [3] = "human" + """ + } + } + } + + test("Should run without failures") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [ + file("https://github.com/STAR-Fusion/STAR-Fusion-Tutorial/raw/v0.0.1/rnaseq_1.fastq.gz"), + file("https://github.com/STAR-Fusion/STAR-Fusion-Tutorial/raw/v0.0.1/rnaseq_2.fastq.gz") + ], // reads + [] // empty list for junction, as we don't have a pre-computed Chimeric.out.junction file + ] + input[1] = STARFUSION_BUILD.out.reference.map { it[1] } + """ + } + } + + then { + assert process.success + assert snapshot( + process.out.fusions, + process.out.abridged, + process.out.coding_effect, + process.out.versions + ).match() + } + + } + + test("Should create stub files") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test_stub', single_end:false ], + [ + file("https://github.com/STAR-Fusion/STAR-Fusion-Tutorial/raw/v0.0.1/rnaseq_1.fastq.gz"), + file("https://github.com/STAR-Fusion/STAR-Fusion-Tutorial/raw/v0.0.1/rnaseq_2.fastq.gz") + ], + [] // empty list for junction + ] + input[1] = STARFUSION_BUILD.out.reference.map { it[1] } + """ + } + } + + then { + assert process.success + assert snapshot( + process.out + ).match() + } + + } + +} diff --git a/modules/local/starfusion/detect/tests/main.nf.test.snap b/modules/local/starfusion/detect/tests/main.nf.test.snap new file mode 100644 index 00000000..2532b33d --- /dev/null +++ b/modules/local/starfusion/detect/tests/main.nf.test.snap @@ -0,0 +1,112 @@ +{ + "Should create stub files": { + "content": [ + { + "0": [ + [ + { + "id": "test_stub", + "single_end": false + }, + "test_stub.starfusion.fusion_predictions.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test_stub", + "single_end": false + }, + "test_stub.starfusion.abridged.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + [ + { + "id": "test_stub", + "single_end": false + }, + "test_stub.starfusion.abridged.coding_effect.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "3": [ + "versions.yml:md5,4131f39f483637d95446231588add8f1" + ], + "abridged": [ + [ + { + "id": "test_stub", + "single_end": false + }, + "test_stub.starfusion.abridged.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "coding_effect": [ + [ + { + "id": "test_stub", + "single_end": false + }, + "test_stub.starfusion.abridged.coding_effect.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "fusions": [ + [ + { + "id": "test_stub", + "single_end": false + }, + "test_stub.starfusion.fusion_predictions.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,4131f39f483637d95446231588add8f1" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-16T14:47:21.862981618" + }, + "Should run without failures": { + "content": [ + [ + [ + { + "id": "test", + "single_end": false + }, + "test.starfusion.fusion_predictions.tsv:md5,2adb2aeb44ea98736fb7572e7b5de5c6" + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test.starfusion.abridged.tsv:md5,f37f1cd07a3a6ff41e131dbe369bc093" + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test.starfusion.abridged.coding_effect.tsv:md5,8f5739b0351a725ee96cdf52860d680e" + ] + ], + [ + "versions.yml:md5,4131f39f483637d95446231588add8f1" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-16T14:47:06.459753683" + } +} \ No newline at end of file From 9f3a0d68ecc645c9d6171c52f52bf229d71f2518 Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:43:16 +0000 Subject: [PATCH 2/8] docs: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 690024b2..f4d5e6fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add nf-test to local subworkflow: `QC_WORKFLOW` [#568](https://github.com/nf-core/rnafusion/pull/568) - Add nf-test to local subworkflow: `TRIM_WORKFLOW` [#572](https://github.com/nf-core/rnafusion/pull/572) - Add nf-test to local module: `FUSIONREPORT_DETECT`. Improve `FUSIONREPORT_DOWNLOAD` module [#572](https://github.com/nf-core/rnafusion/pull/577) +- Add nf-test to local module: `STARFUSION`. [#585](https://github.com/nf-core/rnafusion/pull/585) ### Changed From dea8445b8c1fc98a1187a713d47b83df5416bbe7 Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:57:01 +0000 Subject: [PATCH 3/8] feat: allow to use either reads or junction files --- modules/local/starfusion/detect/main.nf | 4 ++-- subworkflows/local/starfusion_workflow.nf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/local/starfusion/detect/main.nf b/modules/local/starfusion/detect/main.nf index 6ab7e9b8..12c4fd94 100644 --- a/modules/local/starfusion/detect/main.nf +++ b/modules/local/starfusion/detect/main.nf @@ -19,8 +19,8 @@ process STARFUSION { script: def prefix = task.ext.prefix ?: "${meta.id}" - def fasta = meta.single_end ? "--left_fq ${reads[0]}" : "--left_fq ${reads[0]} --right_fq ${reads[1]}" - def junction_arg = junction ? "-J ${junction}": "" + def fasta = reads ? (meta.single_end ? "--left_fq ${reads[0]}" : "--left_fq ${reads[0]} --right_fq ${reads[1]}") : "" + def junction_arg = !reads && junction ? "-J ${junction}" : "" def args = task.ext.args ?: '' """ STAR-Fusion \\ diff --git a/subworkflows/local/starfusion_workflow.nf b/subworkflows/local/starfusion_workflow.nf index de99d8e5..e0e58c8b 100644 --- a/subworkflows/local/starfusion_workflow.nf +++ b/subworkflows/local/starfusion_workflow.nf @@ -30,7 +30,7 @@ workflow STARFUSION_WORKFLOW { SAMTOOLS_INDEX_FOR_STARFUSION(STAR_FOR_STARFUSION.out.bam_sorted) ch_versions = ch_versions.mix(SAMTOOLS_INDEX_FOR_STARFUSION.out.versions) bam_sorted_indexed = STAR_FOR_STARFUSION.out.bam_sorted.join(SAMTOOLS_INDEX_FOR_STARFUSION.out.bai) - reads_junction = reads.join(STAR_FOR_STARFUSION.out.junction ) + reads_junction = reads.join(STAR_FOR_STARFUSION.out.junction ) // TODO: This join is not needed as STARFUSION can simply read from the junction file: https://github.com/STAR-Fusion/STAR-Fusion/wiki#alternatively-kickstart-mode-running-star-yourself-and-then-running-star-fusion-using-the-existing-outputs if (params.cram.contains('starfusion')){ SAMTOOLS_VIEW_FOR_STARFUSION (bam_sorted_indexed, ch_fasta, [] ) From 9aff4ea4e1574e69780c1396dfba65139197359f Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:57:08 +0000 Subject: [PATCH 4/8] test: update snaps --- .../starfusion/detect/tests/main.nf.test.snap | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/local/starfusion/detect/tests/main.nf.test.snap b/modules/local/starfusion/detect/tests/main.nf.test.snap index 2532b33d..f65f94b0 100644 --- a/modules/local/starfusion/detect/tests/main.nf.test.snap +++ b/modules/local/starfusion/detect/tests/main.nf.test.snap @@ -30,7 +30,7 @@ ] ], "3": [ - "versions.yml:md5,4131f39f483637d95446231588add8f1" + "versions.yml:md5,a8fb6344fdf740dde0941048313fc243" ], "abridged": [ [ @@ -60,15 +60,15 @@ ] ], "versions": [ - "versions.yml:md5,4131f39f483637d95446231588add8f1" + "versions.yml:md5,a8fb6344fdf740dde0941048313fc243" ] } ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-16T14:47:21.862981618" + "timestamp": "2024-12-19T18:42:06.988178092" }, "Should run without failures": { "content": [ @@ -78,7 +78,7 @@ "id": "test", "single_end": false }, - "test.starfusion.fusion_predictions.tsv:md5,2adb2aeb44ea98736fb7572e7b5de5c6" + "test.starfusion.fusion_predictions.tsv:md5,82834fffed743afe07da82bd56d50c99" ] ], [ @@ -87,7 +87,7 @@ "id": "test", "single_end": false }, - "test.starfusion.abridged.tsv:md5,f37f1cd07a3a6ff41e131dbe369bc093" + "test.starfusion.abridged.tsv:md5,d6d20fdd4b5cba21b9c0ebf8e0ea19ff" ] ], [ @@ -96,17 +96,17 @@ "id": "test", "single_end": false }, - "test.starfusion.abridged.coding_effect.tsv:md5,8f5739b0351a725ee96cdf52860d680e" + "test.starfusion.abridged.coding_effect.tsv:md5,95dfce6fdaf3589f23881fe1e855c62b" ] ], [ - "versions.yml:md5,4131f39f483637d95446231588add8f1" + "versions.yml:md5,a8fb6344fdf740dde0941048313fc243" ] ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.2" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-16T14:47:06.459753683" + "timestamp": "2024-12-19T18:41:49.150362156" } } \ No newline at end of file From a369518bae364760580be681ce46b45192e28beb Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Thu, 19 Dec 2024 19:08:46 +0000 Subject: [PATCH 5/8] docs: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1cfe307..25152aca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add nf-test to local module: `FUSIONREPORT_DETECT`. Improve `FUSIONREPORT_DOWNLOAD` module [#577](https://github.com/nf-core/rnafusion/pull/577) - Add nf-test to local subworkflow: `ARRIBA_WORKFLOW` [#578](https://github.com/nf-core/rnafusion/pull/578) - Add nf-test to local module: `STARFUSION_BUILD`. [#585](https://github.com/nf-core/rnafusion/pull/585) - +- Add nf-test to local module: `STARFUSION_DETECT`. [#586](https://github.com/nf-core/rnafusion/pull/586) ### Changed From 6f2a382e9edefbbb078093722c2303961e508b14 Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Thu, 19 Dec 2024 19:24:55 +0000 Subject: [PATCH 6/8] fix: add junction if provided --- modules/local/starfusion/detect/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/local/starfusion/detect/main.nf b/modules/local/starfusion/detect/main.nf index 12c4fd94..fd0a7d46 100644 --- a/modules/local/starfusion/detect/main.nf +++ b/modules/local/starfusion/detect/main.nf @@ -20,7 +20,7 @@ process STARFUSION { script: def prefix = task.ext.prefix ?: "${meta.id}" def fasta = reads ? (meta.single_end ? "--left_fq ${reads[0]}" : "--left_fq ${reads[0]} --right_fq ${reads[1]}") : "" - def junction_arg = !reads && junction ? "-J ${junction}" : "" + def junction_arg = junction ? "-J ${junction}" : "" def args = task.ext.args ?: '' """ STAR-Fusion \\ From ed4855edee9e3c01b3b8c8bb12c120c5676ebc82 Mon Sep 17 00:00:00 2001 From: Anabella Trigila <18577080+atrigila@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:07:14 -0300 Subject: [PATCH 7/8] Update modules/local/starfusion/detect/main.nf Co-authored-by: Annick Renevey <47788523+rannick@users.noreply.github.com> --- modules/local/starfusion/detect/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/local/starfusion/detect/main.nf b/modules/local/starfusion/detect/main.nf index fd0a7d46..f1f3d6f9 100644 --- a/modules/local/starfusion/detect/main.nf +++ b/modules/local/starfusion/detect/main.nf @@ -19,7 +19,7 @@ process STARFUSION { script: def prefix = task.ext.prefix ?: "${meta.id}" - def fasta = reads ? (meta.single_end ? "--left_fq ${reads[0]}" : "--left_fq ${reads[0]} --right_fq ${reads[1]}") : "" + def fastq_arg = reads ? (meta.single_end ? "--left_fq ${reads[0]}" : "--left_fq ${reads[0]} --right_fq ${reads[1]}") : "" def junction_arg = junction ? "-J ${junction}" : "" def args = task.ext.args ?: '' """ From f42d9dcf8917dc4c5ab982bc64b58d44ebff2298 Mon Sep 17 00:00:00 2001 From: Anabella Trigila <18577080+atrigila@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:07:21 -0300 Subject: [PATCH 8/8] Update modules/local/starfusion/detect/main.nf Co-authored-by: Annick Renevey <47788523+rannick@users.noreply.github.com> --- modules/local/starfusion/detect/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/local/starfusion/detect/main.nf b/modules/local/starfusion/detect/main.nf index f1f3d6f9..00c78efc 100644 --- a/modules/local/starfusion/detect/main.nf +++ b/modules/local/starfusion/detect/main.nf @@ -25,7 +25,7 @@ process STARFUSION { """ STAR-Fusion \\ --genome_lib_dir $reference \\ - $fasta \\ + $fastq_arg \\ $junction_arg \\ --CPU $task.cpus \\ --examine_coding_effect \\