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 for FUSIONCATCHER subworkflow #591

Merged
merged 12 commits into from
Jan 7, 2025
11 changes: 5 additions & 6 deletions modules/local/fusioncatcher/detect/main.nf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
process FUSIONCATCHER {
process FUSIONCATCHER_DETECT {
tag "$meta.id"
label 'process_high'

conda "${moduleDir}/environment.yml"
container "community.wave.seqera.io/library/fusioncatcher:1.33--4733482b637ef92f"

input:
tuple val(meta), path(fasta)
path reference
tuple val(meta), path(fastqs, stageAs: "input/*")
tuple val(meta2), path(reference)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


output:
tuple val(meta), path("*.fusioncatcher.fusion-genes.txt") , optional:true , emit: fusions
Expand All @@ -21,12 +21,11 @@ process FUSIONCATCHER {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def reads = fasta.toString().replace(" ", ",")
def single_end = meta.single_end ? "--single-end" : ""
"""
fusioncatcher.py \\
-d $reference \\
-i $reads \\
-d ${reference} \\
-i input \\
-p $task.cpus \\
-o . \\
--skip-blat \\
Expand Down
5 changes: 3 additions & 2 deletions modules/local/fusioncatcher/download/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ process FUSIONCATCHER_DOWNLOAD {
container "community.wave.seqera.io/library/fusioncatcher:1.33--4733482b637ef92f"

output:
path "*" , emit: reference
path "versions.yml" , emit: versions
tuple env(meta), path("*"), emit: reference
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -18,6 +18,7 @@ process FUSIONCATCHER_DOWNLOAD {
def args2 = task.ext.args2 ?: ''
def human_version = "v102"
def url = "http://sourceforge.net/projects/fusioncatcher/files/data/human_${human_version}.tar.gz.aa"
meta = [ id: "human_${human_version}" ]
"""
if wget --spider "$url" 2>/dev/null; then
wget $args $url
Expand Down
45 changes: 45 additions & 0 deletions subworkflows/local/fusioncatcher_workflow/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
include { FUSIONCATCHER_DETECT } from '../../../modules/local/fusioncatcher/detect/main'

// TODO: Remove fusioncatcher_fusions as parameter.
// TODO: remove dummy file. Work with Channel.empty()
// TODO: if the files were already produced and the user want to skip the module because of this, they should be taken them from the sample sheet
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open issues?
Using fusioncatcher_fusions is practical if you want to run the last part of rnafusion: fusionreport and fusioninspector

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rannick thanks for looking into this! Let me understand this correctly, the fusioncatcher_fusions parameter can be used to feed one single file and hence skip the FUSIONCATCHER_DETECT process, am I right? I was wondering whether this single file should contain the data for all the samples that the user want to analyze with fusionreport and fusioninspector, or if the user has to supply one file per sample.
If the second scenario is the correct one, then I got it wrong and this approach is almost ok, just a little bit of fine tunning. But if the first scenario is the correct, then we should change more things

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes fusioncatcher_fusions allows to skip FUSIONCATCHER_DETECT.
That is a good point about the samples, the files probably have to be fed per sample

// TODO: harmonize `run_fusioncatcher` and `fusioncatcher_only` parameters at main workflow level to activate/skip this one.

workflow FUSIONCATCHER_WORKFLOW {
take:
reads // channel [ meta, [ fastqs ] ]
fusioncatcher_ref // channel [ meta, path ]
run_fusioncatcher // boolean
all // boolean
fusioninspector_only // boolean
fusioncatcher_fusions // path, string

main:
ch_versions = Channel.empty()
ch_dummy_file = file("$baseDir/assets/dummy_file_fusioncatcher.txt", checkIfExists: true)

if (( run_fusioncatcher || all) && !fusioninspector_only ) {
if (fusioncatcher_fusions){

ch_fusioncatcher_fusions = reads.combine(Channel.value(file(fusioncatcher_fusions, checkIfExists:true)))
.map { meta, reads, fusions -> [ meta, fusions ] }
} else {

FUSIONCATCHER_DETECT (
reads,
fusioncatcher_ref
)
ch_fusioncatcher_fusions = FUSIONCATCHER_DETECT.out.fusions
ch_versions = ch_versions.mix(FUSIONCATCHER_DETECT.out.versions)
}
}
else {
ch_fusioncatcher_fusions = reads.combine(Channel.value(file(ch_dummy_file, checkIfExists:true)))
.map { meta, reads, fusions -> [ meta, fusions ] }
}

emit:
fusions = ch_fusioncatcher_fusions // channel [ meta, fusions ]
versions = ch_versions // channel [ versions ]
}

65 changes: 65 additions & 0 deletions subworkflows/local/fusioncatcher_workflow/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
nextflow_workflow {

name "Test Subworkflow FUSIONCATCHER_WORKFLOW"
script "../main.nf"
workflow "FUSIONCATCHER_WORKFLOW"
tag "subworkflow"
tag "fusioncatcher"
tag "fusioncatcher/download"
tag "fusioncatcher/detect"

// Test
test("FUSIONCATCHER_WORKFLOW - Homo sapiens - FASTQs chr4") {

setup {
// Download reference files for fusioncatch
run("FUSIONCATCHER_DOWNLOAD") {
script "../../../../modules/local/fusioncatcher/download/main.nf"
process {
"""
// No arguments required. Human version v102
"""
}
}
}

when {
workflow {
"""
// ch_reads
input[0] = Channel.of(
[
[ id: "test_fastqs", single_end: false ],
[
file("https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/rnafusion/testdata/human/reads_1.fq.gz", checkIfExists: true),
file("https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/rnafusion/testdata/human/reads_2.fq.gz", checkIfExists: true)
]
] )

// ch_references
input[1] = FUSIONCATCHER_DOWNLOAD.out.reference

// fusioncatcher (boolean)
input[2] = true

// all (boolean)
input[3] = true

// fusioninspector_only (boolean)
input[4] = false

// fusioncatcher_fusions (string path)
input[5] = null
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out).match() }
)
}
}

}
37 changes: 37 additions & 0 deletions subworkflows/local/fusioncatcher_workflow/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"FUSIONCATCHER_WORKFLOW - Homo sapiens - FASTQs chr4": {
"content": [
{
"0": [
[
{
"id": "test_fastqs",
"single_end": false
},
"test_fastqs.fusioncatcher.fusion-genes.txt:md5,c826a24c49abfcec8164c478e1e74892"
]
],
"1": [
"versions.yml:md5,6462518e02774293fa221cead8373305"
],
"fusions": [
[
{
"id": "test_fastqs",
"single_end": false
},
"test_fastqs.fusioncatcher.fusion-genes.txt:md5,c826a24c49abfcec8164c478e1e74892"
]
],
"versions": [
"versions.yml:md5,6462518e02774293fa221cead8373305"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-12-18T21:26:47.477736"
}
}
2 changes: 1 addition & 1 deletion tests/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ process {
resourceLimits = [
cpus: 4,
memory: '15.GB',
time: '1.h'
time: '4.h'
]
}
47 changes: 13 additions & 34 deletions tests/test_build.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,25 @@
"test_build": {
"content": [
[
"bedops",
"bedops/Homo_sapiens.GRCh38.102_rrna_intervals.gtf.bed",
"gatk4",
"gatk4/Homo_sapiens.GRCh38.102.dna.primary_assembly.dict",
"gffread",
"gffread/Homo_sapiens.GRCh38.102.fasta",
"fastqc",
"fastqc/test_1_fastqc.html",
"fastqc/test_1_fastqc.zip",
"fastqc/test_2_fastqc.html",
"fastqc/test_2_fastqc.zip",
"pipeline_info",
"references",
"references/ensembl",
"references/ensembl/Homo_sapiens.GRCh38.102.chr.gtf",
"references/ensembl/Homo_sapiens.GRCh38.102.dna.primary_assembly.fa",
"references/ensembl/Homo_sapiens.GRCh38.102.dna.primary_assembly.fa.fai",
"references/ensembl/Homo_sapiens.GRCh38.102.genepred",
"references/ensembl/Homo_sapiens.GRCh38.102.gtf",
"references/ensembl/Homo_sapiens.GRCh38.102.refflat",
"references/ensembl/Homo_sapiens.GRCh38.102_rrna_intervals.gtf.interval_list",
"references/hgnc",
"references/hgnc/HGNC-DB-timestamp.txt",
"references/hgnc/hgnc_complete_set.txt",
"rrnatranscripts",
"rrnatranscripts/Homo_sapiens.GRCh38.102_rrna_intervals.gtf"
"pipeline_info/nf_core_pipeline_software_mqc_versions.yml"
],
[
"Homo_sapiens.GRCh38.102_rrna_intervals.gtf.bed:md5,5bc3ccc76735ae46699a75269f0ea65b",
"Homo_sapiens.GRCh38.102.dna.primary_assembly.dict:md5,092f1bf29fce906ff7b5ece02b4b21c8",
"Homo_sapiens.GRCh38.102.fasta:md5,d1f17b045dc60c49f2cc29e30006afc0",
"Homo_sapiens.GRCh38.102.chr.gtf:md5,0069687307852c63596b4d2ebdbbaf0c",
"Homo_sapiens.GRCh38.102.dna.primary_assembly.fa.fai:md5,d527f3eb6b664020cf4d882b5820056f",
"Homo_sapiens.GRCh38.102.genepred:md5,59c577ca4ab033c0ce1feac1e387bcab",
"Homo_sapiens.GRCh38.102.gtf:md5,defac755cd9aa4e82ec33398c27745ef",
"Homo_sapiens.GRCh38.102.refflat:md5,ef095e13743811c31d44752c32e9673e",
"Homo_sapiens.GRCh38.102_rrna_intervals.gtf.interval_list:md5,0abf61877f65247b15c438d605d85599",
"hgnc_complete_set.txt:md5,a563a2f8432ec0ab7d3dc74d769102b8",
"Homo_sapiens.GRCh38.102_rrna_intervals.gtf:md5,744bf505deb50837b15441e808cad345"
"test_1_fastqc.html:md5,fce82f01594d12b109776ced37ec0739",
"test_1_fastqc.zip:md5,fd0eae421abf76c38f60656bc0fcf5cf",
"test_2_fastqc.html:md5,40f5f42c62a0e36def4fc3d3c48089cd",
"test_2_fastqc.zip:md5,1aaf903d6ea3957abe6f03ad832f82fa"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.2"
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-12-09T18:20:09.914393513"
"timestamp": "2024-12-18T21:05:30.032816"
}
}
94 changes: 94 additions & 0 deletions tests/test_cosmic.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"test cosmic no fastp trim": {
"content": [
1,
{
"FASTQC": {
"fastqc": "0.12.1"
},
"Workflow": {
"nf-core/rnafusion": "v4.0.0dev"
}
},
[
"fastqc",
"fastqc/test_1_fastqc.html",
"fastqc/test_1_fastqc.zip",
"fastqc/test_2_fastqc.html",
"fastqc/test_2_fastqc.zip",
"pipeline_info",
"pipeline_info/nf_core_pipeline_software_mqc_versions.yml"
],
[
"test_1_fastqc.html:md5,fce82f01594d12b109776ced37ec0739",
"test_1_fastqc.zip:md5,166d13bbf5ebfcb24eb30c78b129a172",
"test_2_fastqc.html:md5,40f5f42c62a0e36def4fc3d3c48089cd",
"test_2_fastqc.zip:md5,4747768318b29ce4effe6c572ccbc36c"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-12-18T21:06:31.911972"
},
"test cosmic with fastp trim": {
"content": [
3,
{
"FASTP": {
"fastp": "0.23.4"
},
"FASTQC": {
"fastqc": "0.12.1"
},
"FASTQC_FOR_FASTP": {
"fastqc": "0.12.1"
},
"Workflow": {
"nf-core/rnafusion": "v4.0.0dev"
}
},
[
"fastp",
"fastp/test.fastp.html",
"fastp/test.fastp.json",
"fastp/test.fastp.log",
"fastp/test_1.fastp.fastq.gz",
"fastp/test_2.fastp.fastq.gz",
"fastqc",
"fastqc/test_1_fastqc.html",
"fastqc/test_1_fastqc.zip",
"fastqc/test_2_fastqc.html",
"fastqc/test_2_fastqc.zip",
"fastqc_for_fastp",
"fastqc_for_fastp/test_trimmed_1_fastqc.html",
"fastqc_for_fastp/test_trimmed_1_fastqc.zip",
"fastqc_for_fastp/test_trimmed_2_fastqc.html",
"fastqc_for_fastp/test_trimmed_2_fastqc.zip",
"pipeline_info",
"pipeline_info/nf_core_pipeline_software_mqc_versions.yml"
],
[
"test.fastp.html:md5,d26a7f988fd5ed667832d391ab06e202",
"test.fastp.json:md5,ebf549d5793aa40efcd9e1ca41504f26",
"test.fastp.log:md5,1c04b14e212aac5ace51f9bd25859f23",
"test_1.fastp.fastq.gz:md5,2a5519a03fb226ae2379b1150b02ff0b",
"test_2.fastp.fastq.gz:md5,4b8d3865b857e6bfae0035a45b2cdc27",
"test_1_fastqc.html:md5,fce82f01594d12b109776ced37ec0739",
"test_1_fastqc.zip:md5,f9e7e4dbf71703d98214cfd5cb79ee07",
"test_2_fastqc.html:md5,40f5f42c62a0e36def4fc3d3c48089cd",
"test_2_fastqc.zip:md5,7428e5d3c26f0934c75b15de29d6af5c",
"test_trimmed_1_fastqc.html:md5,2c2256226962e9be8c20e5720b8a51ab",
"test_trimmed_1_fastqc.zip:md5,3b8731204e07bfe7a6ecce66ba8617db",
"test_trimmed_2_fastqc.html:md5,343c493ba215089723e9d4df7180a0fc",
"test_trimmed_2_fastqc.zip:md5,fcec86b3067854ffdadd00db615f0cdd"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-12-18T21:06:00.758494"
}
}
8 changes: 7 additions & 1 deletion workflows/rnafusion.nf
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ workflow RNAFUSION {


//Run fusioncatcher
// TODO: check this inputs!
FUSIONCATCHER_WORKFLOW (
ch_reads_fusioncatcher
ch_reads_fusioncatcher,
params.fusioncatcher_ref, // channel [ meta, path ]
params.run_fusioncatcher,
params.all,
params.fusioninspector_only,
params.fusioncatcher_fusions
)
ch_versions = ch_versions.mix(FUSIONCATCHER_WORKFLOW.out.versions)

Expand Down
Loading