diff --git a/modules/biobambam/bammerge/main.nf b/modules/biobambam/bammerge/main.nf new file mode 100644 index 00000000..75040903 --- /dev/null +++ b/modules/biobambam/bammerge/main.nf @@ -0,0 +1,38 @@ +process BIOBAMBAM_BAMMERGE { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::biobambam=2.0.183" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/biobambam:2.0.183--h9f5acd7_1': + 'quay.io/biocontainers/biobambam:2.0.183--h9f5acd7_1' }" + + input: + tuple val(meta), path(bam) + + output: + tuple val(meta), path("${prefix}.bam") ,emit: bam + tuple val(meta), path("*.bai") ,optional:true, emit: bam_index + tuple val(meta), path("*.md5") ,optional:true, emit: checksum + path "versions.yml" ,emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: "${meta.id}" + def input_string = bam.join(" I=") + + """ + bammerge \\ + I=${input_string} \\ + $args \\ + > ${prefix}.bam + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bammerge: \$( bammerge --version |& sed '1!d; s/.*version //; s/.\$//' ) + END_VERSIONS + """ +} diff --git a/modules/biobambam/bammerge/meta.yml b/modules/biobambam/bammerge/meta.yml new file mode 100644 index 00000000..9dbe24bc --- /dev/null +++ b/modules/biobambam/bammerge/meta.yml @@ -0,0 +1,46 @@ +name: biobambam_bammerge +description: Merge a list of sorted bam files +keywords: + - merge + - bam +tools: + - biobambam: + description: | + biobambam is a set of tools for early stage alignment file processing. + homepage: https://gitlab.com/german.tischler/biobambam2 + documentation: https://gitlab.com/german.tischler/biobambam2/-/blob/master/README.md + doi: 10.1186/1751-0473-9-13 + licence: ["GPL v3"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: List containing 1 or more bam files +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: Merged BAM file + pattern: "*.bam" + - bam_index: + type: file + description: BAM index file + pattern: "*" + - checksum: + type: file + description: Checksum file + pattern: "*" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@matthdsm" diff --git a/tests/config/nextflow.config b/tests/config/nextflow.config index 4ea085f9..2c672d49 100644 --- a/tests/config/nextflow.config +++ b/tests/config/nextflow.config @@ -19,6 +19,7 @@ if ("$PROFILE" == "singularity") { } else { docker.enabled = true docker.userEmulation = true + docker.runOptions = "--platform linux/x86_64" } // Increase time available to build Conda environment diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 172c3a8b..3970c113 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -234,6 +234,10 @@ biobambam/bammarkduplicates2: - modules/biobambam/bammarkduplicates2/** - tests/modules/biobambam/bammarkduplicates2/** +biobambam/bammerge: + - modules/biobambam/bammerge/** + - tests/modules/biobambam/bammerge/** + biobambam/bamsormadup: - modules/biobambam/bamsormadup/** - tests/modules/biobambam/bamsormadup/** diff --git a/tests/modules/biobambam/bammerge/main.nf b/tests/modules/biobambam/bammerge/main.nf new file mode 100644 index 00000000..7b4ee9cb --- /dev/null +++ b/tests/modules/biobambam/bammerge/main.nf @@ -0,0 +1,30 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BIOBAMBAM_BAMMERGE } from '../../../../modules/biobambam/bammerge/main.nf' + +workflow test_biobambam_bammerge_paired { + + input = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam'], checkIfExists: true) + ] + ] + + BIOBAMBAM_BAMMERGE ( input ) +} + +workflow test_biobambam_bammerge_single { + + input = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam'], checkIfExists: true), + ] + ] + + BIOBAMBAM_BAMMERGE ( input ) +} diff --git a/tests/modules/biobambam/bammerge/nextflow.config b/tests/modules/biobambam/bammerge/nextflow.config new file mode 100644 index 00000000..e5d43921 --- /dev/null +++ b/tests/modules/biobambam/bammerge/nextflow.config @@ -0,0 +1,13 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: BIOBAMBAM_BAMMERGE { + ext.args = {[ + "md5=1", + "md5filename=${meta.id}.md5", + "index=1", + "indexfilename=${meta.id}.bam.bai" + ].join(" ").trim()} + } + +} diff --git a/tests/modules/biobambam/bammerge/test.yml b/tests/modules/biobambam/bammerge/test.yml new file mode 100644 index 00000000..d68b7083 --- /dev/null +++ b/tests/modules/biobambam/bammerge/test.yml @@ -0,0 +1,25 @@ +- name: biobambam bammerge test_biobambam_bammerge_paired + command: nextflow run ./tests/modules/biobambam/bammerge -entry test_biobambam_bammerge_paired -c ./tests/config/nextflow.config -c ./tests/modules/biobambam/bammerge/nextflow.config + tags: + - biobambam/bammerge + - biobambam + files: + - path: output/biobambam/test.bam + md5sum: bc3d32ab6a54d1894ca7cc79387dec57 + - path: output/biobambam/test.bam.bai + md5sum: b8ae542a37a73d79de1c15c765207c53 + - path: output/biobambam/test.md5 + md5sum: 31c59857990ceb392242136429e30243 + +- name: biobambam bammerge test_biobambam_bammerge_single + command: nextflow run ./tests/modules/biobambam/bammerge -entry test_biobambam_bammerge_single -c ./tests/config/nextflow.config -c ./tests/modules/biobambam/bammerge/nextflow.config + tags: + - biobambam/bammerge + - biobambam + files: + - path: output/biobambam/test.bam + md5sum: 86185d3d6895a7722d3b3a09c6f91bfc + - path: output/biobambam/test.bam.bai + md5sum: 973680feb6bc73cd1051ea83c7219418 + - path: output/biobambam/test.md5 + md5sum: 244a9d1cbc6d74724285c80220e5e427