From 31409f5e727ec932f0b3a399c7a3847d70b21374 Mon Sep 17 00:00:00 2001 From: Matthieu Muffato Date: Tue, 26 Jul 2022 22:13:19 +0100 Subject: [PATCH] Added the samtools/dict module (#1922) * Added the samtools/dict module * samtools/dict is single-threaded --- modules/samtools/dict/main.nf | 44 +++++++++++++++++++++ modules/samtools/dict/meta.yml | 41 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/samtools/dict/main.nf | 13 ++++++ tests/modules/samtools/dict/nextflow.config | 5 +++ tests/modules/samtools/dict/test.yml | 13 ++++++ 6 files changed, 120 insertions(+) create mode 100644 modules/samtools/dict/main.nf create mode 100644 modules/samtools/dict/meta.yml create mode 100644 tests/modules/samtools/dict/main.nf create mode 100644 tests/modules/samtools/dict/nextflow.config create mode 100644 tests/modules/samtools/dict/test.yml diff --git a/modules/samtools/dict/main.nf b/modules/samtools/dict/main.nf new file mode 100644 index 00000000..91f782b1 --- /dev/null +++ b/modules/samtools/dict/main.nf @@ -0,0 +1,44 @@ +process SAMTOOLS_DICT { + tag "$fasta" + label 'process_single' + + conda (params.enable_conda ? "bioconda::samtools=1.15.1" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/samtools:1.15.1--h1170115_0' : + 'quay.io/biocontainers/samtools:1.15.1--h1170115_0' }" + + input: + tuple val(meta), path(fasta) + + output: + tuple val(meta), path ("*.dict"), emit: dict + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + """ + samtools \\ + dict \\ + $args \\ + $fasta \\ + > ${fasta}.dict + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//') + END_VERSIONS + """ + + stub: + """ + touch ${fasta}.dict + cat <<-END_VERSIONS > versions.yml + + "${task.process}": + samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//') + END_VERSIONS + """ +} diff --git a/modules/samtools/dict/meta.yml b/modules/samtools/dict/meta.yml new file mode 100644 index 00000000..e3eeccc8 --- /dev/null +++ b/modules/samtools/dict/meta.yml @@ -0,0 +1,41 @@ +name: samtools_dict +description: Create a sequence dictionary file from a FASTA file +keywords: + - dict + - fasta +tools: + - samtools: + description: | + SAMtools is a set of utilities for interacting with and post-processing + short DNA sequence read alignments in the SAM, BAM and CRAM formats, written by Heng Li. + These files are generated as output by short read aligners like BWA. + homepage: http://www.htslib.org/ + documentation: http://www.htslib.org/doc/samtools.html + doi: 10.1093/bioinformatics/btp352 + licence: ["MIT"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - fasta: + type: file + description: FASTA file + pattern: "*.{fa,fasta}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - dict: + type: file + description: FASTA dictionary file + pattern: "*.{dict}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@muffato" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index b7f84004..bcbee2b4 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1919,6 +1919,10 @@ samtools/depth: - modules/samtools/depth/** - tests/modules/samtools/depth/** +samtools/dict: + - modules/samtools/dict/** + - tests/modules/samtools/dict/** + samtools/faidx: - modules/samtools/faidx/** - tests/modules/samtools/faidx/** diff --git a/tests/modules/samtools/dict/main.nf b/tests/modules/samtools/dict/main.nf new file mode 100644 index 00000000..f24a8382 --- /dev/null +++ b/tests/modules/samtools/dict/main.nf @@ -0,0 +1,13 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SAMTOOLS_DICT } from '../../../../modules/samtools/dict/main.nf' + +workflow test_samtools_dict { + + input = [ [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ] + + SAMTOOLS_DICT ( input ) +} diff --git a/tests/modules/samtools/dict/nextflow.config b/tests/modules/samtools/dict/nextflow.config new file mode 100644 index 00000000..8730f1c4 --- /dev/null +++ b/tests/modules/samtools/dict/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/samtools/dict/test.yml b/tests/modules/samtools/dict/test.yml new file mode 100644 index 00000000..8a71398a --- /dev/null +++ b/tests/modules/samtools/dict/test.yml @@ -0,0 +1,13 @@ +- name: samtools dict test_samtools_dict + command: nextflow run tests/modules/samtools/dict -entry test_samtools_dict -c tests/config/nextflow.config -c tests/modules/samtools/dict/nextflow.config + tags: + - samtools + - samtools/dict + files: + - path: output/samtools/genome.fasta.dict + contains: + - "SN:MT192765.1" + - "LN:29829" + - "M5:c95f3e5592d0ad9974e41e7f0ea14eb0" + - path: output/samtools/versions.yml + md5sum: 12cd0c5ce466eefb2dff72625ecbe5c2