add picard_collectwgsmetrics (#304)

* Added new module picard/collectwgsmetrics.

* Removed unused outputs from meta.yml

* Added version.txt file back to meta.yml

* Updated test.yml

* Removed md5sum from test.yaml and added contain tests.

* Update functions.nf

Fixed missing newline formatting.

* Update main.nf

Fixed missing newline formatting.

* style(picard): Remove trailing whitespace

Co-authored-by: Kevin Menden <kevin.menden@t-online.de>
Co-authored-by: Edmund Miller <edmund.a.miller@protonmail.com>
This commit is contained in:
Florian Wuennemann 2021-03-22 12:05:59 -04:00 committed by GitHub
parent eb9178970f
commit 592002aa23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 203 additions and 15 deletions

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* Utility functions used in nf-core DSL2 module files
* -----------------------------------------------------
*/
/*
* Extract name of software tool from process name using $task.process
*/
def getSoftwareName(task_process) {
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
}
/*
* Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
*/
def initOptions(Map args) {
def Map options = [:]
options.args = args.args ?: ''
options.args2 = args.args2 ?: ''
options.args3 = args.args3 ?: ''
options.publish_by_id = args.publish_by_id ?: false
options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files
options.suffix = args.suffix ?: ''
return options
}
/*
* Tidy up and join elements of a list to return a path string
*/
def getPathFromList(path_list) {
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
return paths.join('/')
}
/*
* Function to save/publish module results
*/
def saveFiles(Map args) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
if (ioptions.publish_by_id) {
path_list.add(args.publish_id)
}
if (ioptions.publish_files instanceof Map) {
for (ext in ioptions.publish_files) {
if (args.filename.endsWith(ext.key)) {
def ext_list = path_list.collect()
ext_list.add(ext.value)
return "${getPathFromList(ext_list)}/$args.filename"
}
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
}

View file

@ -0,0 +1,49 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process PICARD_COLLECTWGSMETRICS {
tag "$meta.id"
label 'process_medium'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) }
conda (params.enable_conda ? "bioconda::picard=2.25.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/picard:2.25.0--0"
} else {
container "quay.io/biocontainers/picard:2.25.0--0"
}
input:
tuple val(meta), path(bam), path(bai)
path fasta
output:
tuple val(meta), path("*_metrics"), emit: metrics
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def avail_mem = 3
if (!task.memory) {
log.info '[Picard CollectWgsMetrics] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.'
} else {
avail_mem = task.memory.giga
}
"""
picard \\
-Xmx${avail_mem}g \\
CollectWgsMetrics \\
$options.args \\
INPUT=$bam \\
OUTPUT=${prefix}.CollectWgsMetrics.coverage_metrics \\
REFERENCE_SEQUENCE=$fasta
echo \$(picard CollectWgsMetrics --version 2>&1) | grep -o 'Version.*' | cut -f2- -d: > ${software}.version.txt
"""
}

View file

@ -0,0 +1,46 @@
name: picard_collectwgsmetrics
description: Collect metrics about coverage and performance of whole genome sequencing (WGS) experiments.
keywords:
- alignment
- metrics
- statistics
- quality
- 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://broadinstitute.github.io/picard/
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: BAM file
pattern: "*.{bam}"
- fasta:
type: file
description: Genome fasta file
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- metrics:
type: file
description: Alignment metrics files generated by picard
pattern: "*_{metrics}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@drpatelh"
- "@flowuenne"
- "@lassefolkersen"

View file

@ -76,6 +76,11 @@ bismark_methylation_extractor:
- software/bismark/genome_preparation/** - software/bismark/genome_preparation/**
- tests/software/bismark/methylation_extractor/** - tests/software/bismark/methylation_extractor/**
blast_blastn:
- software/blast/blastn/**
- tests/software/blast/blastn/**
bismark_report: bismark_report:
- software/bismark/genome_preparation/** - software/bismark/genome_preparation/**
- software/bismark/align/** - software/bismark/align/**
@ -96,27 +101,23 @@ blast_makeblastdb:
- software/blast/makeblastdb/** - software/blast/makeblastdb/**
- tests/software/blast/makeblastdb/** - tests/software/blast/makeblastdb/**
blast_blastn: bowtie2_align:
- software/blast/blastn/** - software/bowtie2/align/**
- tests/software/blast/blastn/** - software/bowtie2/build/**
- tests/software/bowtie2/align/**
bowtie_build: bowtie2_build:
- software/bowtie/build/** - software/bowtie2/build/**
- tests/software/bowtie/build_test/** - tests/software/bowtie2/build_test/**
bowtie_align: bowtie_align:
- software/bowtie/align/** - software/bowtie/align/**
- software/bowtie/build/** - software/bowtie/build/**
- tests/software/bowtie/align/** - tests/software/bowtie/align/**
bowtie2_build: bowtie_build:
- software/bowtie2/build/** - software/bowtie/build/**
- tests/software/bowtie2/build_test/** - tests/software/bowtie/build_test/**
bowtie2_align:
- software/bowtie2/align/**
- software/bowtie2/build/**
- tests/software/bowtie2/align/**
bwa_index: bwa_index:
- software/bwa/index/** - software/bwa/index/**
@ -255,6 +256,10 @@ picard_collectmultiplemetrics:
- software/picard/collectmultiplemetrics/** - software/picard/collectmultiplemetrics/**
- tests/software/picard/collectmultiplemetrics/** - tests/software/picard/collectmultiplemetrics/**
picard_collectwgsmetrics:
- software/picard/collectwgsmetrics/**
- tests/software/picard/collectwgsmetrics/**
picard_markduplicates: picard_markduplicates:
- software/picard/markduplicates/** - software/picard/markduplicates/**
- tests/software/picard/markduplicates/** - tests/software/picard/markduplicates/**
@ -370,4 +375,3 @@ ucsc_bedgraphtobigwig:
untar: untar:
- software/untar/** - software/untar/**
- tests/software/untar/** - tests/software/untar/**

View file

@ -0,0 +1,18 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { PICARD_COLLECTWGSMETRICS } from '../../../../software/picard/collectwgsmetrics/main.nf' addParams( options: [:] )
workflow test_picard_collectwgsmetrics {
def input = []
input = [ [ id:'test', single_end:false ], // meta map
file("${launchDir}/tests/data/genomics/sarscov2/bam/test_paired_end.sorted.bam", checkIfExists: true),
file("${launchDir}/tests/data/genomics/sarscov2/bam/test_paired_end.sorted.bam.bai", checkIfExists: true),]
PICARD_COLLECTWGSMETRICS (
input,
file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta", checkIfExists: true)
)
}

View file

@ -0,0 +1,11 @@
- name: picard collectwgsmetrics test_picard_collectwgsmetrics
command: nextflow run tests/software/picard/collectwgsmetrics -entry test_picard_collectwgsmetrics -c tests/config/nextflow.config
tags:
- picard_collectwgsmetrics
- picard
files:
- path: output/picard/test.CollectWgsMetrics.coverage_metrics
contains:
- "GENOME_TERRITORY"
- "29829"
- "17554"