mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
parent
d95be1434f
commit
0f59b07945
6 changed files with 180 additions and 1 deletions
68
modules/bbmap/index/functions.nf
Normal file
68
modules/bbmap/index/functions.nf
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
//
|
||||||
|
// 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.args3 = args.args3 ?: ''
|
||||||
|
options.publish_by_meta = args.publish_by_meta ?: []
|
||||||
|
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_meta) {
|
||||||
|
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
|
||||||
|
for (key in key_list) {
|
||||||
|
if (args.meta && key instanceof String) {
|
||||||
|
def path = key
|
||||||
|
if (args.meta.containsKey(key)) {
|
||||||
|
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
|
||||||
|
}
|
||||||
|
path = path instanceof String ? path : ''
|
||||||
|
path_list.add(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
modules/bbmap/index/main.nf
Normal file
39
modules/bbmap/index/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 BBMAP_INDEX {
|
||||||
|
tag "$fasta"
|
||||||
|
label 'process_long'
|
||||||
|
publishDir "${params.outdir}",
|
||||||
|
mode: params.publish_dir_mode,
|
||||||
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::bbmap=38.92" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/bbmap:38.92--he522d1c_0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/bbmap:38.92--he522d1c_0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(fasta)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path('ref') , emit: index
|
||||||
|
path "*.version.txt" , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
"""
|
||||||
|
bbmap.sh \\
|
||||||
|
ref=${fasta} \\
|
||||||
|
$options.args \\
|
||||||
|
threads=$task.cpus \\
|
||||||
|
-Xmx${task.memory.toGiga()}g
|
||||||
|
|
||||||
|
echo \$(bbversion.sh) > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
43
modules/bbmap/index/meta.yml
Normal file
43
modules/bbmap/index/meta.yml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: bbmap_index
|
||||||
|
description: This module calls bbmap.sh to create an index from a fasta file, ready to be used by bbmap.sh in mapping mode.
|
||||||
|
keywords:
|
||||||
|
- mapping
|
||||||
|
- index
|
||||||
|
- fasta
|
||||||
|
tools:
|
||||||
|
- bbmap:
|
||||||
|
description: BBMap is a short read aligner, as well as various other bioinformatic tools.
|
||||||
|
homepage: https://jgi.doe.gov/data-and-tools/bbtools/bb-tools-user-guide/
|
||||||
|
documentation: https://jgi.doe.gov/data-and-tools/bbtools/bb-tools-user-guide/
|
||||||
|
tool_dev_url: None
|
||||||
|
doi: ""
|
||||||
|
licence: ['UC-LBL license (see package)']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing optional parameters to bbmap.sh
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- fasta:
|
||||||
|
type: fasta
|
||||||
|
description: fasta formatted file with nucleotide sequences
|
||||||
|
pattern: "*.{fna,fa,fasta}"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
- db:
|
||||||
|
type: directory
|
||||||
|
description: Directory with index files
|
||||||
|
pattern: "ref"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@daniellundin"
|
|
@ -30,6 +30,10 @@ bbmap/bbduk:
|
||||||
- modules/bbmap/bbduk/**
|
- modules/bbmap/bbduk/**
|
||||||
- tests/modules/bbmap/bbduk/**
|
- tests/modules/bbmap/bbduk/**
|
||||||
|
|
||||||
|
bbmap/index:
|
||||||
|
- modules/bbmap/index/**
|
||||||
|
- tests/modules/bbmap/index/**
|
||||||
|
|
||||||
bcftools/concat:
|
bcftools/concat:
|
||||||
- modules/bcftools/concat/**
|
- modules/bcftools/concat/**
|
||||||
- tests/modules/bcftools/concat/**
|
- tests/modules/bcftools/concat/**
|
||||||
|
|
13
tests/modules/bbmap/index/main.nf
Normal file
13
tests/modules/bbmap/index/main.nf
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { BBMAP_INDEX } from '../../../../modules/bbmap/index/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_bbmap_index {
|
||||||
|
|
||||||
|
input = [ [ id:'test' ], // meta map
|
||||||
|
file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) ]
|
||||||
|
|
||||||
|
BBMAP_INDEX ( input )
|
||||||
|
}
|
12
tests/modules/bbmap/index/test.yml
Normal file
12
tests/modules/bbmap/index/test.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
## TODO nf-core: Please run the following command to build this file:
|
||||||
|
# nf-core modules create-test-yml bbmap/index
|
||||||
|
- name: bbmap index
|
||||||
|
command: nextflow run ./tests/modules/bbmap/index -entry test_bbmap_index -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- bbmap
|
||||||
|
- bbmap/index
|
||||||
|
files:
|
||||||
|
- path: output/bbmap/ref/genome/1/chr1.chrom.gz
|
||||||
|
md5sum: fc20702f3378836f06d4104b9cd88918
|
||||||
|
- path: output/bbmap/ref/index/1/chr1_index_k13_c15_b1.block
|
||||||
|
md5sum: 9f0d9a7413c1d2c16cc24555b2381163
|
Loading…
Reference in a new issue