mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
add bismark/report (#297)
* 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/report * fix test filepaths * remove mysterious index files
This commit is contained in:
parent
04704c2034
commit
f9ce8664ba
11 changed files with 429 additions and 0 deletions
59
software/bismark/align/functions.nf
Normal file
59
software/bismark/align/functions.nf
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
44
software/bismark/align/main.nf
Normal file
44
software/bismark/align/main.nf
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process BISMARK_ALIGN {
|
||||
tag "$meta.id"
|
||||
label 'process_high'
|
||||
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::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:
|
||||
tuple val(meta), path(reads)
|
||||
path index
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*bam") , emit: bam
|
||||
tuple val(meta), path("*report.txt"), emit: report
|
||||
tuple val(meta), path("*fq.gz") , optional:true, emit: unmapped
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
def fastq = meta.single_end ? reads : "-1 ${reads[0]} -2 ${reads[1]}"
|
||||
"""
|
||||
bismark \\
|
||||
$fastq \\
|
||||
$options.args \\
|
||||
--genome $index \\
|
||||
--bam
|
||||
|
||||
echo \$(bismark -v 2>&1) | sed 's/^.*Bismark Version: v//; s/Copyright.*\$//' > ${software}.version.txt
|
||||
"""
|
||||
}
|
58
software/bismark/align/meta.yml
Normal file
58
software/bismark/align/meta.yml
Normal file
|
@ -0,0 +1,58 @@
|
|||
name: bismark_align
|
||||
description: Performs alignment of BS-Seq reads using bismark
|
||||
keywords:
|
||||
- bismark
|
||||
- 3-letter genome
|
||||
- map
|
||||
- methylation
|
||||
- 5mC
|
||||
- methylseq
|
||||
- bisulphite
|
||||
- bam
|
||||
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:
|
||||
- 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.
|
||||
- index:
|
||||
type: dir
|
||||
description: Bismark genome index directory
|
||||
pattern: "BismarkIndex"
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- bam:
|
||||
type: file
|
||||
description: Output BAM file containing read alignments
|
||||
pattern: "*.{bam}"
|
||||
- unmapped:
|
||||
type: file
|
||||
description: Output FastQ file(s) containing unmapped reads
|
||||
pattern: "*.{fq.gz}"
|
||||
- report:
|
||||
type: file
|
||||
description: Bismark alignment reports
|
||||
pattern: "*{report.txt}"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
authors:
|
||||
- "@phue"
|
59
software/bismark/report/functions.nf
Normal file
59
software/bismark/report/functions.nf
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
39
software/bismark/report/main.nf
Normal file
39
software/bismark/report/main.nf
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process BISMARK_REPORT {
|
||||
tag "$meta.id"
|
||||
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:meta.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:
|
||||
tuple val(meta), path(align_report), path(dedup_report), path(splitting_report), path(mbias)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*{html,txt}"), emit: report
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
"""
|
||||
bismark2report \\
|
||||
--alignment_report $align_report \\
|
||||
--dedup_report $dedup_report \\
|
||||
--splitting_report $splitting_report \\
|
||||
--mbias_report $mbias
|
||||
|
||||
echo \$(bismark -v 2>&1) | sed 's/^.*Bismark Version: v//; s/Copyright.*\$//' > ${software}.version.txt
|
||||
"""
|
||||
}
|
59
software/bismark/report/meta.yml
Normal file
59
software/bismark/report/meta.yml
Normal file
|
@ -0,0 +1,59 @@
|
|||
name: bismark_report
|
||||
description: Collects bismark alignment reports
|
||||
keywords:
|
||||
- bismark
|
||||
- qc
|
||||
- methylation
|
||||
- 5mC
|
||||
- methylseq
|
||||
- bisulphite
|
||||
- report
|
||||
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:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- align_report:
|
||||
type: file
|
||||
description: Bismark alignment reports
|
||||
pattern: "*{report.txt}"
|
||||
- splitting_report:
|
||||
type: file
|
||||
description: Bismark splitting reports
|
||||
pattern: "*{splitting_report.txt}"
|
||||
- dedup_report:
|
||||
type: file
|
||||
description: Bismark deduplication reports
|
||||
pattern: "*.{deduplication_report.txt}"
|
||||
- mbias:
|
||||
type: file
|
||||
description: Text file containing methylation bias information
|
||||
pattern: "*.{txt}"
|
||||
- fasta:
|
||||
type: file
|
||||
description: Input genome fasta file
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- report:
|
||||
type: file
|
||||
description: Bismark reports
|
||||
pattern: "*.{html,txt}"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
authors:
|
||||
- "@phue"
|
|
@ -58,6 +58,11 @@ bedtools_sort:
|
|||
- software/bedtools/sort/**
|
||||
- tests/software/bedtools/sort/**
|
||||
|
||||
bismark_align:
|
||||
- software/bismark/align/**
|
||||
- software/bismark/genome_preparation/**
|
||||
- tests/software/bismark/align/**
|
||||
|
||||
bismark_deduplicate:
|
||||
- software/bismark/deduplicate/**
|
||||
- tests/software/bismark/deduplicate/**
|
||||
|
@ -71,6 +76,14 @@ bismark_methylation_extractor:
|
|||
- software/bismark/genome_preparation/**
|
||||
- tests/software/bismark/methylation_extractor/**
|
||||
|
||||
bismark_report:
|
||||
- software/bismark/genome_preparation/**
|
||||
- software/bismark/align/**
|
||||
- software/bismark/deduplicate/**
|
||||
- software/bismark/methylation_extractor/**
|
||||
- software/bismark/report/**
|
||||
- tests/software/bismark/report/**
|
||||
|
||||
blast_makeblastdb:
|
||||
- software/blast/makeblastdb/**
|
||||
- tests/software/blast/makeblastdb/**
|
||||
|
|
42
tests/software/bismark/align/main.nf
Normal file
42
tests/software/bismark/align/main.nf
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { BISMARK_GENOME_PREPARATION } from '../../../../software/bismark/genome_preparation/main.nf' addParams( options: [:] )
|
||||
include { BISMARK_ALIGN as BISMARK_ALIGN_SE } from '../../../../software/bismark/align/main.nf' addParams( options: [ publish_dir:'test_single_end' ] )
|
||||
include { BISMARK_ALIGN as BISMARK_ALIGN_PE } from '../../../../software/bismark/align/main.nf' addParams( options: [ publish_dir:'test_paired_end' ] )
|
||||
|
||||
/*
|
||||
* Test with single-end data
|
||||
*/
|
||||
workflow test_bismark_align_single_end {
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:true ], // meta map
|
||||
[ file("${launchDir}/tests/data/genomics/sarscov2/fastq/test_methylated_1.fastq.gz", checkIfExists: true) ] ]
|
||||
|
||||
|
||||
BISMARK_GENOME_PREPARATION ( file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta", checkIfExists: true) )
|
||||
BISMARK_ALIGN_SE (
|
||||
input,
|
||||
BISMARK_GENOME_PREPARATION.out.index
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
* Test with paired-end data
|
||||
*/
|
||||
workflow test_bismark_align_paired_end {
|
||||
|
||||
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_PE (
|
||||
input,
|
||||
BISMARK_GENOME_PREPARATION.out.index
|
||||
)
|
||||
}
|
19
tests/software/bismark/align/test.yml
Normal file
19
tests/software/bismark/align/test.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
- name: Run bismark align single-end test workflow
|
||||
command: nextflow run ./tests/software/bismark/align -entry test_bismark_align_single_end -c tests/config/nextflow.config
|
||||
tags:
|
||||
- bismark
|
||||
- bismark_align
|
||||
files:
|
||||
- path: output/test_single_end/test_methylated_1_bismark_bt2.bam
|
||||
md5sum: 7f9744cec5aa7908675e5fae79af36fc
|
||||
- path: output/test_single_end/test_methylated_1_bismark_bt2_SE_report.txt
|
||||
|
||||
- name: Run bismark align paired-end test workflow
|
||||
command: nextflow run ./tests/software/bismark/align -entry test_bismark_align_paired_end -c tests/config/nextflow.config
|
||||
tags:
|
||||
- bismark
|
||||
- bismark_align
|
||||
files:
|
||||
- path: output/test_paired_end/test_methylated_1_bismark_bt2_pe.bam
|
||||
md5sum: b13d0d40dffd336375f80fc94acc295f
|
||||
- path: output/test_paired_end/test_methylated_1_bismark_bt2_PE_report.txt
|
29
tests/software/bismark/report/main.nf
Normal file
29
tests/software/bismark/report/main.nf
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/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_REPORT } from '../../../../software/bismark/report/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_bismark_report {
|
||||
|
||||
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_REPORT (
|
||||
BISMARK_ALIGN.out.report
|
||||
.join(BISMARK_DEDUPLICATE.out.report)
|
||||
.join(BISMARK_METHYLATION_EXTRACTOR.out.report)
|
||||
.join(BISMARK_METHYLATION_EXTRACTOR.out.mbias)
|
||||
)
|
||||
}
|
8
tests/software/bismark/report/test.yml
Normal file
8
tests/software/bismark/report/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
- name: Run bismark report test workflow
|
||||
command: nextflow run ./tests/software/bismark/report -entry test_bismark_report -c tests/config/nextflow.config
|
||||
tags:
|
||||
- bismark
|
||||
- bismark_report
|
||||
files:
|
||||
- path: output/bismark/test_methylated_1_bismark_bt2_PE_report.txt
|
||||
- path: output/bismark/test_methylated_1_bismark_bt2_PE_report.html
|
Loading…
Reference in a new issue