mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 19:18:17 +00:00
add minimap2 index module (#467)
This commit is contained in:
parent
bbf8626b28
commit
05b067e907
6 changed files with 154 additions and 0 deletions
70
software/minimap2/index/functions.nf
Normal file
70
software/minimap2/index/functions.nf
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
software/minimap2/index/main.nf
Normal file
32
software/minimap2/index/main.nf
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
def options = initOptions(params.options)
|
||||||
|
|
||||||
|
process MINIMAP2_INDEX {
|
||||||
|
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:['']) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::minimap2=2.17" : null)
|
||||||
|
container "quay.io/biocontainers/minimap2:2.17--hed695b0_3"
|
||||||
|
|
||||||
|
input:
|
||||||
|
path(fasta)
|
||||||
|
|
||||||
|
output:
|
||||||
|
path("*.mmi") , emit: index
|
||||||
|
path "*.version.txt" ,emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
"""
|
||||||
|
minimap2 \\
|
||||||
|
-t $task.cpus \\
|
||||||
|
-d ${fasta}.mmi \\
|
||||||
|
$fasta
|
||||||
|
ps
|
||||||
|
minimap2 --version &> minimap2.version.txt
|
||||||
|
"""
|
||||||
|
}
|
28
software/minimap2/index/meta.yml
Normal file
28
software/minimap2/index/meta.yml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
name: minimap2_index
|
||||||
|
description: Provides fasta index required by minimap2 alignment.
|
||||||
|
keywords:
|
||||||
|
- index
|
||||||
|
- fasta
|
||||||
|
- reference
|
||||||
|
tools:
|
||||||
|
- minimap2:
|
||||||
|
description: |
|
||||||
|
A versatile pairwise aligner for genomic and spliced nucleotide sequences.
|
||||||
|
homepage: https://github.com/lh3/minimap2
|
||||||
|
documentation: https://github.com/lh3/minimap2#uguide
|
||||||
|
input:
|
||||||
|
- fasta:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Reference database in FASTA format.
|
||||||
|
output:
|
||||||
|
- mmi:
|
||||||
|
type: file
|
||||||
|
description: Minimap2 fasta index.
|
||||||
|
pattern: "*.mmi"
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
authors:
|
||||||
|
- "@yuukiiwa"
|
|
@ -358,6 +358,10 @@ minimap2/align:
|
||||||
- software/minimap2/align/**
|
- software/minimap2/align/**
|
||||||
- tests/software/minimap2/align/**
|
- tests/software/minimap2/align/**
|
||||||
|
|
||||||
|
minimap2/index:
|
||||||
|
- software/minimap2/index/**
|
||||||
|
- tests/software/minimap2/index/**
|
||||||
|
|
||||||
mosdepth:
|
mosdepth:
|
||||||
- software/mosdepth/**
|
- software/mosdepth/**
|
||||||
- tests/software/mosdepth/**
|
- tests/software/mosdepth/**
|
||||||
|
|
12
tests/software/minimap2/index/main.nf
Normal file
12
tests/software/minimap2/index/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { MINIMAP2_INDEX } from '../../../../software/minimap2/index/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_minimap2_index {
|
||||||
|
|
||||||
|
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
|
||||||
|
|
||||||
|
MINIMAP2_INDEX ( fasta )
|
||||||
|
}
|
8
tests/software/minimap2/index/test.yml
Normal file
8
tests/software/minimap2/index/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
- name: minimap2 index
|
||||||
|
command: nextflow run ./tests/software/minimap2/index -entry test_minimap2_index -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- minimap2
|
||||||
|
- minimap2/index
|
||||||
|
files:
|
||||||
|
- path: ./output/minimap2/genome.fasta.mmi
|
||||||
|
md5sum: 72e450f12dc691e763c697463bdb1571
|
Loading…
Reference in a new issue