From 8c0089785381249a38a6b2feb02c41beb314a8fa Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Mon, 21 Mar 2022 11:26:12 +0100 Subject: [PATCH] Add AdapterRemovalFixPrefix (#1424) * Add AdapterRemovalFixPrefix * Prettifying Co-authored-by: Alexander Peltzer --- modules/adapterremovalfixprefix/main.nf | 38 ++++++++++++++++ modules/adapterremovalfixprefix/meta.yml | 43 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/adapterremovalfixprefix/main.nf | 19 ++++++++ .../adapterremovalfixprefix/nextflow.config | 9 ++++ .../modules/adapterremovalfixprefix/test.yml | 9 ++++ 6 files changed, 122 insertions(+) create mode 100644 modules/adapterremovalfixprefix/main.nf create mode 100644 modules/adapterremovalfixprefix/meta.yml create mode 100644 tests/modules/adapterremovalfixprefix/main.nf create mode 100644 tests/modules/adapterremovalfixprefix/nextflow.config create mode 100644 tests/modules/adapterremovalfixprefix/test.yml diff --git a/modules/adapterremovalfixprefix/main.nf b/modules/adapterremovalfixprefix/main.nf new file mode 100644 index 00000000..c0137fb4 --- /dev/null +++ b/modules/adapterremovalfixprefix/main.nf @@ -0,0 +1,38 @@ +def VERSION = '0.05' + +process ADAPTERREMOVALFIXPREFIX { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::adapterremovalfixprefix=0.0.5" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/adapterremovalfixprefix:0.0.5--hdfd78af_2': + 'quay.io/biocontainers/adapterremovalfixprefix:0.0.5--hdfd78af_2' }" + + input: + tuple val(meta), path(fastq) + + output: + tuple val(meta), path("*.fq.gz"), emit: fixed_fastq + 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}" + if ("$fastq" == "${prefix}.fq.gz") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + + """ + AdapterRemovalFixPrefix \\ + $fastq \\ + $args \\ + | gzip > ${prefix}.fq.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + adapterremovalfixprefix: $VERSION + END_VERSIONS + """ +} diff --git a/modules/adapterremovalfixprefix/meta.yml b/modules/adapterremovalfixprefix/meta.yml new file mode 100644 index 00000000..db69bc07 --- /dev/null +++ b/modules/adapterremovalfixprefix/meta.yml @@ -0,0 +1,43 @@ +name: adapterremovalfixprefix +description: Fixes prefixes from AdapterRemoval2 output to make sure no clashing read names are in the output. For use with DeDup. +keywords: + - adapterremoval + - fastq + - dedup +tools: + - adapterremovalfixprefix: + description: Fixes adapter removal prefixes to make sure no clashing read names are in the output. + homepage: https://github.com/apeltzer/AdapterRemovalFixPrefix + documentation: None + tool_dev_url: https://github.com/apeltzer/AdapterRemovalFixPrefix + doi: "10.1186/s13059-016-0918-z" + licence: ["GPL v3"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - fastq: + type: file + description: FASTQ file from AdapterRemoval2 + pattern: "*.{fq.gz,fastq.gz}" + +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" + - fixed_fastq: + type: file + description: FASTQ file with fixed read prefixes for DeDup + pattern: "*.{fq.gz}" + +authors: + - "@jfy133" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index ea17ce2e..20ca238f 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -14,6 +14,10 @@ adapterremoval: - modules/adapterremoval/** - tests/modules/adapterremoval/** +adapterremovalfixprefix: + - modules/adapterremovalfixprefix/** + - tests/modules/adapterremovalfixprefix/** + agrvate: - modules/agrvate/** - tests/modules/agrvate/** diff --git a/tests/modules/adapterremovalfixprefix/main.nf b/tests/modules/adapterremovalfixprefix/main.nf new file mode 100644 index 00000000..863a7ca8 --- /dev/null +++ b/tests/modules/adapterremovalfixprefix/main.nf @@ -0,0 +1,19 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ADAPTERREMOVAL } from '../../../modules/adapterremoval/main.nf' +include { ADAPTERREMOVALFIXPREFIX } from '../../../modules/adapterremovalfixprefix/main.nf' + +workflow test_adapterremovalfixprefix { + + input = [ + [ id:'test', single_end:false ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) + ] + ] + + ADAPTERREMOVAL ( input, [] ) + ADAPTERREMOVALFIXPREFIX ( ADAPTERREMOVAL.out.collapsed ) +} diff --git a/tests/modules/adapterremovalfixprefix/nextflow.config b/tests/modules/adapterremovalfixprefix/nextflow.config new file mode 100644 index 00000000..dcfdc48c --- /dev/null +++ b/tests/modules/adapterremovalfixprefix/nextflow.config @@ -0,0 +1,9 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: ADAPTERREMOVAL { + ext.args = "--collapse" + } + +} diff --git a/tests/modules/adapterremovalfixprefix/test.yml b/tests/modules/adapterremovalfixprefix/test.yml new file mode 100644 index 00000000..4ef6a41e --- /dev/null +++ b/tests/modules/adapterremovalfixprefix/test.yml @@ -0,0 +1,9 @@ +- name: adapterremovalfixprefix test_adapterremovalfixprefix + command: nextflow run tests/modules/adapterremovalfixprefix -entry test_adapterremovalfixprefix -c tests/config/nextflow.config + tags: + - adapterremovalfixprefix + files: + - path: output/adapterremovalfixprefix/test.fq.gz + md5sum: ff956de3532599a56c3efe5369f0953f + - path: output/adapterremovalfixprefix/versions.yml + md5sum: 983cb58079bf015c1d489a7e48261746