mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
add bismark/methylation_extractor (#274)
* add bismark/methylation_extractor * add tests for bismark/methylation_extractor * bismark/methylation_extractor: add genome_preparation to filters * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * remove params from meta.yml * pytest: remove md5sum checks for gzipped output gzip stores timestamps in the file header, so the checksum will be different each time Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
e61f400167
commit
04704c2034
6 changed files with 220 additions and 0 deletions
59
software/bismark/methylation_extractor/functions.nf
Normal file
59
software/bismark/methylation_extractor/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"
|
||||
}
|
||||
}
|
||||
}
|
48
software/bismark/methylation_extractor/main.nf
Normal file
48
software/bismark/methylation_extractor/main.nf
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process BISMARK_METHYLATION_EXTRACTOR {
|
||||
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(bam)
|
||||
path index
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.bedGraph.gz") , emit: bedgraph
|
||||
tuple val(meta), path("*.txt.gz") , emit: methylation_calls
|
||||
tuple val(meta), path("*.cov.gz") , emit: coverage
|
||||
tuple val(meta), path("*_splitting_report.txt"), emit: report
|
||||
tuple val(meta), path("*.M-bias.txt") , emit: mbias
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def seqtype = meta.single_end ? '-s' : '-p'
|
||||
def software = getSoftwareName(task.process)
|
||||
"""
|
||||
bismark_methylation_extractor \\
|
||||
--bedGraph \\
|
||||
--counts \\
|
||||
--gzip \\
|
||||
--report \\
|
||||
$seqtype \\
|
||||
$options.args \\
|
||||
$bam
|
||||
|
||||
echo \$(bismark -v 2>&1) | sed 's/^.*Bismark Version: v//; s/Copyright.*\$//' > ${software}.version.txt
|
||||
"""
|
||||
}
|
66
software/bismark/methylation_extractor/meta.yml
Normal file
66
software/bismark/methylation_extractor/meta.yml
Normal file
|
@ -0,0 +1,66 @@
|
|||
name: bismark_methylation_extractor
|
||||
description: Extracts methylation information for individual cytosines from alignments.
|
||||
keywords:
|
||||
- bismark
|
||||
- consensus
|
||||
- map
|
||||
- methylation
|
||||
- 5mC
|
||||
- methylseq
|
||||
- bisulphite
|
||||
- bam
|
||||
- bedGraph
|
||||
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 ]
|
||||
- bam:
|
||||
type: file
|
||||
description: BAM file containing read alignments
|
||||
pattern: "*.{bam}"
|
||||
- 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 ]
|
||||
- bedgraph:
|
||||
type: file
|
||||
description: Bismark output file containing coverage and methylation metrics
|
||||
pattern: "*.{bedGraph.gz}"
|
||||
- methylation_calls:
|
||||
type: file
|
||||
description: Bismark output file containing strand-specific methylation calls
|
||||
pattern: "*.{txt.gz}"
|
||||
- coverage:
|
||||
type: file
|
||||
description: Bismark output file containing coverage metrics
|
||||
pattern: "*.{cov.gz}"
|
||||
- report:
|
||||
type: file
|
||||
description: Bismark splitting reports
|
||||
pattern: "*_{splitting_report.txt}"
|
||||
- mbias:
|
||||
type: file
|
||||
description: Text file containing methylation bias information
|
||||
pattern: "*.{M-bias.txt}"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
authors:
|
||||
- "@phue"
|
|
@ -66,6 +66,15 @@ bismark_genome_preparation:
|
|||
- software/bismark/genome_preparation/**
|
||||
- tests/software/bismark/genome_preparation/**
|
||||
|
||||
bismark_methylation_extractor:
|
||||
- software/bismark/methylation_extractor/**
|
||||
- software/bismark/genome_preparation/**
|
||||
- tests/software/bismark/methylation_extractor/**
|
||||
|
||||
blast_makeblastdb:
|
||||
- software/blast/makeblastdb/**
|
||||
- tests/software/blast/makeblastdb/**
|
||||
|
||||
blast_blastn:
|
||||
- software/blast/blastn/**
|
||||
- tests/software/blast/blastn/**
|
||||
|
|
20
tests/software/bismark/methylation_extractor/main.nf
Normal file
20
tests/software/bismark/methylation_extractor/main.nf
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { BISMARK_GENOME_PREPARATION } from '../../../../software/bismark/genome_preparation/main.nf' addParams( options: [:] )
|
||||
include { BISMARK_METHYLATION_EXTRACTOR } from '../../../../software/bismark/methylation_extractor/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_bismark_methylation_extractor {
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
[ file("${launchDir}/tests/data/genomics/sarscov2/bam/test_methylated_paired_end.bam", checkIfExists: true) ] ]
|
||||
|
||||
BISMARK_GENOME_PREPARATION ( file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta", checkIfExists: true) )
|
||||
|
||||
BISMARK_METHYLATION_EXTRACTOR (
|
||||
input,
|
||||
BISMARK_GENOME_PREPARATION.out.index
|
||||
)
|
||||
}
|
18
tests/software/bismark/methylation_extractor/test.yml
Normal file
18
tests/software/bismark/methylation_extractor/test.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
- name: Run bismark methylation extractor test workflow
|
||||
command: nextflow run ./tests/software/bismark/methylation_extractor -entry test_bismark_methylation_extractor -c tests/config/nextflow.config
|
||||
tags:
|
||||
- bismark
|
||||
- bismark_methylation_extractor
|
||||
files:
|
||||
- path: output/bismark/CHG_OB_test_methylated_paired_end.txt.gz
|
||||
- path: output/bismark/CHG_OT_test_methylated_paired_end.txt.gz
|
||||
- path: output/bismark/CHH_OB_test_methylated_paired_end.txt.gz
|
||||
- path: output/bismark/CHH_OT_test_methylated_paired_end.txt.gz
|
||||
- path: output/bismark/CpG_OB_test_methylated_paired_end.txt.gz
|
||||
- path: output/bismark/CpG_OT_test_methylated_paired_end.txt.gz
|
||||
- path: output/bismark/test_methylated_paired_end.bedGraph.gz
|
||||
- path: output/bismark/test_methylated_paired_end.bismark.cov.gz
|
||||
- path: output/bismark/test_methylated_paired_end.M-bias.txt
|
||||
md5sum: 0b100924d46b3c35115f1206f34c4a59
|
||||
- path: output/bismark/test_methylated_paired_end_splitting_report.txt
|
||||
md5sum: 288d6f0110127e3a8c10391802118202
|
Loading…
Reference in a new issue