Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skani round 2 #5539

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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/skani/dist/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "skani_dist"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::skani=0.2.1"
50 changes: 50 additions & 0 deletions modules/nf-core/skani/dist/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
process SKANI_DIST {
tag "$meta.id"
label 'process_high'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/skani:0.2.1--h4ac6f70_0':
'biocontainers/skani:0.2.1--h4ac6f70_0' }"

input:
tuple val(meta) , path(query)
tuple val(meta2), path(reference)

output:
tuple val(meta), path("${prefix}.tsv") , emit: dist
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}_${meta2.id}"
"""
skani \\
dist \\
-q ${query} \\
-r ${reference} \\
-o ${prefix}.tsv \\
-t ${task.cpus} \\
${args}

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

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
skani: \$(skani --version 2>&1 | sed 's/^.*skani //; s/ .*\$//')
END_VERSIONS
"""
}
56 changes: 56 additions & 0 deletions modules/nf-core/skani/dist/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "skani_dist"
description: Simple ANI calculation between reference and query genomes.
keywords:
- skani
- metagenomics
- genome
- alignment
- sketch
- distance
- dist
tools:
- "skani":
description: "skani is a fast and robust tool for calculating ANI between metagenome assembled genomes and contigs."
homepage: "https://github.com/bluenote-1577/skani"
documentation: "https://github.com/bluenote-1577/skani/wiki"
tool_dev_url: "https://github.com/bluenote-1577/skani"
doi: "10.1038/s41592-023-02018-3"
licence: ["MIT"]

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- query:
type: file
description: |
FASTA/skani sketch file to be used as query.
pattern: "*.{fasta,fasta.gz,fa,fa.gz,fna,fna.gz,sketch}"
- reference:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add meta2 here too?

type: file
description: |
FASTA/skani sketch file to be used as reference.
pattern: "*.{fasta,fasta.gz,fa,fa.gz,fna,fna.gz,sketch}"

output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- dist:
type: file
description: |
TSV file containing ANI and AF between query and reference as calculated by skani.
pattern: "*.tsv"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"

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

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

tag "modules"
tag "modules_nfcore"
tag "skani"
tag "skani/dist"

// Dependencies
tag "skani/sketch"

setup {
run("SKANI_SKETCH", alias: "SKANI_SKETCH1") {
script "../../sketch/main.nf"
process {
"""
input[0] = [
[ id: 'test' ],
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta.gz", checkIfExists: true)
]
"""
}
}

run("SKANI_SKETCH", alias: "SKANI_SKETCH2") {
script "../../sketch/main.nf"
process {
"""
input[0] = [
[ id: 'test2' ],
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fasta/contigs.fasta", checkIfExists: true)
]
"""
}
}
}

test("fasta.gz + fasta") {
when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta.gz", checkIfExists: true)
]
input[1] = [
[ id:'test2' ], // meta map
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fasta/contigs.fasta", checkIfExists: true)
]
"""
}
}

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

test("fasta.gz + fastq - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta.gz", checkIfExists: true)
]
input[1] = [
[ id:'test2' ], // meta map
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fasta/contigs.fasta", checkIfExists: true)
]
"""
}
}

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

test("sketch + sketch") {
when {
process {
"""
input[0] = SKANI_SKETCH1.out.sketch
input[1] = SKANI_SKETCH2.out.sketch
"""
}
}

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

test("sketch + sketch - stub") {

options "-stub"

when {
process {
"""
input[0] = SKANI_SKETCH1.out.sketch
input[1] = SKANI_SKETCH2.out.sketch
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
134 changes: 134 additions & 0 deletions modules/nf-core/skani/dist/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"sketch + sketch": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test_test2.tsv:md5,1ec6d25df7952408655bcdd7ec123600"
]
],
"1": [
"versions.yml:md5,a8a2d2137a0a871bbd99d861ca4db12f"
],
"dist": [
[
{
"id": "test"
},
"test_test2.tsv:md5,1ec6d25df7952408655bcdd7ec123600"
]
],
"versions": [
"versions.yml:md5,a8a2d2137a0a871bbd99d861ca4db12f"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T19:13:41.612024778"
},
"fasta.gz + fasta": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test_test2.tsv:md5,1ec6d25df7952408655bcdd7ec123600"
]
],
"1": [
"versions.yml:md5,a8a2d2137a0a871bbd99d861ca4db12f"
],
"dist": [
[
{
"id": "test"
},
"test_test2.tsv:md5,1ec6d25df7952408655bcdd7ec123600"
]
],
"versions": [
"versions.yml:md5,a8a2d2137a0a871bbd99d861ca4db12f"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T19:13:15.692205997"
},
"sketch + sketch - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,a8a2d2137a0a871bbd99d861ca4db12f"
],
"dist": [
[
{
"id": "test"
},
"test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,a8a2d2137a0a871bbd99d861ca4db12f"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T19:13:53.29278095"
},
"fasta.gz + fastq - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,a8a2d2137a0a871bbd99d861ca4db12f"
],
"dist": [
[
{
"id": "test"
},
"test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,a8a2d2137a0a871bbd99d861ca4db12f"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T19:13:29.440772434"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/skani/dist/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skani/dist:
- "modules/nf-core/skani/dist/**"
7 changes: 7 additions & 0 deletions modules/nf-core/skani/search/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "skani_search"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::skani=0.2.1"
Loading
Loading