Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nf-test to local module STARFUSION_DETECT #586

Merged
merged 12 commits into from
Dec 20, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

### Changed

Expand Down
5 changes: 3 additions & 2 deletions modules/local/starfusion/detect/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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 fasta = reads ? (meta.single_end ? "--left_fq ${reads[0]}" : "--left_fq ${reads[0]} --right_fq ${reads[1]}") : ""
atrigila marked this conversation as resolved.
Show resolved Hide resolved
def junction_arg = junction ? "-J ${junction}" : ""
def args = task.ext.args ?: ''
"""
STAR-Fusion \\
--genome_lib_dir $reference \\
$fasta \\
atrigila marked this conversation as resolved.
Show resolved Hide resolved
-J $junction \\
$junction_arg \\
rannick marked this conversation as resolved.
Show resolved Hide resolved
--CPU $task.cpus \\
--examine_coding_effect \\
--output_dir . \\
Expand Down
87 changes: 87 additions & 0 deletions modules/local/starfusion/detect/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -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()
}

}

}
112 changes: 112 additions & 0 deletions modules/local/starfusion/detect/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 1 addition & 1 deletion subworkflows/local/starfusion_workflow.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
rannick marked this conversation as resolved.
Show resolved Hide resolved

if (params.cram.contains('starfusion')){
SAMTOOLS_VIEW_FOR_STARFUSION (bam_sorted_indexed, ch_fasta, [] )
Expand Down
Loading