add bwameth/index module + test

This commit is contained in:
phue 2021-02-17 18:03:48 +01:00
parent ed573db194
commit 180b1cf36b
6 changed files with 179 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_index:
- software/bwameth/index/**
- tests/software/bwameth/index/**
cat_fastq: cat_fastq:
- software/cat/fastq/** - software/cat/fastq/**
- tests/software/cat/fastq/** - tests/software/cat/fastq/**

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,35 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BWAMETH_INDEX {
tag "$fasta"
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:'') }
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:
path fasta
output:
path "*.bwameth.c2t*", emit: index
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
"""
bwameth.py index $fasta
echo \$(bwameth.py --version 2>&1) | cut -f2 -d" " > ${software}.version.txt
"""
}

View file

@ -0,0 +1,53 @@
name: bwameth_index
description: Performs indexing of c2t converted reference genome
keywords:
- bwameth
- 3-letter genome
- index
- methylseq
- bisulphite
- fasta
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:
- fasta:
type: file
description: Input genome fasta file
output:
- index:
type: file
description: c2t converted genome BWA index files
pattern: "*.{bwameth.c2t.amb,bwameth.c2t.ann,bwameth.c2t.bwt,bwameth.c2t.pac,bwameth.c2t.sa}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@phue"

View file

@ -0,0 +1,10 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BWAMETH_INDEX } from '../../../../software/bwameth/index/main.nf' addParams( options: [:] )
workflow test_bwameth_index {
BWAMETH_INDEX ( file("${launchDir}/tests/data/fasta/E_coli/NC_010473.fa", checkIfExists: true) )
}

View file

@ -0,0 +1,18 @@
- name: Run bwameth index test workflow
command: nextflow run ./tests/software/bwameth/index -entry test_bwameth_index -c tests/config/nextflow.config
tags:
- bwameth
- bwameth_index
files:
- path: ./output/bwameth/NC_010473.fa.bwameth.c2t.pac
md5sum: 7586c6a3be45c4dea15376a5c7bb9bf0
- path: ./output/bwameth/NC_010473.fa.bwameth.c2t.amb
md5sum: 87e019665cbb66bdee2bacccb26845c9
- path: ./output/bwameth/NC_010473.fa.bwameth.c2t.ann
md5sum: a4659a63572b6998c67457bd8e95790d
- path: ./output/bwameth/NC_010473.fa.bwameth.c2t.bwt
md5sum: 582854008bcbe99d5b51290773a7db5f
- path: ./output/bwameth/NC_010473.fa.bwameth.c2t
md5sum: db670853725f4a31080c991e9df6b330
- path: ./output/bwameth/NC_010473.fa.bwameth.c2t.sa
md5sum: 020db07e7e1544dc961c30c9936f3213