Skip to content
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
29 changes: 22 additions & 7 deletions modules/nf-core/bamtools/convert/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,38 @@ process BAMTOOLS_CONVERT {
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def test = args ==~ /-format (bed|fasta|fastq|json|pileup|sam|yaml)/
if ( test == false ) error "-format option must be provided in args. Possible values: bed fasta fastq json pileup sam yaml"
m = args =~ /-format ([a-z]+)/
ext = m[0][1]
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
format_cmd = args ==~ /-format (bed|fasta|fastq|json|pileup|sam|yaml)/
matched_format = args =~ /-format ([a-z]+)/
extension = matched_format[0][1]
if ( format_cmd == false ) error "-format option must be provided in args. Possible values: bed fasta fastq json pileup sam yaml"

"""
bamtools \\
convert \\
$args \\
-in $bam \\
-out ${prefix}.${ext}
-out ${prefix}.${extension}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
bamtools: \$( bamtools --version | grep -e 'bamtools' | sed 's/^.*bamtools //' )
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
format_cmd = args ==~ /-format (bed|fasta|fastq|json|pileup|sam|yaml)/
matched_format = args =~ /-format ([a-z]+)/
extension = matched_format[0][1]
if ( format_cmd == false ) error "-format option must be provided in args. Possible values: bed fasta fastq json pileup sam yaml"

"""
touch ${prefix}.${extension}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bamtools: \$( bamtools --version | grep -e 'bamtools' | sed 's/^.*bamtools //' )
END_VERSIONS
"""
}
233 changes: 233 additions & 0 deletions modules/nf-core/bamtools/convert/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
nextflow_process {

name "Test Process BAMTOOLS_CONVERT"
config "./nextflow.config"
script "../main.nf"
process "BAMTOOLS_CONVERT"

tag "modules"
tag "modules_nfcore"
tag "bamtools"
tag "bamtools/convert"

test("test_bamtools_convert_ext_error") {
when {
params {
module_args = "-format vcf"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.failed },
{ assert process.errorReport.contains("-format option must be provided in args. Possible values: bed fasta fastq json pileup sam yaml") }
Comment thread
LouisLeNezet marked this conversation as resolved.
)
}
}
test("test_bamtools_convert_noext_error") {
when {
params {
module_args = ""
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.failed },
{ assert process.errorReport.contains("-format option must be provided in args. Possible values: bed fasta fastq json pileup sam yaml") }
)
}
}
test("test_bamtools_convert_bed") {
when {
params {
module_args = "-format bed"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
test("test_bamtools_convert_fasta") {
when {
params {
module_args = "-format fasta"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
test("test_bamtools_convert_fastq") {
when {
params {
module_args = "-format fastq"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
test("test_bamtools_convert_json") {


when {
params {
module_args = "-format json"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
test("test_bamtools_convert_pileup") {


when {
params {
module_args = "-format pileup"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
test("test_bamtools_convert_sam") {


when {
params {
module_args = "-format sam"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
test("test_bamtools_convert_yaml") {
when {
params {
module_args = "-format yaml"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}

test("test_bamtools_convert_yaml - stub") {
when {
params {
module_args = "-format yaml"
}
process {
"""
input[0] = [
[id:'test', single_end:false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists:true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out,
process.out.versions.collect{path(it).yaml}
).match() }
)
}
}
}
Loading
Loading