🏋️‍♀️ new submodule mash/sketch🕺 (#426)

* new submodule mash/sketch

* fixed submodule naming

* OK, tag is diff to keyword

* OK  another round 🤣

* removed TODO comments

* updated as per review comments 🙆‍♂️

* updated functions.nf 😁

* Update software/mash/sketch/main.nf

* Update main.nf

Removed blank line at the 12th

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
Thanh Lee 2021-04-10 16:24:23 +01:00 committed by GitHub
parent dce27b8102
commit ec15bae344
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 183 additions and 4 deletions

View file

@ -0,0 +1,70 @@
/*
* -----------------------------------------------------
* 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"
}
}
}

View file

@ -0,0 +1,40 @@
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process MASH_SKETCH {
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::mash=2.3" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/mash:2.3--he348c14_1"
} else {
container "quay.io/biocontainers/mash:2.3--he348c14_1"
}
input:
tuple val(meta), path(reads)
output:
tuple val(meta), path("*.msh") , emit: mash
tuple val(meta), path("*.mash_stats") , emit: stats
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
mash \\
sketch \\
$options.args \\
-p $task.cpus \\
-o ${prefix} \\
-r $reads \\
2> ${prefix}.mash_stats
echo \$(mash --version 2>&1) > ${software}.version.txt
"""
}

View file

@ -0,0 +1,40 @@
name: mash_sketch
description: Creates vastly reduced representations of sequences using MinHash
keywords:
- mash/sketch
tools:
- mash:
description: Fast sequence distance estimator that uses MinHash
homepage: https://github.com/marbl/Mash
documentation: https://mash.readthedocs.io/en/latest/sketches.html
tool_dev_url: https://github.com/marbl/Mash
doi: "10.1186/s13059-016-0997-x"
licence: ['https://github.com/marbl/Mash/blob/master/LICENSE.txt']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- reads:
type: file
description: List of input paired-end FastQ files
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- version:
type: file
description: Sketch output
pattern: "*.{mash}"
- stats:
type: file
description: Sketch statistics
pattern: "*.{mash_stats}"
authors:
- "@thanhleviet"

View file

@ -301,6 +301,10 @@ kraken2/run:
- software/kraken2/run/**
- tests/software/kraken2/run/**
mash/sketch:
- software/mash/sketch/**
- tests/software/mash/sketch/**
methyldackel/extract:
- software/methyldackel/extract/**
- tests/software/methyldackel/extract/**
@ -386,14 +390,14 @@ quast:
- software/quast/**
- tests/software/quast/**
rasusa:
- software/rasusa/**
- tests/software/rasusa/**
rapidnj:
- software/rapidnj/**
- tests/software/rapidnj/**
rasusa:
- software/rasusa/**
- tests/software/rasusa/**
salmon/index:
- software/salmon/index/**
- tests/software/salmon/index/**

View file

@ -0,0 +1,16 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { MASH_SKETCH } from '../../../../software/mash/sketch/main.nf' addParams( options: [:] )
workflow test_mash_sketch {
input = [ [ id:'test', single_end:false], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true)
]
]
MASH_SKETCH ( input )
}

View file

@ -0,0 +1,9 @@
- name: mash sketch
command: nextflow run ./tests/software/mash/sketch -entry test_mash_sketch -c tests/config/nextflow.config
tags:
- mash/sketch
files:
- path: output/mash/test.msh
md5sum: d747145a43dad5f82342036f8f5d9133
- path: output/mash/test.mash_stats
md5sum: 2a6f297d8e69a5e4160243bc6c89129c