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
37 changes: 30 additions & 7 deletions modules/nf-core/samtools/fixmate/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,49 @@ process SAMTOOLS_FIXMATE {
'biocontainers/samtools:1.21--h50ea8bc_0' }"

input:
tuple val(meta), path(bam)
tuple val(meta), path(input)

output:
tuple val(meta), path("*.bam"), emit: bam
path "versions.yml" , emit: versions
tuple val(meta), path("${prefix}.bam") , emit: bam , optional: true
tuple val(meta), path("${prefix}.cram"), emit: cram, optional: true
tuple val(meta), path("${prefix}.sam") , emit: sam , optional: true
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
if ("$bam" == "${prefix}.bam") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!"
prefix = task.ext.prefix ?: "${meta.id}_fixmate"
def extension = args.contains("--output-fmt sam") ? "sam" :
args.contains("--output-fmt bam") ? "bam" :
args.contains("--output-fmt cram") ? "cram" :
"bam"
if ("$input" == "${prefix}.${extension}") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!"
"""
samtools \\
fixmate \\
$args \\
--threads ${task.cpus-1} \\
$bam \\
${prefix}.bam \\
$input \\
${prefix}.${extension} \\

cat <<-END_VERSIONS > versions.yml
"${task.process}":
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}_fixmate"
def extension = args.contains("--output-fmt sam") ? "sam" :
args.contains("--output-fmt bam") ? "bam" :
args.contains("--output-fmt cram") ? "cram" :
"bam"
if ("$input" == "${prefix}.${extension}") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!"
"""
touch ${prefix}.${extension}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
58 changes: 52 additions & 6 deletions modules/nf-core/samtools/fixmate/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,74 @@ input:
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
- input:
type: file
description: BAM/CRAM/SAM file, must be sorted by name, not coordinate
pattern: "*.{bam,cram,sam}"
ontologies:
- edam: http://edamontology.org/format_2572 # BAM
- edam: http://edamontology.org/format_3462 # CRAM
- edam: http://edamontology.org/format_2573 # SAM
output:
- bam:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- "*.bam":
type: file
description: A BAM/CRAM/SAM file with mate information added and/or proper pairs
recalled
pattern: "*.{bam,cram,sam}"
pattern: "*.{bam}"
ontologies:
- edam: http://edamontology.org/format_2572
- ${prefix}.bam:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "*.{bam}"
ontologies:
- edam: http://edamontology.org/format_2572
- cram:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "*.{cram}"
ontologies:
- edam: http://edamontology.org/format_3462
- ${prefix}.cram:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "*.{cram}"
ontologies:
- edam: http://edamontology.org/format_3462
- sam:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "*.{sam}"
ontologies:
- edam: http://edamontology.org/format_2573
- ${prefix}.sam:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "*.{sam}"
ontologies:
- edam: http://edamontology.org/format_2573
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
ontologies: []
authors:
- "@sppearce"
maintainers:
- "@sppearce"
- "@GallVp"
90 changes: 85 additions & 5 deletions modules/nf-core/samtools/fixmate/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
// TODO nf-core: Once you have added the required tests, please run the following command to build this file:
// nf-core modules test samtools/fixmate
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "samtools"
tag "samtools/fixmate"
tag "samtools/sort"

test("sarscov2 - bam") {

when {
params {
module_args = ''
samtools_sort_args = ''
}
process {
"""
input[0] = Channel.of([
Expand All @@ -27,9 +31,85 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.bam[0][1]).name).match("bam") },
{ assert snapshot(process.out.versions).match("versions") }
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
process.out.versions)
.match()
}
)
}
}

test("human - cram") {

setup {
run("SAMTOOLS_SORT") {
script "../../../samtools/sort/main.nf"
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram', checkIfExists: true)
]
input[1] = [
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)
]
"""
}
}
}

when {
params {
module_args = '--output-fmt cram'
samtools_sort_args = '--template-coordinate --output-fmt cram'
}
process {
"""
input[0] = SAMTOOLS_SORT.out.cram
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.cram[0][1]).name,
process.out.versions
).match()
}
)
}

}

test("human - cram - stub") {

options "-stub"

when {
params {
module_args = '--output-fmt cram'
samtools_sort_args = ''
}
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram', checkIfExists: true)
]
"""
}
}

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

}
}
}
69 changes: 60 additions & 9 deletions modules/nf-core/samtools/fixmate/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,24 +1,75 @@
{
"versions": {
"human - cram - stub": {
"content": [
{
"0": [

],
"1": [
[
{
"id": "test",
"single_end": false
},
"test_fixmate.cram:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [

],
"3": [
"versions.yml:md5,d1afb9aa7c14a683e2a0b8a43daa5d31"
],
"bam": [

],
"cram": [
[
{
"id": "test",
"single_end": false
},
"test_fixmate.cram:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"sam": [

],
"versions": [
"versions.yml:md5,d1afb9aa7c14a683e2a0b8a43daa5d31"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
},
"timestamp": "2025-03-21T06:53:59.470746689"
},
"human - cram": {
"content": [
"test_fixmate.cram",
[
"versions.yml:md5,d1afb9aa7c14a683e2a0b8a43daa5d31"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
"nf-test": "0.9.2",
"nextflow": "24.10.5"
},
"timestamp": "2024-09-16T08:01:53.33860034"
"timestamp": "2025-03-21T06:53:49.930885979"
},
"bam": {
"sarscov2 - bam": {
"content": [
"test.bam"
"762e859a3d0ed1553655cde77665c940",
[
"versions.yml:md5,d1afb9aa7c14a683e2a0b8a43daa5d31"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.04.3"
"nf-test": "0.9.2",
"nextflow": "24.10.5"
},
"timestamp": "2024-02-12T18:24:59.755324"
"timestamp": "2025-03-21T06:47:32.759541463"
}
}
9 changes: 9 additions & 0 deletions modules/nf-core/samtools/fixmate/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
process {
withName: 'SAMTOOLS_FIXMATE' {
ext.args = params.module_args
}
withName: 'SAMTOOLS_SORT' {
ext.args = params.samtools_sort_args
ext.prefix = { "${meta.id}.sorted" }
}
}
2 changes: 0 additions & 2 deletions modules/nf-core/samtools/fixmate/tests/tags.yml

This file was deleted.

2 changes: 1 addition & 1 deletion modules/nf-core/samtools/markdup/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ nextflow_process {

}

}
}
1 change: 0 additions & 1 deletion modules/yaml-schema.json

This file was deleted.

1 change: 1 addition & 0 deletions modules/yaml-schema.json