diff --git a/modules/nf-core/seqkit/sliding/main.nf b/modules/nf-core/seqkit/sliding/main.nf new file mode 100644 index 00000000000..ffa570eb58f --- /dev/null +++ b/modules/nf-core/seqkit/sliding/main.nf @@ -0,0 +1,40 @@ +process SEQKIT_SLIDING { + tag "$meta.id" + label 'process_low' + + conda "bioconda::seqkit=2.1.0" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/seqkit:2.1.0--h9ee0642_0': + 'biocontainers/seqkit:2.1.0--h9ee0642_0' }" + + input: + tuple val(meta), path(fastx) + + output: + tuple val(meta), path("*.fast*"), emit: fastx + 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 extension = "fastq" + if ("$fastx" ==~ /.+\.fasta$|.+\.fa$|.+\.fas$|.+\.fna$/) { + extension = "fasta" + } + """ + seqkit \\ + sliding \\ + ${fastx} \\ + ${args} \\ + --threads ${task.cpus} \\ + -o ${prefix}.${extension} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + seqkit: \$( seqkit | sed '3!d; s/Version: //' ) + END_VERSIONS + """ +} diff --git a/modules/nf-core/seqkit/sliding/meta.yml b/modules/nf-core/seqkit/sliding/meta.yml new file mode 100644 index 00000000000..d6d6362780c --- /dev/null +++ b/modules/nf-core/seqkit/sliding/meta.yml @@ -0,0 +1,42 @@ +name: seqkit_sliding +description: Use seqkit to generate sliding windows of input fasta +keywords: + - seqkit + - sliding + - windows +tools: + - seqkit: + description: Cross-platform and ultrafast toolkit for FASTA/Q file manipulation, written by Wei Shen. + homepage: https://bioinf.shenwei.me/seqkit/usage/ + documentation: https://bioinf.shenwei.me/seqkit/usage/ + tool_dev_url: https://github.com/shenwei356/seqkit/ + doi: "10.1371/journal.pone.016396" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - fastx: + type: file + description: fasta/q file + pattern: "*.{fasta,fastq,fa,fq,fas,fna,faa}*" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - windows: + type: file + description: fasta/q window file + pattern: "*.{fasta,fastq,fa,fq,fas,fna,faa}*" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@DLBPointon" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index cb2a6979b72..54dbac81223 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -3259,6 +3259,10 @@ seqkit/replace: - modules/nf-core/seqkit/replace/** - tests/modules/nf-core/seqkit/replace/** +seqkit/sliding: + - modules/nf-core/seqkit/sliding/** + - tests/modules/nf-core/seqkit/sliding/** + seqkit/split2: - modules/nf-core/seqkit/split2/** - tests/modules/nf-core/seqkit/split2/** diff --git a/tests/modules/nf-core/seqkit/sliding/main.nf b/tests/modules/nf-core/seqkit/sliding/main.nf new file mode 100644 index 00000000000..074de723360 --- /dev/null +++ b/tests/modules/nf-core/seqkit/sliding/main.nf @@ -0,0 +1,25 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SEQKIT_SLIDING } from '../../../../../modules/nf-core/seqkit/sliding/main.nf' + +workflow test_seqkit_sliding_fasta { + + input = [ [ id:'test' ], // meta map + [ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ] + ] + + SEQKIT_SLIDING ( input ) + +} + +workflow test_seqkit_sliding_fastq { + + input = [ [ id:'test' ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ] + ] + + SEQKIT_SLIDING ( input ) + +} diff --git a/tests/modules/nf-core/seqkit/sliding/nextflow.config b/tests/modules/nf-core/seqkit/sliding/nextflow.config new file mode 100644 index 00000000000..790f4c163f6 --- /dev/null +++ b/tests/modules/nf-core/seqkit/sliding/nextflow.config @@ -0,0 +1,7 @@ +process { + + withName: 'SEQKIT_SLIDING' { + ext.args = "-s 2 -W 5" + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + } +} diff --git a/tests/modules/nf-core/seqkit/sliding/test.yml b/tests/modules/nf-core/seqkit/sliding/test.yml new file mode 100644 index 00000000000..88b160b1f02 --- /dev/null +++ b/tests/modules/nf-core/seqkit/sliding/test.yml @@ -0,0 +1,18 @@ +- name: seqkit sliding test_seqkit_sliding_fasta + command: nextflow run ./tests/modules/nf-core/seqkit/sliding -entry test_seqkit_sliding_fasta -c ./tests/config/nextflow.config + tags: + - seqkit/sliding + - seqkit + files: + - path: output/seqkit/test.fasta + md5sum: d5e112b55c37bef1f16f28ba16b323dd + - path: output/seqkit/versions.yml +- name: seqkit sliding test_seqkit_sliding_fastq + command: nextflow run ./tests/modules/nf-core/seqkit/sliding -entry test_seqkit_sliding_fastq -c ./tests/config/nextflow.config + tags: + - seqkit/sliding + - seqkit + files: + - path: output/seqkit/test.fastq + md5sum: 59f475cac6d2c372ce2d3a1e3c40305b + - path: output/seqkit/versions.yml