add bismark/summary (#295)

* add bismark/align module

* bismark/align: add tests

* bismark/align: update meta.yml

* bismark/align: skip checksum for alignment logs

they contain timestamps

* bismark/align: restore correct checksum

caused some mixup in the last commit

* bismark/align: add genome_preparation to filters

* Fix conda version pin

* change options to be a global var

* remove params from meta.yml

* add bismark/summary

* remove md5sum check for bismark_summary_report.html

it contains a timestamp

* fix tests

* update meta.yml

* remove mysterious index files
This commit is contained in:
Patrick Hüther 2021-03-22 14:58:54 +01:00 committed by GitHub
parent 134c8ef6ce
commit eb9178970f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 197 additions and 0 deletions

View file

@ -0,0 +1,59 @@
/*
* -----------------------------------------------------
* 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.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,38 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process BISMARK_SUMMARY {
label 'process_low'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:'') }
conda (params.enable_conda ? "bioconda::bismark=0.23.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/bismark:0.23.0--0"
} else {
container "quay.io/biocontainers/bismark:0.23.0--0"
}
input:
path(bam)
path(align_report)
path(dedup_report)
path(splitting_report)
path(mbias)
output:
path("*{html,txt}") , emit: summary
path "*.version.txt", emit: version
script:
def software = getSoftwareName(task.process)
"""
bismark2summary
echo \$(bismark -v 2>&1) | sed 's/^.*Bismark Version: v//; s/Copyright.*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,53 @@
name: bismark_summary
description: |
Uses Bismark report files of several samples in a run folder
to generate a graphical summary HTML report.
keywords:
- bismark
- qc
- methylation
- 5mC
- methylseq
- bisulphite
- report
- summary
tools:
- bismark:
description: |
Bismark is a tool to map bisulfite treated sequencing reads
and perform methylation calling in a quick and easy-to-use fashion.
homepage: https://github.com/FelixKrueger/Bismark
documentation: https://github.com/FelixKrueger/Bismark/tree/master/Docs
doi: 10.1093/bioinformatics/btr167
input:
- bam:
type: file
description: Bismark alignment
pattern: "*.{bam}"
- align_report:
type: file
description: Bismark alignment reports
pattern: "*{report.txt}"
- dedup_report:
type: file
description: Bismark deduplication reports
pattern: "*.{deduplication_report.txt}"
- splitting_report:
type: file
description: Bismark splitting reports
pattern: "*{splitting_report.txt}"
- mbias:
type: file
description: Text file containing methylation bias information
pattern: "*.{txt}"
output:
- summary:
type: file
description: Bismark summary
pattern: "*.{html,txt}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@phue"

View file

@ -84,6 +84,14 @@ bismark_report:
- software/bismark/report/**
- tests/software/bismark/report/**
bismark_summary:
- software/bismark/genome_preparation/**
- software/bismark/align/**
- software/bismark/deduplicate/**
- software/bismark/methylation_extractor/**
- software/bismark/summary/**
- tests/software/bismark/summary/**
blast_makeblastdb:
- software/blast/makeblastdb/**
- tests/software/blast/makeblastdb/**

View file

@ -0,0 +1,30 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BISMARK_GENOME_PREPARATION } from '../../../../software/bismark/genome_preparation/main.nf' addParams( options: [:] )
include { BISMARK_ALIGN } from '../../../../software/bismark/align/main.nf' addParams( options: [:] )
include { BISMARK_DEDUPLICATE } from '../../../../software/bismark/deduplicate/main.nf' addParams( options: [:] )
include { BISMARK_METHYLATION_EXTRACTOR } from '../../../../software/bismark/methylation_extractor/main.nf' addParams( options: [:] )
include { BISMARK_SUMMARY } from '../../../../software/bismark/summary/main.nf' addParams( options: [:] )
workflow test_bismark_summary {
def input = []
input = [ [ id:'test', single_end:false ], // meta map
[ file("${launchDir}/tests/data/genomics/sarscov2/fastq/test_methylated_1.fastq.gz", checkIfExists: true),
file("${launchDir}/tests/data/genomics/sarscov2/fastq/test_methylated_2.fastq.gz", checkIfExists: true) ] ]
BISMARK_GENOME_PREPARATION ( file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta", checkIfExists: true) )
BISMARK_ALIGN ( input, BISMARK_GENOME_PREPARATION.out.index )
BISMARK_DEDUPLICATE ( BISMARK_ALIGN.out.bam )
BISMARK_METHYLATION_EXTRACTOR ( BISMARK_DEDUPLICATE.out.bam, BISMARK_GENOME_PREPARATION.out.index )
BISMARK_SUMMARY (
BISMARK_ALIGN.out.bam.collect{ meta, bam -> bam },
BISMARK_ALIGN.out.report.collect{ meta, report -> report },
BISMARK_DEDUPLICATE.out.report.collect{ meta, bam -> bam },
BISMARK_METHYLATION_EXTRACTOR.out.report.collect{ meta, report -> report },
BISMARK_METHYLATION_EXTRACTOR.out.mbias.collect{ meta, mbias -> mbias }
)
}

View file

@ -0,0 +1,9 @@
- name: Run bismark summary test workflow
command: nextflow run ./tests/software/bismark/summary -entry test_bismark_summary -c tests/config/nextflow.config
tags:
- bismark
- bismark_summary
files:
- path: output/bismark/bismark_summary_report.html
- path: output/bismark/bismark_summary_report.txt
md5sum: 06fc717e81b3f8f0d6e279d572f407f6