From 75606893756ee2e2bf34d650c9973932301fb20a Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Tue, 15 Feb 2022 12:30:28 +0100 Subject: [PATCH] feat: add sourmash sketch (#1287) Co-authored-by: Jose Espinosa-Carrasco Co-authored-by: Harshil Patel --- modules/sourmash/sketch/main.nf | 35 ++++++++++++++++ modules/sourmash/sketch/meta.yml | 42 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/sourmash/sketch/main.nf | 15 +++++++ tests/modules/sourmash/sketch/nextflow.config | 5 +++ tests/modules/sourmash/sketch/test.yml | 10 +++++ 6 files changed, 111 insertions(+) create mode 100644 modules/sourmash/sketch/main.nf create mode 100644 modules/sourmash/sketch/meta.yml create mode 100644 tests/modules/sourmash/sketch/main.nf create mode 100644 tests/modules/sourmash/sketch/nextflow.config create mode 100644 tests/modules/sourmash/sketch/test.yml diff --git a/modules/sourmash/sketch/main.nf b/modules/sourmash/sketch/main.nf new file mode 100644 index 00000000..e16b605f --- /dev/null +++ b/modules/sourmash/sketch/main.nf @@ -0,0 +1,35 @@ +process SOURMASH_SKETCH { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::sourmash=4.2.4" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/sourmash:4.2.4--hdfd78af_0': + 'quay.io/biocontainers/sourmash:4.2.4--hdfd78af_0' }" + + input: + tuple val(meta), path(sequence) + + output: + tuple val(meta), path("*.sig"), emit: signatures + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: "dna --param-string 'scaled=1000,k=31'" + def prefix = task.ext.prefix ?: "${meta.id}" + """ + sourmash sketch \\ + $args \\ + --merge '${prefix}' \\ + --output '${prefix}.sig' \\ + $sequence + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + sourmash: \$(echo \$(sourmash --version 2>&1) | sed 's/^sourmash //' ) + END_VERSIONS + """ +} diff --git a/modules/sourmash/sketch/meta.yml b/modules/sourmash/sketch/meta.yml new file mode 100644 index 00000000..9fb552bc --- /dev/null +++ b/modules/sourmash/sketch/meta.yml @@ -0,0 +1,42 @@ +name: sourmash_sketch +description: Create a signature (a hash sketch) of a sequence using sourmash +keywords: + - hash sketch + - signature +tools: + - sourmash: + description: Compute and compare MinHash signatures for DNA data sets. + homepage: https://sourmash.readthedocs.io/ + documentation: https://sourmash.readthedocs.io/ + tool_dev_url: https://github.com/dib-lab/sourmash + doi: "10.1186/s13059-016-0997-x" + licence: ['BSD-3-clause'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - sequence: + type: file + description: FastA file containing (genomic) sequence data + pattern: "*.{fna,fa,fasta}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - signatures: + type: file + description: MinHash signature of the given sequence + pattern: "*.{sig}" + +authors: + - "@Midnighter" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index de061264..52c7f569 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1417,6 +1417,10 @@ snpsites: - modules/snpsites/** - tests/modules/snpsites/** +sourmash/sketch: + - modules/sourmash/sketch/** + - tests/modules/sourmash/sketch/** + spades: - modules/spades/** - tests/modules/spades/** diff --git a/tests/modules/sourmash/sketch/main.nf b/tests/modules/sourmash/sketch/main.nf new file mode 100644 index 00000000..c9288c59 --- /dev/null +++ b/tests/modules/sourmash/sketch/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SOURMASH_SKETCH } from '../../../../modules/sourmash/sketch/main.nf' + +workflow test_sourmash_sketch { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + ] + + SOURMASH_SKETCH ( input ) +} diff --git a/tests/modules/sourmash/sketch/nextflow.config b/tests/modules/sourmash/sketch/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/sourmash/sketch/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} \ No newline at end of file diff --git a/tests/modules/sourmash/sketch/test.yml b/tests/modules/sourmash/sketch/test.yml new file mode 100644 index 00000000..5bd18967 --- /dev/null +++ b/tests/modules/sourmash/sketch/test.yml @@ -0,0 +1,10 @@ +- name: sourmash sketch test_sourmash_sketch + command: nextflow run tests/modules/sourmash/sketch -entry test_sourmash_sketch -c tests/config/nextflow.config + tags: + - sourmash + - sourmash/sketch + files: + - path: output/sourmash/test.sig + md5sum: 4b0dee307e35fc670cd0d416321e4961 + - path: output/sourmash/versions.yml + md5sum: ec70dabc3e4b3bf11d39c17a99ca4bc6