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
7 changes: 7 additions & 0 deletions modules/nf-core/sativaepang/looplace/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::sativa-epang=0.9.3.4
55 changes: 55 additions & 0 deletions modules/nf-core/sativaepang/looplace/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
process SATIVAEPANG_LOOPLACE {
tag "$meta.id"
label 'process_high'

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

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

output:
tuple val(meta), path(taskdir), emit: taskdir
tuple val("${task.process}"), val('sativaepang'), eval("grep -m1 -oE '[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+' \$(command -v sativa-epang)"), topic: versions, emit: versions_sativaepang

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

script:
def args = task.ext.args ?: ''
"""
# Private writable taskdir: loo-place writes a jplace/logs into every fold, which
# would otherwise mutate lootasks' own output in place (nf-core/modules#12799-style
# -resume bug). fold_*/{ref.nwk,ref.fasta,query.fasta} stay symlinks -- at GTDB scale
# these are already near-full-alignment copies per fold, so duplicating them again
# here isn't affordable.
mv "$taskdir" "${taskdir}.orig"
mkdir "$taskdir"
ln -s "\$(readlink -f "${taskdir}.orig/manifest.json")" "$taskdir/manifest.json"
for fold in "${taskdir}.orig"/fold_*; do
d="$taskdir/\$(basename "\$fold")"
mkdir "\$d"
ln -s "\$(readlink -f "\$fold")"/* "\$d/"
done

sativa-epang \\
-stage loo-place \\
-taskdir $taskdir \\
-T ${task.cpus} \\
${args}
"""

stub:
"""
mv "$taskdir" "${taskdir}.orig"
mkdir "$taskdir"
ln -s "\$(readlink -f "${taskdir}.orig/manifest.json")" "$taskdir/manifest.json"
for fold in "${taskdir}.orig"/fold_*; do
d="$taskdir/\$(basename "\$fold")"
mkdir "\$d"
touch "\$d/epa_result.jplace"
done
"""
}
68 changes: 68 additions & 0 deletions modules/nf-core/sativaepang/looplace/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "sativaepang_looplace"
description: Place every leave-one-out fold with EPA-ng via -stage loo-place, writing a jplace into each fold directory
keywords:
- phylogenetics
- taxonomy
- mislabelling
- placement
- leave-one-out
tools:
- "sativaepang":
description: "SATIVA with EPA-ng as the placement engine"
homepage: "https://github.com/Aaramis/sativa-epang"
documentation: "https://github.com/Aaramis/sativa-epang/blob/main/CHANGES-epa-ng.md"
tool_dev_url: "https://github.com/Aaramis/sativa-epang"
doi: "10.1093/nar/gkw396"
licence:
- "GPL-3.0-or-later"
identifier: ""
input:
- - meta:
type: map
description: Groovy Map containing sample information. e.g. `[ id:'sample1' ]`
- taskdir:
type: directory
description: |
The `*.l1o_tasks` directory produced by `sativaepang/lootasks`: one
subdirectory per fold (`ref.nwk`, `ref.fasta`, `query.fasta`) plus a
`manifest.json`.
pattern: "*.l1o_tasks"
output:
taskdir:
- - meta:
type: map
description: Groovy Map containing sample information. e.g. `[ id:'sample1' ]`
- taskdir:
type: directory
description: |
The same taskdir, with an `epa_result.jplace` (plus `epang.log` and
`epa_info.log`) added to every fold subdirectory. Input to
`sativaepang/looscore`.
pattern: "*.l1o_tasks"
versions_sativaepang:
- - ${task.process}:
type: string
description: The name of the process
- sativaepang:
type: string
description: The name of the tool
- grep -m1 -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' \$(command -v sativa-epang):
type: eval
description: The expression to obtain the version of the tool

topics:
versions:
- - ${task.process}:
type: string
description: The name of the process
- sativaepang:
type: string
description: The name of the tool
- grep -m1 -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' \$(command -v sativa-epang):
type: eval
description: The expression to obtain the version of the tool

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

name "Test Process SATIVAEPANG_LOOPLACE"
script "../main.nf"
process "SATIVAEPANG_LOOPLACE"

tag "modules"
tag "modules_nfcore"
tag "sativaepang"
tag "sativaepang/lootasks"
tag "sativaepang/looplace"

test("sativa-epang tiny example") {

setup {
run("SATIVAEPANG_LOOTASKS") {
script "../../lootasks/main.nf"
process {
"""
input[0] = [
[ id:'test' ],
file(params.modules_testdata_base_path + 'delete_me/sativaepang/sativaepang_tiny.refjson', checkIfExists: true),
file(params.modules_testdata_base_path + 'delete_me/sativaepang/sativaepang_tiny.model', checkIfExists: true)
]
"""
}
}
}

when {
process {
"""
input[0] = SATIVAEPANG_LOOTASKS.out.taskdir
"""
}
}

then {
// epa_result.jplace/epa_info.log/epang.log aren't byte-reproducible across
// engines (conda vs. container placement likelihoods, wall-clock timing) --
// masked below, same precedent as sigprofiler/snapaligner.
def taskdir = file(process.out.taskdir[0][1])
def foldDirs = taskdir.listFiles().findAll { it.isDirectory() && it.name.startsWith("fold_") }
assertAll(
{ assert process.success },
{ assert foldDirs.size() > 0 },
{ assert foldDirs.every { new File(it.toString(), "epa_result.jplace").exists() } },
{ assert snapshot(sanitizeOutput(process.out, unstablePatterns: ["**/epa_result.jplace", "**/epa_info.log", "**/epang.log"])).match() }
)
}
}

test("gtdb archaea 16S") {

setup {
run("SATIVAEPANG_LOOTASKS") {
script "../../lootasks/main.nf"
process {
"""
input[0] = [
[ id:'test' ],
file(params.modules_testdata_base_path + 'delete_me/sativaepang/gtdb_archaea_16s.refjson', checkIfExists: true),
file(params.modules_testdata_base_path + 'delete_me/sativaepang/gtdb_archaea_16s.model', checkIfExists: true)
]
"""
}
}
}

when {
process {
"""
input[0] = SATIVAEPANG_LOOTASKS.out.taskdir
"""
}
}

then {
def taskdir = file(process.out.taskdir[0][1])
def foldDirs = taskdir.listFiles().findAll { it.isDirectory() && it.name.startsWith("fold_") }
assertAll(
{ assert process.success },
{ assert foldDirs.size() > 0 },
{ assert foldDirs.every { new File(it.toString(), "epa_result.jplace").exists() } },
{ assert snapshot(sanitizeOutput(process.out, unstablePatterns: ["**/epa_result.jplace", "**/epa_info.log", "**/epang.log"])).match() }
)
}
}

test("sativa-epang tiny example - stub") {

options "-stub"

setup {
run("SATIVAEPANG_LOOTASKS") {
script "../../lootasks/main.nf"
process {
"""
input[0] = [
[ id:'test' ],
file(params.modules_testdata_base_path + 'delete_me/sativaepang/sativaepang_tiny.refjson', checkIfExists: true),
file(params.modules_testdata_base_path + 'delete_me/sativaepang/sativaepang_tiny.model', checkIfExists: true)
]
"""
}
}
}

when {
process {
"""
input[0] = SATIVAEPANG_LOOTASKS.out.taskdir
"""
}
}

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