diff --git a/modules/elprep/merge/main.nf b/modules/elprep/merge/main.nf new file mode 100644 index 00000000..d5ffc497 --- /dev/null +++ b/modules/elprep/merge/main.nf @@ -0,0 +1,43 @@ +process ELPREP_MERGE { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::elprep=5.1.2" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/elprep:5.1.2--he881be0_0': + 'quay.io/biocontainers/elprep:5.1.2--he881be0_0' }" + + input: + tuple val(meta), path(bam) + + output: + tuple val(meta), path("output/**.{bam,sam}") , emit: bam + 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 suffix = args.contains("--output-type sam") ? "sam" : "bam" + def single_end = meta.single_end ? " --single-end" : "" + + """ + # create directory and move all input so elprep can find and merge them before splitting + mkdir input + mv ${bam} input/ + + elprep merge \\ + input/ \\ + output/${prefix}.${suffix} \\ + $args \\ + ${single_end} \\ + --nr-of-threads $task.cpus + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + elprep: \$(elprep 2>&1 | head -n2 | tail -n1 |sed 's/^.*version //;s/ compiled.*\$//') + END_VERSIONS + """ +} diff --git a/modules/elprep/merge/meta.yml b/modules/elprep/merge/meta.yml new file mode 100644 index 00000000..1f49b1a0 --- /dev/null +++ b/modules/elprep/merge/meta.yml @@ -0,0 +1,44 @@ +name: "elprep_merge" +description: Merge split bam/sam chunks in one file +keywords: + - bam + - sam + - merge +tools: + - "elprep": + description: "elPrep is a high-performance tool for preparing .sam/.bam files for variant calling in sequencing pipelines. It can be used as a drop-in replacement for SAMtools/Picard/GATK4." + homepage: "https://github.com/ExaScience/elprep" + documentation: "https://github.com/ExaScience/elprep" + tool_dev_url: "https://github.com/ExaScience/elprep" + doi: "10.1371/journal.pone.0244471" + licence: "['AGPL v3']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: List of BAM/SAM chunks to merge + pattern: "*.{bam,sam}" + +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" + - bam: + type: file + description: Merged BAM/SAM file + pattern: "*.{bam,sam}" + +authors: + - "@matthdsm" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index dfcbfa8c..dcf85ba0 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -603,6 +603,10 @@ elprep/filter: - modules/elprep/filter/** - tests/modules/elprep/filter/** +elprep/merge: + - modules/elprep/merge/** + - tests/modules/elprep/merge/** + elprep/split: - modules/elprep/split/** - tests/modules/elprep/split/** diff --git a/tests/modules/elprep/merge/main.nf b/tests/modules/elprep/merge/main.nf new file mode 100644 index 00000000..b4a40ce3 --- /dev/null +++ b/tests/modules/elprep/merge/main.nf @@ -0,0 +1,17 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ELPREP_SPLIT } from '../../../../modules/elprep/split/main.nf' +include { ELPREP_MERGE } from '../../../../modules/elprep/merge/main.nf' + +workflow test_elprep_merge { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) + ] + + ELPREP_SPLIT ( input ) + ELPREP_MERGE ( ELPREP_SPLIT.out.bam ) +} diff --git a/tests/modules/elprep/merge/nextflow.config b/tests/modules/elprep/merge/nextflow.config new file mode 100644 index 00000000..4e4570f4 --- /dev/null +++ b/tests/modules/elprep/merge/nextflow.config @@ -0,0 +1,5 @@ +process { + withName : ELPREP_MERGE { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + } +} diff --git a/tests/modules/elprep/merge/test.yml b/tests/modules/elprep/merge/test.yml new file mode 100644 index 00000000..ad2ecfef --- /dev/null +++ b/tests/modules/elprep/merge/test.yml @@ -0,0 +1,8 @@ +- name: elprep merge test_elprep_merge + command: nextflow run tests/modules/elprep/merge -entry test_elprep_merge -c tests/config/nextflow.config + tags: + - elprep + - elprep/merge + files: + - path: output/elprep/output/test.bam + - path: output/elprep/versions.yml