From 24f0bdd14ec32e0114aa6ee5337ddbd490ffd570 Mon Sep 17 00:00:00 2001 From: Michael J Cipriano <42848032+mjcipriano@users.noreply.github.com> Date: Wed, 9 Mar 2022 12:36:05 -0500 Subject: [PATCH] added module seqkit replace (#1382) * added module seqkit replace * added when * removed extra line * Update modules/seqkit/replace/main.nf Co-authored-by: Robert A. Petit III * Updated meta * updated indents Co-authored-by: Cipriano Co-authored-by: Sateesh Peri <33637490+sateeshperi@users.noreply.github.com> Co-authored-by: Robert A. Petit III --- modules/seqkit/replace/main.nf | 41 ++++++++++++++++++++ modules/seqkit/replace/meta.yml | 41 ++++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/seqkit/replace/main.nf | 24 ++++++++++++ tests/modules/seqkit/replace/nextflow.config | 14 +++++++ tests/modules/seqkit/replace/test.yml | 21 ++++++++++ 6 files changed, 145 insertions(+) create mode 100644 modules/seqkit/replace/main.nf create mode 100644 modules/seqkit/replace/meta.yml create mode 100644 tests/modules/seqkit/replace/main.nf create mode 100644 tests/modules/seqkit/replace/nextflow.config create mode 100644 tests/modules/seqkit/replace/test.yml diff --git a/modules/seqkit/replace/main.nf b/modules/seqkit/replace/main.nf new file mode 100644 index 00000000..db189ef6 --- /dev/null +++ b/modules/seqkit/replace/main.nf @@ -0,0 +1,41 @@ +process SEQKIT_REPLACE { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::seqkit=2.1.0" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/seqkit:2.1.0--h9ee0642_0': + 'quay.io/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|.+\.fasta.gz|.+\.fa|.+\.fa.gz|.+\.fas|.+\.fas.gz|.+\.fna|.+\.fna.gz/) { + extension = "fasta" + } + def endswith = task.ext.suffix ?: "${extension}.gz" + """ + seqkit \\ + replace \\ + ${args} \\ + --threads ${task.cpus} \\ + -i ${fastx} \\ + -o ${prefix}.${endswith} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + seqkit: \$( seqkit | sed '3!d; s/Version: //' ) + END_VERSIONS + """ +} diff --git a/modules/seqkit/replace/meta.yml b/modules/seqkit/replace/meta.yml new file mode 100644 index 00000000..c15d04cb --- /dev/null +++ b/modules/seqkit/replace/meta.yml @@ -0,0 +1,41 @@ +name: seqkit_replace +description: Use seqkit to find/replace strings within sequences and sequence headers +keywords: + - seqkit + - replace +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 ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - fastx: + type: file + description: fasta/q file with replaced values + pattern: "*.{fasta,fastq,fa,fq,fas,fna,faa}*" + +authors: + - "@mjcipriano" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index d6575ff1..a370f371 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1481,6 +1481,10 @@ seqkit/pair: - modules/seqkit/pair/** - tests/modules/seqkit/pair/** +seqkit/replace: + - modules/seqkit/replace/** + - tests/modules/seqkit/replace/** + seqkit/split2: - modules/seqkit/split2/** - tests/modules/seqkit/split2/** diff --git a/tests/modules/seqkit/replace/main.nf b/tests/modules/seqkit/replace/main.nf new file mode 100644 index 00000000..5c4058e7 --- /dev/null +++ b/tests/modules/seqkit/replace/main.nf @@ -0,0 +1,24 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SEQKIT_REPLACE } from '../../../../modules/seqkit/replace/main.nf' +include { SEQKIT_REPLACE as SEQKIT_REPLACEUNCOMP } from '../../../../modules/seqkit/replace/main.nf' + +workflow test_seqkit_replace { + + input = [ [ id:'test' ], // meta map + [ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ] + ] + + SEQKIT_REPLACE ( input ) +} + +workflow test_seqkit_replace_uncomp { + + input = [ [ id:'test' ], // meta map + [ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ] + ] + + SEQKIT_REPLACEUNCOMP ( input ) +} diff --git a/tests/modules/seqkit/replace/nextflow.config b/tests/modules/seqkit/replace/nextflow.config new file mode 100644 index 00000000..8cec8505 --- /dev/null +++ b/tests/modules/seqkit/replace/nextflow.config @@ -0,0 +1,14 @@ +process { + + withName: 'SEQKIT_REPLACE' { + ext.args = "-s -p 'A' -r 'N'" + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + } + + withName: 'SEQKIT_REPLACEUNCOMP' { + ext.args = "-s -p 'T' -r 'N'" + ext.suffix = ".fasta" + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + } + +} diff --git a/tests/modules/seqkit/replace/test.yml b/tests/modules/seqkit/replace/test.yml new file mode 100644 index 00000000..94c3a5ef --- /dev/null +++ b/tests/modules/seqkit/replace/test.yml @@ -0,0 +1,21 @@ +- name: seqkit replace test_seqkit_replace + command: nextflow run tests/modules/seqkit/replace -entry test_seqkit_replace -c tests/config/nextflow.config + tags: + - seqkit + - seqkit/replace + files: + - path: output/seqkit/test.fasta.gz + md5sum: 053847219695c0a923d02352442d7abf + - path: output/seqkit/versions.yml + md5sum: dc9d18b7836c9db00a3032fd191bd831 + +- name: seqkit replace test_seqkit_replace_uncomp + command: nextflow run tests/modules/seqkit/replace -entry test_seqkit_replace_uncomp -c tests/config/nextflow.config + tags: + - seqkit + - seqkit/replace + files: + - path: output/seqkit/test..fasta + md5sum: 05d3294a62c72f5489f067c1da3c2f6c + - path: output/seqkit/versions.yml + md5sum: 3b88128487ec949f0bdeecebc375c407