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

nf-test for pilon #5293

Merged
merged 9 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/ .*\$//' )
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def valid_mode = ["frags", "jumps", "unpaired", "bam"]
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
if ( !valid_mode.contains(pilon_mode) ) { error "Unrecognised mode to run Pilon. Options: ${valid_mode.join(', ')}" }
"""
touch ${prefix}.fasta
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
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/ .*\$//' )
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
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() }
)
}

}
SPPearce marked this conversation as resolved.
Show resolved Hide resolved

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
Loading