add bwameth/align module + tests

This commit is contained in:
phue 2021-02-17 18:23:11 +01:00
parent 180b1cf36b
commit 84a5da0d91
12 changed files with 93990 additions and 0 deletions

4
.github/filters.yml vendored
View file

@ -96,6 +96,10 @@ bwamem2_mem:
- software/bwamem2/mem/** - software/bwamem2/mem/**
- tests/software/bwamem2/mem/** - tests/software/bwamem2/mem/**
bwameth_align:
- software/bwameth/align/**
- tests/software/bwameth/align/**
bwameth_index: bwameth_index:
- software/bwameth/index/** - software/bwameth/index/**
- tests/software/bwameth/index/** - tests/software/bwameth/index/**

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,45 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BWAMETH_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::bwameth=0.2.2" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/bwameth:0.20--py35_0"
} else {
container "quay.io/biocontainers/bwameth:0.20--py35_0"
}
input:
tuple val(meta), path(reads)
path index
output:
tuple val(meta), path("*.bam"), emit: bam
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def read_group = meta.read_group ? "-R ${meta.read_group}" : ""
def c2t = index.first().toString() - '.bwameth' - '.c2t' - '.amb' - '.ann' - '.bwt' - '.pac' - '.sa'
"""
bwameth.py \\
$options.args \\
$read_group \\
-t $task.cpus \\
--reference $c2t \\
$reads \\
| samtools view $options.args2 -@ $task.cpus -bhS -o ${prefix}.bam -
echo \$(bwameth.py --version 2>&1) | cut -f2 -d" " > ${software}.version.txt
"""
}

View file

@ -0,0 +1,76 @@
name: bwameth_align
description: Performs alignment of BS-Seq reads using bwameth
keywords:
- bwameth
- alignment
- 3-letter genome
- map
- methylation
- 5mC
- methylseq
- bisulphite
- fastq
- bam
tools:
- bwameth:
description: |
Fast and accurate alignment of BS-Seq reads
using bwa-mem and a 3-letter genome.
homepage: https://github.com/brentp/bwa-meth
documentation: https://github.com/brentp/bwa-meth
arxiv: arXiv:1401.1129
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- publish_dir_mode:
type: string
description: |
Value for the Nextflow `publishDir` mode parameter.
Available: symlink, rellink, link, copy, copyNoFollow, move.
- enable_conda:
type: boolean
description: |
Run the module with Conda using the software specified
via the `conda` directive
- singularity_pull_docker_container:
type: boolean
description: |
Instead of directly downloading Singularity images for use with Singularity,
force the workflow to pull and convert Docker containers instead.
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: file
description: BWA genome index files
pattern: "*.{amb,ann,bwt,pac,sa}"
- 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 ]
- bam:
type: file
description: Output BAM file containing read alignments
pattern: "*.{bam}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@phue"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,5 @@
9372274 2 4
20895 1 Y
142347 1 R
4707032 1 Y
4828484 1 R

View file

@ -0,0 +1,5 @@
9372274 2 11
0 rgi|170079663|ref|NC_010473.1| Escherichia coli str. K-12 substr. DH10B, complete genome
0 4686137 2
0 fgi|170079663|ref|NC_010473.1| Escherichia coli str. K-12 substr. DH10B, complete genome
4686137 4686137 2

View file

@ -0,0 +1,53 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BWAMETH_ALIGN as BWAMETH_ALIGN_SE } from '../../../../software/bwameth/align/main.nf' addParams( options: [ publish_dir:'test_single_end' ] )
include { BWAMETH_ALIGN as BWAMETH_ALIGN_PE } from '../../../../software/bwameth/align/main.nf' addParams( options: [ publish_dir:'test_paired_end' ] )
/*
* Test with single-end data
*/
workflow test_bwameth_align_single_end {
def input = []
def index = []
input = [ [ id:'test', single_end:true ], // meta map
[ file("${launchDir}/tests/data/fastq/methylated_dna/Ecoli_10K_methylated_R1.fastq.gz", checkIfExists: true) ] ]
index = [ file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.amb", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.ann", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.bwt", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.sa", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.pac", checkIfExists: true) ]
BWAMETH_ALIGN_SE (
input,
index
)
}
/*
* Test with paired-end data
*/
workflow test_bwameth_align_paired_end {
def input = []
def index = []
input = [ [ id:'test', single_end:false ], // meta map
[ file("${launchDir}/tests/data/fastq/methylated_dna/Ecoli_10K_methylated_R1.fastq.gz", checkIfExists: true),
file("${launchDir}/tests/data/fastq/methylated_dna/Ecoli_10K_methylated_R2.fastq.gz", checkIfExists: true) ] ]
index = [ file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.amb", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.ann", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.bwt", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.sa", checkIfExists: true),
file("${launchDir}/tests/data/index/E_coli/bwameth/NC_010473.fa.bwameth.c2t.pac", checkIfExists: true) ]
BWAMETH_ALIGN_PE (
input,
index
)
}

View file

@ -0,0 +1,17 @@
- name: Run bwameth single-end test workflow
command: nextflow run ./tests/software/bwameth/align -entry test_bwameth_align_single_end -c tests/config/nextflow.config
tags:
- bwameth
- bwameth_align
files:
- path: output/test_single_end/test.bam
md5sum: 1873323773a8508494e7edc3e2035113
- name: Run bwameth paired-end test workflow
command: nextflow run ./tests/software/bwameth/align -entry test_bwameth_align_paired_end -c tests/config/nextflow.config
tags:
- bwameth
- bwameth_align
files:
- path: output/test_paired_end/test.bam
md5sum: 1f32b10471468596359584ca9f476caf