From 6806cd1de9f493ecba86960fc8a6e7d86e262d9b Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Thu, 24 Mar 2022 18:38:24 -0500 Subject: [PATCH] feat(bbmap): Initialize pileup module (#1441) * feat(bbmap): Initialize pileup module * test(bbmap): Update outputs * test(bbmap): Add pileup tags * style(bbmap): Add in when Co-authored-by: Robert A. Petit III --- modules/bbmap/pileup/main.nf | 39 ++++++++++++++++++ modules/bbmap/pileup/meta.yml | 47 ++++++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/bbmap/pileup/main.nf | 15 +++++++ tests/modules/bbmap/pileup/nextflow.config | 5 +++ tests/modules/bbmap/pileup/test.yml | 12 ++++++ 6 files changed, 122 insertions(+) create mode 100644 modules/bbmap/pileup/main.nf create mode 100644 modules/bbmap/pileup/meta.yml create mode 100644 tests/modules/bbmap/pileup/main.nf create mode 100644 tests/modules/bbmap/pileup/nextflow.config create mode 100644 tests/modules/bbmap/pileup/test.yml diff --git a/modules/bbmap/pileup/main.nf b/modules/bbmap/pileup/main.nf new file mode 100644 index 00000000..8d424bc2 --- /dev/null +++ b/modules/bbmap/pileup/main.nf @@ -0,0 +1,39 @@ +process BBMAP_PILEUP { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::bbmap=38.92 bioconda::samtools=1.13 pigz=2.6" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/mulled-v2-008daec56b7aaf3f162d7866758142b9f889d690:f5f55fc5623bb7b3f725e8d2f86bedacfd879510-0' : + 'quay.io/biocontainers/mulled-v2-008daec56b7aaf3f162d7866758142b9f889d690:f5f55fc5623bb7b3f725e8d2f86bedacfd879510-0' }" + + input: + tuple val(meta), path(bam) + + output: + tuple val(meta), path("*.stats.txt"), emit: covstats + tuple val(meta), path("*.hist.txt") , emit: hist + 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}" + """ + pileup.sh \\ + -Xmx${task.memory.toGiga()}g \\ + in=${bam} \\ + out=${prefix}.coverage.stats.txt \\ + hist=${prefix}.coverage.hist.txt \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bbmap: \$(bbversion.sh) + samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//') + pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' ) + END_VERSIONS + """ +} diff --git a/modules/bbmap/pileup/meta.yml b/modules/bbmap/pileup/meta.yml new file mode 100644 index 00000000..5cd85f9a --- /dev/null +++ b/modules/bbmap/pileup/meta.yml @@ -0,0 +1,47 @@ +name: "bbmap_pileup" +description: Calculates per-scaffold or per-base coverage information from an unsorted sam or bam file. +keywords: + - fasta + - genome + - coverage +tools: + - bbmap: + description: BBMap is a short read aligner, as well as various other bioinformatic tools. + homepage: https://jgi.doe.gov/data-and-tools/bbtools/bb-tools-user-guide/ + documentation: https://jgi.doe.gov/data-and-tools/bbtools/bb-tools-user-guide/ + tool_dev_url: "https://github.com/BioInfoTools/BBMap/blob/master/sh/pileup.sh" + doi: "" + licence: ["UC-LBL license (see package)"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - stats: + type: file + description: Per-scaffold coverage info + pattern: "*.stats.txt" + - hist: + type: file + description: "Histogram of # occurrences of each depth level" + pattern: "*.hist.txt" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@Emiller88" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index d3282321..2a93a846 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -106,6 +106,10 @@ bbmap/index: - modules/bbmap/index/** - tests/modules/bbmap/index/** +bbmap/pileup: + - modules/bbmap/pileup/** + - tests/modules/bbmap/pileup/** + bcftools/annotate: - modules/bcftools/annotate/** - tests/modules/bcftools/annotate/** diff --git a/tests/modules/bbmap/pileup/main.nf b/tests/modules/bbmap/pileup/main.nf new file mode 100644 index 00000000..943df9b5 --- /dev/null +++ b/tests/modules/bbmap/pileup/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BBMAP_PILEUP } from '../../../../modules/bbmap/pileup/main.nf' + +workflow test_bbmap_pileup { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + + BBMAP_PILEUP ( input ) +} diff --git a/tests/modules/bbmap/pileup/nextflow.config b/tests/modules/bbmap/pileup/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/bbmap/pileup/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/bbmap/pileup/test.yml b/tests/modules/bbmap/pileup/test.yml new file mode 100644 index 00000000..84814a7a --- /dev/null +++ b/tests/modules/bbmap/pileup/test.yml @@ -0,0 +1,12 @@ +- name: "bbmap pileup" + command: nextflow run ./tests/modules/bbmap/pileup -entry test_bbmap_pileup -c ./tests/config/nextflow.config -c ./tests/modules/bbmap/pileup/nextflow.config + tags: + - "bbmap" + - "bbmap/pileup" + files: + - path: "output/bbmap/test.coverage.stats.txt" + md5sum: c3fc9d0681589b69e3301ca3cb27b7a4 + - path: "output/bbmap/test.coverage.hist.txt" + md5sum: 96915920ef42ddc9483457dd4585a088 + - path: output/bbmap/versions.yml + md5sum: 894acc38bdc167dc22851df15e5a8453