mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
add module for dragonflye (#633)
* add module for dragonflye * fix tests for dragonflye * Update test.yml * Update meta.yml * Update main.nf * Update main.nf * Update modules/dragonflye/meta.yml Co-authored-by: Gregor Sturm <mail@gregor-sturm.de>
This commit is contained in:
parent
67cc3bd116
commit
653e9e05b1
6 changed files with 221 additions and 0 deletions
68
modules/dragonflye/functions.nf
Normal file
68
modules/dragonflye/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"
|
||||
}
|
||||
}
|
||||
}
|
45
modules/dragonflye/main.nf
Normal file
45
modules/dragonflye/main.nf
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process DRAGONFLYE {
|
||||
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::dragonflye=1.0.4" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/dragonflye:1.0.4--hdfd78af_0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/dragonflye:1.0.4--hdfd78af_0"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(reads)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("contigs.fa") , emit: contigs
|
||||
tuple val(meta), path("dragonflye.log") , emit: log
|
||||
tuple val(meta), path("{flye,miniasm,raven}.fasta") , emit: raw_contigs
|
||||
tuple val(meta), path("{miniasm,raven}-unpolished.gfa"), optional:true , emit: gfa
|
||||
tuple val(meta), path("flye-info.txt"), optional:true , emit: txt
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def memory = task.memory.toGiga()
|
||||
"""
|
||||
dragonflye \\
|
||||
--reads ${reads} \\
|
||||
$options.args \\
|
||||
--cpus $task.cpus \\
|
||||
--ram $memory \\
|
||||
--outdir ./ \\
|
||||
--force
|
||||
echo \$(dragonflye --version 2>&1) | sed 's/^.*dragonflye //' > ${software}.version.txt
|
||||
"""
|
||||
}
|
57
modules/dragonflye/meta.yml
Normal file
57
modules/dragonflye/meta.yml
Normal file
|
@ -0,0 +1,57 @@
|
|||
name: dragonflye
|
||||
description: Assemble bacterial isolate genomes from Nanopore reads
|
||||
keywords:
|
||||
- bacterial
|
||||
- assembly
|
||||
- nanopore
|
||||
|
||||
tools:
|
||||
- dragonflye:
|
||||
description: Microbial assembly pipeline for Nanopore reads
|
||||
homepage: https://github.com/rpetit3/dragonflye
|
||||
documentation: https://github.com/rpetit3/dragonflye/blob/main/README.md
|
||||
licence: ['GPL v2']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- reads:
|
||||
type: file
|
||||
description: Input Nanopore FASTQ file
|
||||
pattern: "*.fastq.gz"
|
||||
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}"
|
||||
- contigs:
|
||||
type: file
|
||||
description: The final assembly produced by Dragonflye
|
||||
pattern: "contigs.fa"
|
||||
- log:
|
||||
type: file
|
||||
description: Full log file for bug reporting
|
||||
pattern: "dragonflye.log"
|
||||
- raw_contigs:
|
||||
type: file
|
||||
description: Raw assembly produced by the assembler (Flye, Miniasm, or Raven)
|
||||
pattern: "{flye,miniasm,raven}.fasta"
|
||||
- txt:
|
||||
type: file
|
||||
description: Assembly information output by Flye
|
||||
pattern: "flye-info.txt"
|
||||
- gfa:
|
||||
type: file
|
||||
description: Assembly graph produced by Miniasm, or Raven
|
||||
pattern: "{miniasm,raven}-unpolished.gfa"
|
||||
|
||||
authors:
|
||||
- "@rpetit3"
|
|
@ -242,6 +242,10 @@ delly/call:
|
|||
- modules/delly/call/**
|
||||
- tests/modules/delly/call/**
|
||||
|
||||
dragonflye:
|
||||
- modules/dragonflye/**
|
||||
- tests/modules/dragonflye/**
|
||||
|
||||
dshbio/filterbed:
|
||||
- modules/dshbio/filterbed/**
|
||||
- tests/modules/dshbio/filterbed/**
|
||||
|
|
22
tests/modules/dragonflye/main.nf
Normal file
22
tests/modules/dragonflye/main.nf
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { DRAGONFLYE } from '../../../modules/dragonflye/main.nf' addParams( options: [args: '--assembler miniasm --gsize 5000000'] )
|
||||
include { DRAGONFLYE as DRAGONFLYE_RAVEN } from '../../../modules/dragonflye/main.nf' addParams( options: [args: '--assembler raven --gsize 5000000'] )
|
||||
|
||||
workflow test_dragonflye {
|
||||
input = [ [ id:'test', single_end:true ], // meta map
|
||||
[ file("https://github.com/nf-core/test-datasets/raw/bacass/nanopore/subset15000.fq.gz", checkIfExists: true) ]
|
||||
]
|
||||
|
||||
DRAGONFLYE ( input )
|
||||
}
|
||||
|
||||
workflow test_dragonflye_raven {
|
||||
input = [ [ id:'test', single_end:true ], // meta map
|
||||
[ file("https://github.com/nf-core/test-datasets/raw/bacass/nanopore/subset15000.fq.gz", checkIfExists: true) ]
|
||||
]
|
||||
|
||||
DRAGONFLYE_RAVEN ( input )
|
||||
}
|
25
tests/modules/dragonflye/test.yml
Normal file
25
tests/modules/dragonflye/test.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
- name: dragonflye with miniasm
|
||||
command: nextflow run ./tests/modules/dragonflye -entry test_dragonflye -c tests/config/nextflow.config
|
||||
tags:
|
||||
- dragonflye
|
||||
files:
|
||||
- path: output/dragonflye/miniasm.fasta
|
||||
md5sum: 6b8903ba09592df99f43ed05fda488f6
|
||||
- path: output/dragonflye/miniasm-unpolished.gfa
|
||||
md5sum: 40ab03a417eafab0cb4ac2c32bd006e1
|
||||
# MD5sum not reproducible (timestamp, contig order)
|
||||
- path: output/dragonflye/contigs.fa
|
||||
- path: output/dragonflye/dragonflye.log
|
||||
|
||||
- name: dragonflye with raven
|
||||
command: nextflow run ./tests/modules/dragonflye -entry test_dragonflye_raven -c tests/config/nextflow.config
|
||||
tags:
|
||||
- dragonflye
|
||||
files:
|
||||
- path: output/dragonflye/raven.fasta
|
||||
md5sum: bd4ba5b0dda110a7ccbea9581c97a898
|
||||
- path: output/dragonflye/raven-unpolished.gfa
|
||||
md5sum: 62c21791dbf9b2c7375dc52d7bab5be2
|
||||
# MD5sum not reproducible (timestamp, contig order)
|
||||
- path: output/dragonflye/contigs.fa
|
||||
- path: output/dragonflye/dragonflye.log
|
Loading…
Reference in a new issue