mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
Merge pull request #166 from MaxUlysse/master_bwa-mem2
chores: add bwa-mem2 index + mem
This commit is contained in:
commit
b28604efca
16 changed files with 408 additions and 0 deletions
8
.github/filters.yml
vendored
8
.github/filters.yml
vendored
|
@ -96,6 +96,14 @@ bwa_mem:
|
|||
- software/bwa/mem/**
|
||||
- tests/software/bwa/mem/**
|
||||
|
||||
bwamem2_index:
|
||||
- software/bwamem2/index/**
|
||||
- tests/software/bwamem2/index/**
|
||||
|
||||
bwamem2_mem:
|
||||
- software/bwamem2/mem/**
|
||||
- tests/software/bwamem2/mem/**
|
||||
|
||||
cat_fastq:
|
||||
- software/cat/fastq/**
|
||||
- tests/software/cat/fastq/**
|
||||
|
|
59
software/bwamem2/index/functions.nf
Normal file
59
software/bwamem2/index/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"
|
||||
}
|
||||
}
|
||||
}
|
35
software/bwamem2/index/main.nf
Normal file
35
software/bwamem2/index/main.nf
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
def options = initOptions(params.options)
|
||||
|
||||
process BWAMEM2_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::bwa-mem2=2.1=he513fc3_0" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/bwa-mem2:2.1--he513fc3_0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/bwa-mem2:2.1--he513fc3_0"
|
||||
}
|
||||
|
||||
input:
|
||||
path fasta
|
||||
|
||||
output:
|
||||
path "bwamem2" , emit: index
|
||||
path "*.version.txt", emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
"""
|
||||
mkdir bwamem2
|
||||
bwa-mem2 index $options.args $fasta -p bwamem2/${fasta}
|
||||
echo \$(bwa-mem2 version 2>&1) > ${software}.version.txt
|
||||
"""
|
||||
}
|
50
software/bwamem2/index/meta.yml
Normal file
50
software/bwamem2/index/meta.yml
Normal file
|
@ -0,0 +1,50 @@
|
|||
name: bwamem2_index
|
||||
description: Create BWA-mem2 index for reference genome
|
||||
keywords:
|
||||
- index
|
||||
- fasta
|
||||
- genome
|
||||
- reference
|
||||
tools:
|
||||
- bwa:
|
||||
description: |
|
||||
BWA-mem2 is a software package for mapping DNA sequences against
|
||||
a large reference genome, such as the human genome.
|
||||
homepage: https://github.com/bwa-mem2/bwa-mem2
|
||||
documentation: https://github.com/bwa-mem2/bwa-mem2#usage
|
||||
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: BWA genome index files
|
||||
pattern: "*.{0132,amb,ann,bwt.2bit.64,pac}"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
authors:
|
||||
- "@maxulysse"
|
59
software/bwamem2/mem/functions.nf
Normal file
59
software/bwamem2/mem/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"
|
||||
}
|
||||
}
|
||||
}
|
46
software/bwamem2/mem/main.nf
Normal file
46
software/bwamem2/mem/main.nf
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
def options = initOptions(params.options)
|
||||
|
||||
process BWAMEM2_MEM {
|
||||
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::bwa-mem2=2.1=he513fc3_0 bioconda::samtools=1.11=h6270b1f_0" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/mulled-v2-e5d375990341c5aef3c9aff74f96f66f65375ef6:e6f0d20c9d78572ddbbf00d8767ee6ff865edd4e-0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/mulled-v2-e5d375990341c5aef3c9aff74f96f66f65375ef6:e6f0d20c9d78572ddbbf00d8767ee6ff865edd4e-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}" : ""
|
||||
"""
|
||||
INDEX=`find -L ./ -name "*.amb" | sed 's/.amb//'`
|
||||
|
||||
bwa-mem2 mem \\
|
||||
$options.args \\
|
||||
$read_group \\
|
||||
-t $task.cpus \\
|
||||
\$INDEX \\
|
||||
$reads \\
|
||||
| samtools view $options.args2 -@ $task.cpus -bhS -o ${prefix}.bam -
|
||||
|
||||
echo \$(bwa-mem2 version 2>&1) > ${software}.version.txt
|
||||
"""
|
||||
}
|
65
software/bwamem2/mem/meta.yml
Normal file
65
software/bwamem2/mem/meta.yml
Normal file
|
@ -0,0 +1,65 @@
|
|||
name: bwamem2_mem
|
||||
description: Performs fastq alignment to a fasta reference using BWA
|
||||
keywords:
|
||||
- mem
|
||||
- bwa
|
||||
- alignment
|
||||
- map
|
||||
- fastq
|
||||
- bam
|
||||
- sam
|
||||
tools:
|
||||
- bwa:
|
||||
description: |
|
||||
BWA is a software package for mapping DNA sequences against
|
||||
a large reference genome, such as the human genome.
|
||||
homepage: http://bio-bwa.sourceforge.net/
|
||||
documentation: http://www.htslib.org/doc/samtools.html
|
||||
arxiv: arXiv:1303.3997
|
||||
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: "Directory containing BWA index *.{amb,ann,bwt,pac,sa}"
|
||||
output:
|
||||
- bam:
|
||||
type: file
|
||||
description: Output BAM file containing read alignments
|
||||
pattern: "*.{bam}"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
authors:
|
||||
- "@maxulysse"
|
BIN
tests/data/index/E_coli/bwamem2/NC_010473.fa.0123
Normal file
BIN
tests/data/index/E_coli/bwamem2/NC_010473.fa.0123
Normal file
Binary file not shown.
3
tests/data/index/E_coli/bwamem2/NC_010473.fa.amb
Normal file
3
tests/data/index/E_coli/bwamem2/NC_010473.fa.amb
Normal file
|
@ -0,0 +1,3 @@
|
|||
4686137 1 2
|
||||
20895 1 Y
|
||||
142347 1 R
|
3
tests/data/index/E_coli/bwamem2/NC_010473.fa.ann
Normal file
3
tests/data/index/E_coli/bwamem2/NC_010473.fa.ann
Normal file
|
@ -0,0 +1,3 @@
|
|||
4686137 1 11
|
||||
0 gi|170079663|ref|NC_010473.1| Escherichia coli str. K-12 substr. DH10B, complete genome
|
||||
0 4686137 2
|
BIN
tests/data/index/E_coli/bwamem2/NC_010473.fa.bwt.2bit.64
Normal file
BIN
tests/data/index/E_coli/bwamem2/NC_010473.fa.bwt.2bit.64
Normal file
Binary file not shown.
BIN
tests/data/index/E_coli/bwamem2/NC_010473.fa.pac
Normal file
BIN
tests/data/index/E_coli/bwamem2/NC_010473.fa.pac
Normal file
Binary file not shown.
9
tests/software/bwamem2/index/main.nf
Normal file
9
tests/software/bwamem2/index/main.nf
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { BWAMEM2_INDEX } from '../../../../software/bwamem2/index/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_bwamem2_index {
|
||||
BWAMEM2_INDEX ( file("${launchDir}/tests/data/fasta/E_coli/NC_010473.fa", checkIfExists: true) )
|
||||
}
|
16
tests/software/bwamem2/index/test.yml
Normal file
16
tests/software/bwamem2/index/test.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
- name: bwamem2 index
|
||||
command: nextflow run ./tests/software/bwamem2/index -entry test_bwamem2_index -c tests/config/nextflow.config
|
||||
tags:
|
||||
- bwamem2
|
||||
- bwamem2_index
|
||||
files:
|
||||
- path: output/bwamem2/bwamem2/NC_010473.fa.0123
|
||||
md5sum: e112e4d2fd893fb939d306b27ece9de5
|
||||
- path: output/bwamem2/bwamem2/NC_010473.fa.amb
|
||||
md5sum: 942a990ae872f1c0b8d72dda2db405d5
|
||||
- path: output/bwamem2/bwamem2/NC_010473.fa.ann
|
||||
md5sum: ebf1a0279cf5b8d7f1a8cb855a3a3705
|
||||
- path: output/bwamem2/bwamem2/NC_010473.fa.bwt.2bit.64
|
||||
md5sum: f0154573be12440aee294b726cd88c86
|
||||
- path: output/bwamem2/bwamem2/NC_010473.fa.pac
|
||||
md5sum: 4d5e6fc45bbc968f7f859e9ca2cc89ad
|
36
tests/software/bwamem2/mem/main.nf
Normal file
36
tests/software/bwamem2/mem/main.nf
Normal file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { BWAMEM2_MEM } from '../../../../software/bwamem2/mem/main.nf' addParams( options: [:] )
|
||||
|
||||
/*
|
||||
* Test with single-end data
|
||||
*/
|
||||
workflow test_bwamem2_mem_single_end {
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:true ], // meta map
|
||||
[ file("${launchDir}/tests/data/fastq/dna/Ecoli_DNA_R1.fastq.gz", checkIfExists: true) ] ]
|
||||
|
||||
BWAMEM2_MEM (
|
||||
input,
|
||||
file("${launchDir}/tests/data/index/E_coli/bwamem2/", checkIfExists: true)
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
* Test with paired-end data
|
||||
*/
|
||||
workflow test_bwamem2_mem_paired_end {
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
[ file("${launchDir}/tests/data/fastq/dna/Ecoli_DNA_R1.fastq.gz", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/fastq/dna/Ecoli_DNA_R2.fastq.gz", checkIfExists: true) ] ]
|
||||
|
||||
BWAMEM2_MEM (
|
||||
input,
|
||||
file("${launchDir}/tests/data/index/E_coli/bwamem2/", checkIfExists: true)
|
||||
)
|
||||
}
|
19
tests/software/bwamem2/mem/test.yml
Normal file
19
tests/software/bwamem2/mem/test.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
- name: bwamem2 mem single-end
|
||||
command: nextflow run ./tests/software/bwamem2/mem -entry test_bwamem2_mem_single_end -c tests/config/nextflow.config
|
||||
tags:
|
||||
- bwamem2
|
||||
- bwamem2_mem
|
||||
- bwamem2_mem_single_end
|
||||
files:
|
||||
- path: output/bwamem2/test.bam
|
||||
md5sum: 354acd3b7033a2d4ee69452df18c0a4d
|
||||
|
||||
- name: bwamem2 mem paired-end
|
||||
command: nextflow run ./tests/software/bwamem2/mem -entry test_bwamem2_mem_paired_end -c tests/config/nextflow.config
|
||||
tags:
|
||||
- bwamem2
|
||||
- bwamem2_mem
|
||||
- bwamem2_mem_paired_end
|
||||
files:
|
||||
- path: output/bwamem2/test.bam
|
||||
md5sum: 26187528a7bde13a2a9e9dd549b9bcd0
|
Loading…
Reference in a new issue