Skip to content

Commit

Permalink
Merge pull request #21 from CCBR/picard-samtofastq
Browse files Browse the repository at this point in the history
New module picard samtofastq
  • Loading branch information
kelly-sovacool authored Oct 23, 2023
2 parents 048ba8c + 42811fa commit 1773e91
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
- custom/bam_to_fastq (#14)
- cutadapt (#11)
- khmer/uniquekmers (#7)
- picard/samtofastq (#21)
- samtools/filteraligned (#13,#20)
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ Many of the modules and subworkflows in this project reuse and adapt code from [
In those cases, credit is noted in the `meta.yml` file of the module/subworkflow and also listed here:

- [bwa](modules/CCBR/bwa) adapts the [nf-core bwa module](https://github.com/nf-core/chipseq/tree/51eba00b32885c4d0bec60db3cb0a45eb61e34c5/modules/nf-core/modules/bwa)
- [cutadapt](modules/CCBR/cutadapt) adapts the [nf-core cutadapt module](https://github.com/nf-core/modules/tree/master/modules/nf-core/cutadapt)
- [cutadapt](modules/CCBR/cutadapt) adapts the [nf-core cutadapt module](https://github.com/nf-core/modules/tree/ef007b1ce5316506b8c27c3e7a62482409c6153c/modules/nf-core/cutadapt)
- [khmer](modules/CCBR/khmer) adapts the [nf-core khmer module](https://github.com/nf-core/modules/tree/b48a1efc8e067502e1a9bafbac788c1e0abdfc6a/modules/nf-core/khmer)
- [picard/samtofastq](modules/picard/samtofastq) adapts the [nf-core gatk4 samtofastq module](https://github.com/nf-core/modules/tree/ef007b1ce5316506b8c27c3e7a62482409c6153c/modules/nf-core/gatk4/samtofastq)
48 changes: 48 additions & 0 deletions modules/CCBR/picard/samtofastq/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
process PICARD_SAMTOFASTQ {
tag { meta.id }
label 'process_medium'

container 'nciccbr/ccbr_picard_2.27.5:v1'

input:
tuple val(meta), path(bam)

output:
tuple val(meta), path("*.fastq.gz"), emit: reads
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 output = meta.single_end ? "--FASTQ ${prefix}.fastq" : "--FASTQ ${prefix}_1.fastq --SECOND_END_FASTQ ${prefix}_2.fastq --UNPAIRED_FASTQ ${prefix}.unpaired.fastq"

if (!task.memory) {
log.warn '[Picard SamToFastq] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.'
}
def avail_mem = task.memory ? (task.memory.mega*0.8).intValue() : 3072

"""
picard \\
-Xmx${avail_mem}M \\
SamToFastq \\
${args} \\
--INPUT ${bam} \\
${output}
pigz -p ${task.cpus} *.fastq
cat <<-END_VERSIONS > versions.yml
"${task.process}":
picard: \$(picard SamToFastq --version 2>&1 | grep -o 'Version:.*' | cut -f2- -d:)
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.fastq.gz versions.yml
"""
}
44 changes: 44 additions & 0 deletions modules/CCBR/picard/samtofastq/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "picard_samtofastq"
description: Converts a BAM or SAM file to fastq. Adapted from the nf-core gatk4 samtofastq module.
keywords:
- fastq
- bam
- sam
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 ]
- bam:
type: file
description: |
SAM or BAM file
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"
- fastq:
type: file
description: fastq files
pattern: "*.{fastq}"
authors:
- "@kelly-sovacool"
maintainers:
- "@kelly-sovacool"
4 changes: 4 additions & 0 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ khmer/uniquekmers:
- modules/CCBR/khmer/uniquekmers/**
- tests/CCBR/khmer/uniquekmers/**

picard/samtofastq:
- modules/CCBR/picard/samtofastq/**
- tests/modules/CCBR/picard/samtofastq/**

samtools/filteraligned:
- modules/CCBR/samtools/filteraligned/**
- tests/modules/CCBR/samtools/filteraligned/**
19 changes: 19 additions & 0 deletions tests/modules/CCBR/picard/samtofastq/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env nextflow

nextflow.enable.dsl = 2

include { PICARD_SAMTOFASTQ } from '../../../../../modules/CCBR/picard/samtofastq/main.nf'

workflow test_picard_samtofastq_single {
input = [ [ id:'test', single_end: true ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_single_end_bam'], checkIfExists: true) ]
]
PICARD_SAMTOFASTQ ( input )
}

workflow test_picard_samtofastq_paired {
input = [ [ id:'test', single_end: false ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) ]
]
PICARD_SAMTOFASTQ ( input )
}
4 changes: 4 additions & 0 deletions tests/modules/CCBR/picard/samtofastq/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
}
34 changes: 34 additions & 0 deletions tests/modules/CCBR/picard/samtofastq/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
- name: picard samtofastq test_picard_samtofastq_single
command: nextflow run ./tests/modules/CCBR/picard/samtofastq -entry test_picard_samtofastq_single -c ./tests/config/nextflow.config
tags:
- picard/samtofastq
- picard
files:
- path: output/picard/test.fastq.gz
contains:
- "@ERR5069949.2151832"
- path: output/picard/versions.yml

- name: picard samtofastq test_picard_samtofastq_paired
command: nextflow run ./tests/modules/CCBR/picard/samtofastq -entry test_picard_samtofastq_paired -c ./tests/config/nextflow.config
tags:
- picard/samtofastq
- picard
files:
- path: output/picard/test_1.fastq.gz
contains:
- "@ERR5069949.2151832/1"
- path: output/picard/test_2.fastq.gz
contains:
- "@ERR5069949.2151832/2"
- path: output/picard/test.unpaired.fastq.gz
- path: output/picard/versions.yml

- name: picard samtofastq test_picard_samtofastq_single stub
command: nextflow run ./tests/modules/CCBR/picard/samtofastq -entry test_picard_samtofastq_single -c ./tests/config/nextflow.config -stub
tags:
- picard/samtofastq
- picard
files:
- path: output/picard/test.fastq.gz
- path: output/picard/versions.yml

0 comments on commit 1773e91

Please sign in to comment.