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
12 changes: 11 additions & 1 deletion modules/nf-core/bwa/mem/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ process BWA_MEM {
output:
tuple val(meta), path("*.bam") , emit: bam, optional: true
tuple val(meta), path("*.cram") , emit: cram, optional: true
tuple val(meta), path("*.sam") , emit: sam, optional: true
tuple val(meta), path("*.csi") , emit: csi, optional: true
tuple val(meta), path("*.crai") , emit: crai, optional: true
tuple val("${task.process}"), val('bwa'), eval('bwa 2>&1 | sed -n "s/^Version: //p"'), topic: versions, emit: versions_bwa
Expand All @@ -36,6 +37,15 @@ process BWA_MEM {
"bam"
def reference = fasta && extension=="cram" ? "--reference ${fasta}" : ""
if (!fasta && extension=="cram") error "Fasta reference is required for CRAM output"
//
// For SAM output we can skip samtools view
//
def pipe_command = ""
if (extension == "sam") {
pipe_command = "> ${prefix}.${extension}"
} else {
pipe_command = "| samtools $samtools_command $args2 ${reference} --threads $task.cpus -o ${prefix}.${extension} -"
}
"""
INDEX=`find -L ./ -name "*.amb" | sed 's/\\.amb\$//'`

Expand All @@ -44,7 +54,7 @@ process BWA_MEM {
-t $task.cpus \\
\$INDEX \\
$reads \\
| samtools $samtools_command $args2 ${reference} --threads $task.cpus -o ${prefix}.${extension} -
$pipe_command
"""

stub:
Expand Down
10 changes: 10 additions & 0 deletions modules/nf-core/bwa/mem/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ output:
pattern: "*.{cram}"
ontologies:
- edam: "http://edamontology.org/format_3462"
sam:
- - meta:
type: map
description: Groovy Map containing sample information
- "*.sam":
type: file
description: Output SAM file containing read alignments
pattern: "*.{sam}"
ontologies:
- edam: "http://edamontology.org/format_2573"
csi:
- - meta:
type: map
Expand Down
88 changes: 88 additions & 0 deletions modules/nf-core/bwa/mem/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ nextflow_process {
{ assert process.success },
{ assert snapshot(
process.out.cram,
process.out.sam,
process.out.csi,
process.out.crai,
process.out.findAll { key, val -> key.startsWith("versions") },
Expand Down Expand Up @@ -80,6 +81,7 @@ nextflow_process {
{ assert process.success },
{ assert snapshot(
process.out.cram,
process.out.sam,
process.out.csi,
process.out.crai,
process.out.findAll { key, val -> key.startsWith("versions") },
Expand All @@ -91,6 +93,47 @@ nextflow_process {

}

test("Single-End - SAM output") {

config "./nextflow_sam.config"

when {
params {
module_args2 = "--output-fmt sam"
}

process {
"""
input[0] = [
[ id:'test', single_end:true ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)
]
]
input[1] = BWA_INDEX.out.index
input[2] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)]
input[3] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.bam,
process.out.cram,
process.out.csi,
process.out.crai,
process.out.findAll { key, val -> key.startsWith("versions") },
bam(process.out.sam[0][1]).getReadsMD5()
).match()
}
)
}

}

test("Paired-End") {

when {
Expand All @@ -115,6 +158,7 @@ nextflow_process {
{ assert process.success },
{ assert snapshot(
process.out.cram,
process.out.sam,
process.out.csi,
process.out.crai,
process.out.findAll { key, val -> key.startsWith("versions") },
Expand Down Expand Up @@ -150,6 +194,7 @@ nextflow_process {
{ assert process.success },
{ assert snapshot(
process.out.cram,
process.out.sam,
process.out.csi,
process.out.crai,
process.out.findAll { key, val -> key.startsWith("versions") },
Expand Down Expand Up @@ -185,6 +230,7 @@ nextflow_process {
{ assert process.success },
{ assert snapshot(
process.out.cram,
process.out.sam,
process.out.csi,
process.out.crai,
process.out.findAll { key, val -> key.startsWith("versions") },
Expand All @@ -196,6 +242,48 @@ nextflow_process {

}

test ("Paired-end - SAM output") {

config "./nextflow_sam.config"

when {
params {
module_args2 = "--output-fmt sam"
}

process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = BWA_INDEX.out.index
input[2] = [[:],[]]
input[3] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.bam,
process.out.cram,
process.out.csi,
process.out.crai,
process.out.findAll { key, val -> key.startsWith("versions") },
bam(process.out.sam[0][1]).getReadsMD5()
).match()
}
)
}

}

test("Single-end - stub") {

options "-stub"
Expand Down
Loading
Loading