diff --git a/CHANGELOG.md b/CHANGELOG.md index f09fb222..c75b3bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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 [#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) - Added a new module `CTATSPLICING_STARTOCANCERINTRONS` and a new parameter `--ctatsplicing`. This options creates reports on cancer splicing abberations and requires one or both of `--arriba` and `--starfusion` to be given. [#587](https://github.com/nf-core/rnafusion/pull/587) ### Changed diff --git a/modules/local/starfusion/detect/main.nf b/modules/local/starfusion/detect/main.nf index 83b0dc2f..00c78efc 100644 --- a/modules/local/starfusion/detect/main.nf +++ b/modules/local/starfusion/detect/main.nf @@ -19,13 +19,14 @@ 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 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 ?: '' """ STAR-Fusion \\ --genome_lib_dir $reference \\ - $fasta \\ - -J $junction \\ + $fastq_arg \\ + $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..f65f94b0 --- /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,a8fb6344fdf740dde0941048313fc243" + ], + "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,a8fb6344fdf740dde0941048313fc243" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2024-12-19T18:42:06.988178092" + }, + "Should run without failures": { + "content": [ + [ + [ + { + "id": "test", + "single_end": false + }, + "test.starfusion.fusion_predictions.tsv:md5,82834fffed743afe07da82bd56d50c99" + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test.starfusion.abridged.tsv:md5,d6d20fdd4b5cba21b9c0ebf8e0ea19ff" + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test.starfusion.abridged.coding_effect.tsv:md5,95dfce6fdaf3589f23881fe1e855c62b" + ] + ], + [ + "versions.yml:md5,a8fb6344fdf740dde0941048313fc243" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2024-12-19T18:41:49.150362156" + } +} \ No newline at end of file diff --git a/subworkflows/local/starfusion_workflow.nf b/subworkflows/local/starfusion_workflow.nf index 2083036f..82ae6f76 100644 --- a/subworkflows/local/starfusion_workflow.nf +++ b/subworkflows/local/starfusion_workflow.nf @@ -34,7 +34,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.ctatsplicing || params.all) { CTATSPLICING_WORKFLOW(