Skip to content
Open
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
8 changes: 8 additions & 0 deletions modules/nf-core/mako/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
# renovate: datasource=conda depName=bioconda/fg-mako
- "bioconda::fg-mako=0.1.3"
44 changes: 44 additions & 0 deletions modules/nf-core/mako/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
process MAKO {
tag "${meta.id}"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "${workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container
? 'https://depot.galaxyproject.org/singularity/fg-mako:0.1.3--h7296c89_0'
: 'quay.io/biocontainers/fg-mako:0.1.3--h7296c89_0'}"

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

output:
tuple val(meta), path("${prefix}.bam"), emit: bam

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have maybe have this in one tuple?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about combining the BAM and BAI, because the .bai is optional: true but the .bam is always produced.

tuple val(meta), path("${prefix}.bam.bai"), emit: bai, optional: true
tuple val("${task.process}"), val('mako'), eval("mako --version | sed '1!d; s/^[^ ]* //; s/ .*//'"), topic: versions, emit: versions_mako
tuple val("${task.process}"), val('fgumi'), eval("mako --version | sed '2!d; s/.* //'"), topic: versions, emit: versions_fgumi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no fgumi here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fgumi version is built into this command:

$ mako --version
mako 0.1.3 (rev unknown)
powered by fgumi 0.3.1

$ mako --version | sed '1!d; s/^[^ ]* //; s/ .*//'
0.1.3
$ mako --version | sed '2!d; s/.* //'
0.3.1


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

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
if ("${prefix}.bam" == "${bam}") {
error("Input and output names are the same, set prefix in module configuration to disambiguate!")
}
"""
mako \\
--input ${bam} \\
--output ${prefix}.bam \\
--threads ${task.cpus} \\
${args}
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
def create_index = args.contains('--write-index') ? "touch ${prefix}.bam.bai" : ''
"""
touch ${prefix}.bam
${create_index}
"""
}
104 changes: 104 additions & 0 deletions modules/nf-core/mako/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: mako
description: Sort SAM/BAM files by coordinate, queryname or template-coordinate using a fast external merge-sort
keywords:
- sort
- bam
- sam
- template-coordinate
- umi
tools:
- mako:
description: |
mako is a focused, single-purpose command-line tool for sorting SAM and BAM files.
It uses a high-performance external merge-sort (spilling to disk for inputs larger than
memory) with parallel radix sorting of in-memory chunks, and is a standalone packaging
of the fgumi sort command.
homepage: https://github.com/fg-labs/mako
documentation: https://github.com/fg-labs/mako
tool_dev_url: https://github.com/fg-labs/mako
licence: ["MIT"]
identifier: ""
input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- bam:
type: file
description: Input SAM/BAM file to sort
pattern: "*.{sam,bam}"
ontologies:
- edam: "http://edamontology.org/format_2572" # BAM
- edam: "http://edamontology.org/format_2573" # SAM
output:
bam:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "${prefix}.bam":
type: file
description: Sorted BAM file
pattern: "*.{bam}"
ontologies:
- edam: "http://edamontology.org/format_2572" # BAM
bai:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "${prefix}.bam.bai":
type: file
description: BAM index, written only for a coordinate sort with `--write-index`
pattern: "*.{bai}"
ontologies:
- edam: "http://edamontology.org/format_3327" # BAI
versions_mako:
- - "${task.process}":
type: string
description: The name of the process
- "mako":
type: string
description: The name of the tool
- "mako --version | sed '1!d; s/^[^ ]* //; s/ .*//'":
type: eval
description: The expression to obtain the version of the tool
versions_fgumi:
- - "${task.process}":
type: string
description: The name of the process
- "fgumi":
type: string
description: The name of the underlying engine
- "mako --version | sed '2!d; s/.* //'":
type: eval
description: The expression to obtain the version of the underlying fgumi engine

topics:
versions:
- - "${task.process}":
type: string
description: The name of the process
- "mako":
type: string
description: The name of the tool
- "mako --version | sed '1!d; s/^[^ ]* //; s/ .*//'":
type: eval
description: The expression to obtain the version of the tool
- - "${task.process}":
type: string
description: The name of the process
- "fgumi":
type: string
description: The name of the underlying engine
- "mako --version | sed '2!d; s/.* //'":
type: eval
description: The expression to obtain the version of the underlying fgumi engine

authors:
- "@nh13"
maintainers:
- "@nh13"
150 changes: 150 additions & 0 deletions modules/nf-core/mako/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "mako"

test("sarscov2 - bam - coordinate sort") {

when {
params {
module_args = '--order coordinate'
}
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert bam(process.out.bam[0][1]).getHeader().any { it.contains("SO:coordinate") } },
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
process.out.findAll { key, val -> key.startsWith("versions") }
).match() }
)
}
}

test("sarscov2 - bam - queryname sort") {

when {
params {
module_args = '--order queryname'
}
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert bam(process.out.bam[0][1]).getHeader().any { it.contains("SO:queryname") } },
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
process.out.findAll { key, val -> key.startsWith("versions") }
).match() }
)
}
}

test("sarscov2 - bam - coordinate sort with index") {

when {
params {
module_args = '--order coordinate --write-index'
}
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert bam(process.out.bam[0][1]).getHeader().any { it.contains("SO:coordinate") } },
{ assert process.out.bai[0][1] ==~ /.*\.bam\.bai/ },
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
process.out.findAll { key, val -> key.startsWith("versions") }
).match() }
)
}
}

test("sarscov2 - bam - template-coordinate sort (default)") {

when {
params {
module_args = ''
}
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert bam(process.out.bam[0][1]).getHeader().any { it.contains("template-coordinate") } },
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
process.out.findAll { key, val -> key.startsWith("versions") }
).match() }
)
}
}

test("sarscov2 - bam - stub") {

options "-stub"

when {
params {
module_args = '--order coordinate'
}
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true)
]
"""
}
}

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