Skip to content

Commit

Permalink
new module: Picard/fastqtosam (nf-core#1911)
Browse files Browse the repository at this point in the history
* add Picard FastqToSam

* Update test.yml

* update tests

* possible fix?

* fixed!

* Update modules/picard/fastqtosam/main.nf

Co-authored-by: Moritz E. Beber <[email protected]>

* Update modules/picard/fastqtosam/main.nf

Co-authored-by: Moritz E. Beber <[email protected]>

* simplify tests

* fix tests

* revert version check

Co-authored-by: CMGG ICT Team <[email protected]>
Co-authored-by: Moritz E. Beber <[email protected]>
  • Loading branch information
3 people committed Sep 5, 2022
1 parent 6f131aa commit d5bc3d2
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 0 deletions.
43 changes: 43 additions & 0 deletions modules/picard/fastqtosam/main.nf
Original file line number Diff line number Diff line change
@@ -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
"""
}
46 changes: 46 additions & 0 deletions modules/picard/fastqtosam/meta.yml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
43 changes: 43 additions & 0 deletions tests/modules/picard/fastqtosam/main.nf
Original file line number Diff line number Diff line change
@@ -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 )
}
7 changes: 7 additions & 0 deletions tests/modules/picard/fastqtosam/nextflow.config
Original file line number Diff line number Diff line change
@@ -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"
}
}
26 changes: 26 additions & 0 deletions tests/modules/picard/fastqtosam/test.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d5bc3d2

Please sign in to comment.