mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
Add module kleborate
(#711)
* initial commit [ci skip] * remove todo from the module files [ci skip] * add a sample test case [ci skip] * push the latest work [ci skip] * bump kleborate build * test passing with the new build for kleborate [ci skip] * ready for review * Apply suggestions from code review Co-authored-by: Robert A. Petit III <robbie.petit@gmail.com> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
8e9d6cd5e4
commit
77a2895785
6 changed files with 179 additions and 0 deletions
68
modules/kleborate/functions.nf
Normal file
68
modules/kleborate/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/kleborate/main.nf
Normal file
39
modules/kleborate/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 KLEBORATE {
|
||||
tag "$meta.id"
|
||||
label 'process_medium'
|
||||
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::kleborate=2.1.0" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/kleborate:2.1.0--pyhdfd78af_1"
|
||||
} else {
|
||||
container "quay.io/biocontainers/kleborate:2.1.0--pyhdfd78af_1"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(fastas)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.txt"), emit: txt
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
kleborate \\
|
||||
$options.args \\
|
||||
--outfile ${prefix}.results.txt \\
|
||||
--assemblies *.fasta
|
||||
|
||||
echo \$(kleborate -v 2>&1) | sed 's/kleborate //;' > ${software}.version.txt
|
||||
"""
|
||||
}
|
43
modules/kleborate/meta.yml
Normal file
43
modules/kleborate/meta.yml
Normal file
|
@ -0,0 +1,43 @@
|
|||
name: kleborate
|
||||
description: Kleborate is a tool to screen genome assemblies of Klebsiella pneumoniae and the Klebsiella pneumoniae species complex (KpSC).
|
||||
keywords:
|
||||
- screening assemblies
|
||||
- Klebsiella pneumoniae
|
||||
tools:
|
||||
- kleborate:
|
||||
description: Screening Klebsiella genome assemblies for MLST, sub-species, and other Klebsiella related genes of interest
|
||||
homepage: https://github.com/katholt/Kleborate
|
||||
documentation: https://github.com/katholt/Kleborate/wiki
|
||||
tool_dev_url: https://github.com/katholt/Kleborate
|
||||
doi: 10.1038/s41467-021-24448-3
|
||||
licence: ['GPL v3 or later (GPL v3+)']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- fastas:
|
||||
type: files
|
||||
description: Klebsiella genome assemblies to be screened
|
||||
pattern: "*.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}"
|
||||
- txt:
|
||||
type: file
|
||||
description: Result file generated after screening
|
||||
pattern: "*.txt"
|
||||
|
||||
authors:
|
||||
- "@abhi18av"
|
||||
- "@rpetit3"
|
|
@ -505,6 +505,10 @@ kallistobustools/ref:
|
|||
- modules/kallistobustools/ref/**
|
||||
- tests/modules/kallistobustools/ref/**
|
||||
|
||||
kleborate:
|
||||
- modules/kleborate/**
|
||||
- tests/modules/kleborate/**
|
||||
|
||||
kraken2/kraken2:
|
||||
- modules/kraken2/kraken2/**
|
||||
- modules/untar/**
|
||||
|
|
18
tests/modules/kleborate/main.nf
Normal file
18
tests/modules/kleborate/main.nf
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { KLEBORATE } from '../../../modules/kleborate/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_kleborate {
|
||||
|
||||
input = [
|
||||
[ id:'test', single_end:false ], // meta map
|
||||
[ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['illumina']['scaffolds_fasta'], checkIfExists: true)
|
||||
]
|
||||
]
|
||||
|
||||
KLEBORATE ( input )
|
||||
}
|
7
tests/modules/kleborate/test.yml
Normal file
7
tests/modules/kleborate/test.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- name: kleborate
|
||||
command: nextflow run ./tests/modules/kleborate -entry test_kleborate -c tests/config/nextflow.config
|
||||
tags:
|
||||
- kleborate
|
||||
files:
|
||||
- path: output/kleborate/test.results.txt
|
||||
md5sum: b7979a71170736098fb8403cd92748f5
|
Loading…
Reference in a new issue