Skip to content

Commit

Permalink
nf-test for pilon (#5293)
Browse files Browse the repository at this point in the history
* nf-test for pilon

* linting for license

* Add stub and extra test

* Swap to testdata_base_path

* Add missing END_VERSIONS and alignment

* Add optional outputs to stub

---------

Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com>
  • Loading branch information
thanhleviet and SPPearce authored Jun 27, 2024
1 parent 5438150 commit 0aef8ea
Show file tree
Hide file tree
Showing 9 changed files with 481 additions and 41 deletions.
25 changes: 22 additions & 3 deletions modules/nf-core/pilon/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process PILON {

input:
tuple val(meta), path(fasta)
tuple val(meta_bam), path(bam), path(bai)
tuple val(meta2), path(bam), path(bai)
val pilon_mode

output:
Expand All @@ -24,8 +24,8 @@ process PILON {
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def valid_mode = ["frags", "jumps", "unpaired", "bam"]
if ( !valid_mode.contains(pilon_mode) ) { error "Unrecognised mode to run Pilon. Options: ${valid_mode.join(', ')}" }
"""
Expand All @@ -39,5 +39,24 @@ process PILON {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
pilon: \$(echo \$(pilon --version) | sed 's/^.*version //; s/ .*\$//' )
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def valid_mode = ["frags", "jumps", "unpaired", "bam"]
if ( !valid_mode.contains(pilon_mode) ) { error "Unrecognised mode to run Pilon. Options: ${valid_mode.join(', ')}" }
"""
touch ${prefix}.fasta
touch ${prefix}.vcf
touch ${prefix}.change
touch ${prefix}.bed
touch ${prefix}.wig
cat <<-END_VERSIONS > versions.yml
"${task.process}":
pilon: \$(echo \$(pilon --version) | sed 's/^.*version //; s/ .*\$//' )
END_VERSIONS
"""

}
9 changes: 7 additions & 2 deletions modules/nf-core/pilon/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ tools:
documentation: "https://github.com/broadinstitute/pilon/wiki/Requirements-&-Usage"
tool_dev_url: "https://github.com/broadinstitute/pilon"
doi: "10.1371/journal.pone.0112963"
licence: "['GPL v2']"
licence: ["GPL-2.0-or-later"]
input:
- meta:
type: map
description: |
Groovy Map containing sample information
Groovy Map containing sample information for the fasta
e.g. [ id:'test', single_end:false ]
- fasta:
type: file
description: FASTA of the input genome
pattern: "*.{fasta}"
- meta2:
type: map
description: |
Groovy Map containing sample information for the bam file
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: BAM file of reads aligned to the input genome
Expand Down
116 changes: 116 additions & 0 deletions modules/nf-core/pilon/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
nextflow_process {

name "Test Process PILON"
script "../main.nf"
process "PILON"

tag "modules"
tag "modules_nfcore"
tag "pilon"


test("homo sapiens bam") {

when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genome.fasta", checkIfExists: true)
]
input[1] = [ [ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai", checkIfExists: true),
]
input[2] = "bam"
"""
}
}

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

}

test("homo sapiens bam - stub") {
options "-stub"
when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genome.fasta", checkIfExists: true)
]
input[1] = [ [ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai", checkIfExists: true),
]
input[2] = "bam"
"""
}
}

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

}

test("homo sapiens frags") {

when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genome.fasta", checkIfExists: true)
]
input[1] = [ [ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai", checkIfExists: true),
]
input[2] = "frags"
"""
}
}

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

}

test("homo sapiens frags - stub") {
options "-stub"
when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genome.fasta", checkIfExists: true)
]
input[1] = [ [ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai", checkIfExists: true),
]
input[2] = "frags"
"""
}
}

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

}

}
Loading

0 comments on commit 0aef8ea

Please sign in to comment.