mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
module: MALT/RUN (#646)
* Specify more guidelines on input channels * Linting * Updates based on code review * Update README.md * Fix broken sentence * Add MALT with incomplete tests * Parameter typo fix * Clean up test yaml * Finish MALT module prior UNZIP and MALT_BUILD modiules * Add required modules for tests * Sync test out with malt-build * Fix input parameters in tests based on final build module * Update modules/malt/run/meta.yml Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> Co-authored-by: Gregor Sturm <mail@gregor-sturm.de>
This commit is contained in:
parent
6913da9d2d
commit
292e8eceb9
6 changed files with 211 additions and 0 deletions
68
modules/malt/run/functions.nf
Normal file
68
modules/malt/run/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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
modules/malt/run/main.nf
Normal file
54
modules/malt/run/main.nf
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process MALT_RUN {
|
||||||
|
|
||||||
|
label 'process_high_memory'
|
||||||
|
publishDir "${params.outdir}",
|
||||||
|
mode: params.publish_dir_mode,
|
||||||
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:[:], publish_by_meta:[]) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::malt=0.5.2" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/malt:0.5.2--0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/malt:0.5.2--0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
path fastqs
|
||||||
|
val mode
|
||||||
|
path index
|
||||||
|
|
||||||
|
output:
|
||||||
|
path "*.rma6" , emit: rma6
|
||||||
|
path "*.{tab,text,sam}", optional:true, emit: alignments
|
||||||
|
path "*.log" , emit: log
|
||||||
|
path "*.version.txt" , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def avail_mem = 6
|
||||||
|
if (!task.memory) {
|
||||||
|
log.info '[MALT_RUN] Available memory not known - defaulting to 6GB. Specify process memory requirements to change this.'
|
||||||
|
} else {
|
||||||
|
avail_mem = task.memory.giga
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
malt-run \\
|
||||||
|
-J-Xmx${avail_mem}g \\
|
||||||
|
-t ${task.cpus} \\
|
||||||
|
-v \\
|
||||||
|
-o . \\
|
||||||
|
$options.args \\
|
||||||
|
--inFile ${fastqs.join(' ')} \\
|
||||||
|
-m $mode \\
|
||||||
|
--index $index/ |&tee malt-run.log
|
||||||
|
|
||||||
|
echo \$(malt-run --help 2>&1) | grep -o 'version.* ' | cut -f 1 -d ',' | cut -f2 -d ' ' > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
53
modules/malt/run/meta.yml
Normal file
53
modules/malt/run/meta.yml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
name: malt_run
|
||||||
|
description: MALT, an acronym for MEGAN alignment tool, is a sequence alignment and analysis tool designed for processing high-throughput sequencing data, especially in the context of metagenomics.
|
||||||
|
keywords:
|
||||||
|
- malt
|
||||||
|
- alignment
|
||||||
|
- metagenomics
|
||||||
|
- ancient DNA
|
||||||
|
- aDNA
|
||||||
|
- palaeogenomics
|
||||||
|
- archaeogenomics
|
||||||
|
- microbiome
|
||||||
|
tools:
|
||||||
|
- malt:
|
||||||
|
description: A tool for mapping metagenomic data
|
||||||
|
homepage: https://www.wsi.uni-tuebingen.de/lehrstuehle/algorithms-in-bioinformatics/software/malt/
|
||||||
|
documentation: https://software-ab.informatik.uni-tuebingen.de/download/malt/manual.pdf
|
||||||
|
tool_dev_url: None
|
||||||
|
doi: "10.1038/s41559-017-0446-6"
|
||||||
|
licence: ['GPL v3']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- fastqs:
|
||||||
|
type: file
|
||||||
|
description: Input FASTQ files
|
||||||
|
pattern: "*.{fastq.gz,fq.gz}"
|
||||||
|
- mode:
|
||||||
|
type: string
|
||||||
|
description: Program mode
|
||||||
|
pattern: 'Unknown|BlastN|BlastP|BlastX|Classifier'
|
||||||
|
- index:
|
||||||
|
type: directory
|
||||||
|
description: Index/database directory from malt-build
|
||||||
|
pattern: '*/'
|
||||||
|
output:
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
- rma6:
|
||||||
|
type: file
|
||||||
|
description: MEGAN6 RMA6 file
|
||||||
|
pattern: "*.rma6"
|
||||||
|
- sam:
|
||||||
|
type: file
|
||||||
|
description: Alignment files in Tab, Text or MEGAN-compatible SAM format
|
||||||
|
pattern: "*.{tab,txt,sam}"
|
||||||
|
- log:
|
||||||
|
type: file
|
||||||
|
description: Log of verbose MALT stdout
|
||||||
|
pattern: "malt-run.log"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@jfy133"
|
|
@ -478,6 +478,10 @@ malt/build:
|
||||||
- modules/malt/build/**
|
- modules/malt/build/**
|
||||||
- tests/modules/malt/build_test/**
|
- tests/modules/malt/build_test/**
|
||||||
|
|
||||||
|
malt/run:
|
||||||
|
- modules/malt/run/**
|
||||||
|
- tests/modules/malt/run/**
|
||||||
|
|
||||||
mash/sketch:
|
mash/sketch:
|
||||||
- modules/mash/sketch/**
|
- modules/mash/sketch/**
|
||||||
- tests/modules/mash/sketch/**
|
- tests/modules/mash/sketch/**
|
||||||
|
|
21
tests/modules/malt/run/main.nf
Normal file
21
tests/modules/malt/run/main.nf
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { UNZIP } from '../../../../modules/unzip/main.nf' addParams( options: [:] )
|
||||||
|
include { MALT_BUILD } from '../../../../modules/malt/build/main.nf' addParams( options: [:] )
|
||||||
|
include { MALT_RUN } from '../../../../modules/malt/run/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_malt_run {
|
||||||
|
|
||||||
|
fastas = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
|
||||||
|
gff = file(params.test_data['sarscov2']['genome']['genome_gff3'], checkIfExists: true)
|
||||||
|
seq_type = "DNA"
|
||||||
|
map_db = file("https://software-ab.informatik.uni-tuebingen.de/download/megan6/megan-nucl-Jan2021.db.zip", checkIfExists: true)
|
||||||
|
input = file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)
|
||||||
|
mode = "BlastN"
|
||||||
|
|
||||||
|
UNZIP ( map_db )
|
||||||
|
MALT_BUILD ( fastas, seq_type, gff, UNZIP.out.unzipped_archive )
|
||||||
|
MALT_RUN ( input, mode, MALT_BUILD.out.index )
|
||||||
|
}
|
11
tests/modules/malt/run/test.yml
Normal file
11
tests/modules/malt/run/test.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
## TODO nf-core: Please run the following command to build this file:
|
||||||
|
# nf-core modules create-test-yml malt/run
|
||||||
|
- name: malt run
|
||||||
|
command: nextflow run ./tests/modules/malt/run -entry test_malt_run -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- malt
|
||||||
|
- malt/run
|
||||||
|
files:
|
||||||
|
- path: output/malt/test_1.rma6
|
||||||
|
- path: output/malt/malt-run.log
|
||||||
|
|
Loading…
Reference in a new issue