From 8f199c4fa44d522194202d05d1e747759fdf9603 Mon Sep 17 00:00:00 2001 From: Merlin Szymanski Date: Mon, 13 Jun 2022 15:09:32 +0200 Subject: [PATCH] Create atlas/splitmerge Module (#1756) * Add atlas/splitmerge module * Finish the tests for atlas/splitmerge * Prettier * Update modules/atlas/splitmerge/meta.yml Co-authored-by: James A. Fellows Yates * Remove curly brackets from meta.yml parameters For single-file outputs, as reviewed * Lintung: Remove trailing white-space Co-authored-by: James A. Fellows Yates --- modules/atlas/splitmerge/main.nf | 36 ++++++++++ modules/atlas/splitmerge/meta.yml | 70 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/config/test_data.config | 4 +- tests/modules/atlas/splitmerge/main.nf | 15 ++++ .../modules/atlas/splitmerge/nextflow.config | 5 ++ tests/modules/atlas/splitmerge/test.yml | 11 +++ 7 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 modules/atlas/splitmerge/main.nf create mode 100644 modules/atlas/splitmerge/meta.yml create mode 100644 tests/modules/atlas/splitmerge/main.nf create mode 100644 tests/modules/atlas/splitmerge/nextflow.config create mode 100644 tests/modules/atlas/splitmerge/test.yml diff --git a/modules/atlas/splitmerge/main.nf b/modules/atlas/splitmerge/main.nf new file mode 100644 index 00000000..b7b07bfb --- /dev/null +++ b/modules/atlas/splitmerge/main.nf @@ -0,0 +1,36 @@ +process ATLAS_SPLITMERGE { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::atlas=0.9.9" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/atlas:0.9.9--h082e891_0': + 'quay.io/biocontainers/atlas:0.9.9--h082e891_0' }" + + input: + tuple val(meta), path(bam), path(bai), path(read_group_settings), path(blacklist) + + output: + tuple val(meta), path("*_mergedReads.bam"), path("*.txt.gz"), emit: data + path "versions.yml", emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def optional = blacklist ? 'blacklist=${blacklist}' : '' + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + atlas \\ + task=splitMerge bam=${bam} \\ + readGroupSettings=${read_group_settings}\\ + $optional \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + atlas: \$((atlas 2>&1) | grep Atlas | head -n 1 | sed -e 's/^[ \t]*Atlas //') + END_VERSIONS + """ +} diff --git a/modules/atlas/splitmerge/meta.yml b/modules/atlas/splitmerge/meta.yml new file mode 100644 index 00000000..0765896a --- /dev/null +++ b/modules/atlas/splitmerge/meta.yml @@ -0,0 +1,70 @@ +name: "atlas_splitmerge" +description: split single end read groups by length and merge paired end reads +keywords: + - split + - merge + - bam + - read group +tools: + - "atlas": + description: "ATLAS, a suite of methods to accurately genotype and estimate genetic diversity" + homepage: "https://bitbucket.org/wegmannlab/atlas/wiki/Home" + documentation: "https://bitbucket.org/wegmannlab/atlas/wiki/Home" + tool_dev_url: "https://bitbucket.org/wegmannlab/atlas" + doi: "10.1101/105346" + licence: "['GPL v3']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + + - bam: + type: file + description: Single input BAM file. + pattern: "*.bam" + - bai: + type: file + description: The BAI file for the input BAM file + pattern: "*.bai" + - read_group_setting: + type: file + description: | + TXT file containing the split and merge settings for + each readgroup. Each line consist of one readgroup, + single/double identifier and the maximum cycle number + of the sequencer. e.g. "RG1 single 100" + pattern: "*.txt" + - blacklist: + type: file + description: | + blacklist.txt (optional), A txt file with blacklisted read names + that should be ignored and just written to file, each on a new line + pattern: "*.txt" + +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: A BAM file with suffix_mergedReads.bam + pattern: "*_mergedReads.bam" + + - filelist: + type: file + description: A file listing all reads that were filtered out in the merging process with suffix_ignoredReads.txt.gz + pattern: "*.txt.gz" + +authors: + - "@merszym" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 46d8a939..578d8252 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -78,6 +78,10 @@ ataqv/ataqv: - modules/ataqv/ataqv/** - tests/modules/ataqv/ataqv/** +atlas/splitmerge: + - modules/atlas/splitmerge/** + - tests/modules/atlas/splitmerge/** + bakta: - modules/bakta/** - tests/modules/bakta/** diff --git a/tests/config/test_data.config b/tests/config/test_data.config index e3713bd1..b97f8899 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -234,8 +234,10 @@ params { mitochon_standin_recalibrated_sorted_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/mitochon_standin.recalibrated.sorted.bam" mitochon_standin_recalibrated_sorted_bam_bai = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/mitochon_standin.recalibrated.sorted.bam.bai" + + test3_single_end_markduplicates_sorted_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/test3.single_end.markduplicates.sorted.bam" - test3_single_end_markduplicates_sorted_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/test3.single_end.markduplicates.sorted.bam" + read_group_settings_txt = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/read_group_settings.txt" test_paired_end_sorted_cram = "${test_data_dir}/genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram" test_paired_end_sorted_cram_crai = "${test_data_dir}/genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram.crai" diff --git a/tests/modules/atlas/splitmerge/main.nf b/tests/modules/atlas/splitmerge/main.nf new file mode 100644 index 00000000..9334c27f --- /dev/null +++ b/tests/modules/atlas/splitmerge/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ATLAS_SPLITMERGE } from '../../../../modules/atlas/splitmerge/main.nf' + +//MAIN +workflow test_atlas_splitmerge { + meta = [ id:'test', single_end:false ] + bam = file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) + bai = file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) + settings = file(params.test_data['homo_sapiens']['illumina']['read_group_settings_txt'], checkIfExists: true) + + ATLAS_SPLITMERGE ( [meta, bam, bai, settings, []] ) +} diff --git a/tests/modules/atlas/splitmerge/nextflow.config b/tests/modules/atlas/splitmerge/nextflow.config new file mode 100644 index 00000000..ff5bc701 --- /dev/null +++ b/tests/modules/atlas/splitmerge/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: ATLAS_SPLITMERGE { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + } +} \ No newline at end of file diff --git a/tests/modules/atlas/splitmerge/test.yml b/tests/modules/atlas/splitmerge/test.yml new file mode 100644 index 00000000..145a2e8a --- /dev/null +++ b/tests/modules/atlas/splitmerge/test.yml @@ -0,0 +1,11 @@ +- name: atlas splitmerge test_atlas_splitmerge + command: nextflow run tests/modules/atlas/splitmerge -entry test_atlas_splitmerge -c tests/config/nextflow.config + tags: + - atlas + - atlas/splitmerge + files: + - path: output/atlas/test.paired_end.sorted_ignoredReads.txt.gz + md5sum: 9b64c47313d2de89c26790f713707ee6 + - path: output/atlas/test.paired_end.sorted_mergedReads.bam + - path: output/atlas/versions.yml + md5sum: 11735bec9c2f4b395b987fd00d4e4294