Skip to content

Commit

Permalink
Add sylph sketch (nf-core#7078)
Browse files Browse the repository at this point in the history
* Add sylph sketch

* Update snap

* Update snap

* Remove sylph profile

* Fix linting with version

* Fix output format in meta.yama

* Fix input formatting

* Update meta

* Fix input formatting

* Fix output formatting

* Add versions to output

* Update snap

* Update test

* Fix lintinG

* Test linting

* Linting

* Correct output names

* Add quotes to output names

* Linting

* Fix align in input

* Update modules/nf-core/sylph/sketch/tests/main.nf.test

Co-authored-by: Sateesh_Peri <[email protected]>

* Update snapshot

* Add stub test

---------

Co-authored-by: Sateesh_Peri <[email protected]>
  • Loading branch information
2 people authored and LouisLeNezet committed Dec 4, 2024
1 parent c83b675 commit 1212074
Show file tree
Hide file tree
Showing 5 changed files with 377 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/nf-core/sylph/sketch/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
- bioconda
dependencies:
- "bioconda::sylph=0.7.0"
51 changes: 51 additions & 0 deletions modules/nf-core/sylph/sketch/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
process SYLPH_SKETCH {
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/sylph:0.7.0--h919a2d8_0' :
'biocontainers/sylph:0.7.0--h919a2d8_0' }"

input:
tuple val(meta), path(reads)
path(reference)

output:
tuple val(meta), path('my_sketches/*.sylsp'), path('database.syldb'), emit: sketch_fastq_genome
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}"
def fastq = meta.single_end ? "-r ${reads[0]}" : "-1 ${reads[0]} -2 ${reads[1]}"
"""
sylph sketch \\
$args \\
$fastq \\
-g $reference \\
-S $prefix \\
-d my_sketches
cat <<-END_VERSIONS > versions.yml
"${task.process}":
sylph: \$(sylph -V|awk '{print \$2}')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
mkdir -p my_sketches
touch my_sketches/${prefix}.sylsp
touch database.syldb
cat <<-END_VERSIONS > versions.yml
"${task.process}":
sylph: \$(sylph -V|awk '{print \$2}')
END_VERSIONS
"""
}
60 changes: 60 additions & 0 deletions modules/nf-core/sylph/sketch/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "sylph_sketch"
description: Sketching/indexing sequencing reads
keywords:
- sketch
- metagenomics
- sylph
- indexing
tools:
- sylph:
description: Sylph quickly enables querying of genomes against even low-coverage
shotgun metagenomes to find nearest neighbour ANI.
homepage: https://github.com/bluenote-1577/sylph
documentation: https://github.com/bluenote-1577/sylph
tool_dev_url: https://github.com/bluenote-1577/sylph
doi: 10.1038/s41587-024-02412-y
licence: ["MIT"]
identifier: biotools:sylph
input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`
- reads:
type: file
description: Input fastq files
pattern: "*.{fq,fastq,fq.gz,fastq.gz}"
- - reference:
type: file
description: Reference genome file in FASTA format
output:
- sketch_fastq_genome:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "my_sketches/*.sylsp"
- my_sketches/*.sylsp:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "my_sketches/*.sylsp"
- database.syldb:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "my_sketches/*.sylsp"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@jiahang1234"
- "@sofstam"
maintainers:
- "@sofstam"
74 changes: 74 additions & 0 deletions modules/nf-core/sylph/sketch/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
nextflow_process {

script "../main.nf"
process "SYLPH_SKETCH"
tag "modules"
tag "modules_nfcore"
tag "sylph"
tag "sylph/sketch"

test("sarscov2 illumina single-end [fastq_gz]") {
when {
process {
"""
input[0] = [ [ id:'test', single_end:true ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ]
]
input[1] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
"""
}
}

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

test("sarscov2 illumina paired-end [fastq_gz]") {
when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ]
]
input[1] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
"""
}
}

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

test("sarscov2 illumina paired-end [fastq_gz]-stub") {

options "-stub"

when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ]
]
input[1] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
187 changes: 187 additions & 0 deletions modules/nf-core/sylph/sketch/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"SYLPH_SKETCH: Should run without failures with single-end data": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": true
},
"test.sylsp:md5,4f9ba8a3613e74e0fd4213330abae522",
"database.syldb:md5,c60e5450276385d81557a3f2b224762f"
]
],
"1": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
],
"sketch_fastq_genome": [
[
{
"id": "test",
"single_end": true
},
"test.sylsp:md5,4f9ba8a3613e74e0fd4213330abae522",
"database.syldb:md5,c60e5450276385d81557a3f2b224762f"
]
],
"versions": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-11-27T11:14:52.331315"
},
"sarscov2 illumina paired-end [fastq_gz]": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test.paired.sylsp:md5,8ac5d34be025f7491c13ab6407e946fd",
"database.syldb:md5,c60e5450276385d81557a3f2b224762f"
]
],
"1": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
],
"sketch_fastq_genome": [
[
{
"id": "test",
"single_end": false
},
"test.paired.sylsp:md5,8ac5d34be025f7491c13ab6407e946fd",
"database.syldb:md5,c60e5450276385d81557a3f2b224762f"
]
],
"versions": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-11-28T10:12:17.710653"
},
"SYLPH_SKETCH: Should run without failures with paired-end data": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test.paired.sylsp:md5,8ac5d34be025f7491c13ab6407e946fd",
"database.syldb:md5,c60e5450276385d81557a3f2b224762f"
]
],
"1": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
],
"sketch_fastq_genome": [
[
{
"id": "test",
"single_end": false
},
"test.paired.sylsp:md5,8ac5d34be025f7491c13ab6407e946fd",
"database.syldb:md5,c60e5450276385d81557a3f2b224762f"
]
],
"versions": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-11-27T11:15:00.053288"
},
"sarscov2 illumina single-end [fastq_gz]": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": true
},
"test.sylsp:md5,4f9ba8a3613e74e0fd4213330abae522",
"database.syldb:md5,c60e5450276385d81557a3f2b224762f"
]
],
"1": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
],
"sketch_fastq_genome": [
[
{
"id": "test",
"single_end": true
},
"test.sylsp:md5,4f9ba8a3613e74e0fd4213330abae522",
"database.syldb:md5,c60e5450276385d81557a3f2b224762f"
]
],
"versions": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-11-27T17:04:41.72956"
},
"sarscov2 illumina paired-end [fastq_gz]-stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test.sylsp:md5,d41d8cd98f00b204e9800998ecf8427e",
"database.syldb:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
],
"sketch_fastq_genome": [
[
{
"id": "test",
"single_end": false
},
"test.sylsp:md5,d41d8cd98f00b204e9800998ecf8427e",
"database.syldb:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,f78c271e0133ef3d93db094bdab7cf3c"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-11-28T11:24:25.020343"
}
}

0 comments on commit 1212074

Please sign in to comment.