diff --git a/modules/picard/fastqtosam/main.nf b/modules/picard/fastqtosam/main.nf new file mode 100644 index 00000000..2feb274c --- /dev/null +++ b/modules/picard/fastqtosam/main.nf @@ -0,0 +1,43 @@ +process PICARD_FASTQTOSAM { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::picard=2.27.4" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/picard:2.27.4--hdfd78af_0' : + 'quay.io/biocontainers/picard:2.27.4--hdfd78af_0' }" + + input: + tuple val(meta), path(reads) + + output: + tuple val(meta), path("*.bam"), 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}" + if (!task.memory) { + log.warn '[Picard FastqToSam] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' + } + def avail_mem = task.memory ? task.memory.giga : 3 + def input = meta.single_end ? "--FASTQ ${reads}" : "--FASTQ ${reads[0]} --FASTQ2 ${reads[1]}" + def sample_name = args.contains("--SAMPLE_NAME") || args.contains("-SM") ? "" : "--SAMPLE_NAME ${prefix}" + """ + picard \\ + -Xmx${avail_mem}g \\ + FastqToSam \\ + ${args} \\ + ${input} \\ + ${sample_name} \\ + --OUTPUT ${prefix}.bam + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + picard: \$(picard FastqToSam --version 2>&1 | grep -o 'Version:.*' | cut -f2- -d:) + END_VERSIONS + """ +} diff --git a/modules/picard/fastqtosam/meta.yml b/modules/picard/fastqtosam/meta.yml new file mode 100644 index 00000000..39f1d79b --- /dev/null +++ b/modules/picard/fastqtosam/meta.yml @@ -0,0 +1,46 @@ +name: "picard_fastqtosam" +description: Converts a FASTQ file to an unaligned BAM or SAM file. +keywords: + - fastq + - unaligned + - bam +tools: + - picard: + description: | + A set of command line tools (in Java) for manipulating high-throughput sequencing (HTS) + data and formats such as SAM/BAM/CRAM and VCF. + homepage: https://broadinstitute.github.io/picard/ + documentation: https://gatk.broadinstitute.org/hc/en-us/articles/360036510672-FastqToSam-Picard- + tool_dev_url: https://github.com/broadinstitute/picard + licence: ["MIT"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - reads: + type: file + description: | + List of input FastQ files of size 1 and 2 for single-end and paired-end data, + respectively. + +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: Unaligned bam file + pattern: "*.{bam}" + +authors: + - "@matthdsm" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 89b29d26..b3fe0cad 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1715,6 +1715,10 @@ picard/crosscheckfingerprints: - modules/picard/crosscheckfingerprints/** - tests/modules/picard/crosscheckfingerprints/** +picard/fastqtosam: + - modules/picard/fastqtosam/** + - tests/modules/picard/fastqtosam/** + picard/filtersamreads: - modules/picard/filtersamreads/** - tests/modules/picard/filtersamreads/** diff --git a/tests/modules/picard/fastqtosam/main.nf b/tests/modules/picard/fastqtosam/main.nf new file mode 100644 index 00000000..2eb55e63 --- /dev/null +++ b/tests/modules/picard/fastqtosam/main.nf @@ -0,0 +1,43 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { PICARD_FASTQTOSAM } from '../../../../modules/picard/fastqtosam/main.nf' + +workflow test_picard_fastqtosam_single { + + input = [ + [ id:'test', single_end:true ], // meta map + [ + file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) + ] + ] + + PICARD_FASTQTOSAM ( input ) +} + +workflow test_picard_fastqtosam_paired { + + 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) + ] + ] + + PICARD_FASTQTOSAM ( input ) +} + +workflow test_picard_fastqtosam_paired_custom_samplename { + + 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) + ] + ] + + PICARD_FASTQTOSAM ( input ) +} diff --git a/tests/modules/picard/fastqtosam/nextflow.config b/tests/modules/picard/fastqtosam/nextflow.config new file mode 100644 index 00000000..25c849c9 --- /dev/null +++ b/tests/modules/picard/fastqtosam/nextflow.config @@ -0,0 +1,7 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: "test_picard_fastqtosam_paired_custom_samplename:PICARD_FASTQTOSAM" { + ext.args = "--SAMPLE_NAME CustomSample" + } +} diff --git a/tests/modules/picard/fastqtosam/test.yml b/tests/modules/picard/fastqtosam/test.yml new file mode 100644 index 00000000..929af92a --- /dev/null +++ b/tests/modules/picard/fastqtosam/test.yml @@ -0,0 +1,26 @@ +- name: picard fastqtosam test_picard_fastqtosam_single + command: nextflow run ./tests/modules/picard/fastqtosam -entry test_picard_fastqtosam_single -c ./tests/config/nextflow.config -c ./tests/modules/picard/fastqtosam/nextflow.config + tags: + - picard + - picard/fastqtosam + files: + - path: output/picard/test.bam + md5sum: fe2882efe8f13a8da20fcc63469ed0aa + +- name: picard fastqtosam test_picard_fastqtosam_paired + command: nextflow run ./tests/modules/picard/fastqtosam -entry test_picard_fastqtosam_paired -c ./tests/config/nextflow.config -c ./tests/modules/picard/fastqtosam/nextflow.config + tags: + - picard + - picard/fastqtosam + files: + - path: output/picard/test.bam + md5sum: 90e4f59f9d942f96c3f3c41160f3fd5d + +- name: picard fastqtosam test_picard_fastqtosam_paired_custom_samplename + command: nextflow run ./tests/modules/picard/fastqtosam -entry test_picard_fastqtosam_paired_custom_samplename -c ./tests/config/nextflow.config -c ./tests/modules/picard/fastqtosam/nextflow.config + tags: + - picard + - picard/fastqtosam + files: + - path: output/picard/test.bam + md5sum: 69d35ee2b5dc263d022eaf59a9e383d3