mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-23 03:28:17 +00:00
add flash module (#341)
* add flash module * remove todo * run tests Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
6d14819859
commit
67b3e00f58
6 changed files with 174 additions and 0 deletions
60
software/flash/functions.nf
Normal file
60
software/flash/functions.nf
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* -----------------------------------------------------
|
||||||
|
* 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_id = args.publish_by_id ?: false
|
||||||
|
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_id) {
|
||||||
|
path_list.add(args.publish_id)
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
40
software/flash/main.nf
Normal file
40
software/flash/main.nf
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process FLASH {
|
||||||
|
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), publish_id:meta.id) }
|
||||||
|
conda (params.enable_conda ? "bioconda::flash=1.2.11" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/flash:1.2.11--hed695b0_5"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/flash:1.2.11--hed695b0_5"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(reads)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*.merged.*.fastq.gz"), emit: reads
|
||||||
|
path "*.version.txt" , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
def merged = "-o ${prefix}.merged"
|
||||||
|
def input_reads = "${reads[0]} ${reads[1]}"
|
||||||
|
"""
|
||||||
|
flash \\
|
||||||
|
$options.args \\
|
||||||
|
$merged \\
|
||||||
|
-z \\
|
||||||
|
$input_reads
|
||||||
|
echo \$(flash --version) > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
44
software/flash/meta.yml
Normal file
44
software/flash/meta.yml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
name: flash
|
||||||
|
description: Perform merging of mate paired-end sequencing reads
|
||||||
|
keywords:
|
||||||
|
- sort
|
||||||
|
- reads merging
|
||||||
|
- merge mate pairs
|
||||||
|
tools:
|
||||||
|
- flash:
|
||||||
|
description: |
|
||||||
|
Merge mates from fragments that are shorter than twice the read length
|
||||||
|
homepage: https://ccb.jhu.edu/software/FLASH/
|
||||||
|
documentation: {}
|
||||||
|
doi: 10.1093/bioinformatics/btr507
|
||||||
|
licence: ['GPL v3+']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- reads:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
List of input FastQ files of size 2; i.e., paired-end data.
|
||||||
|
pattern: "*fastq.gz"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- reads:
|
||||||
|
type: file
|
||||||
|
description: The merged fastq reads
|
||||||
|
pattern: "*fastq.gz"
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@Erkison"
|
|
@ -178,6 +178,10 @@ fastqc:
|
||||||
- software/fastqc/**
|
- software/fastqc/**
|
||||||
- tests/software/fastqc/**
|
- tests/software/fastqc/**
|
||||||
|
|
||||||
|
flash:
|
||||||
|
- software/flash/**
|
||||||
|
- tests/software/flash/**
|
||||||
|
|
||||||
gatk4_applybqsr:
|
gatk4_applybqsr:
|
||||||
- software/gatk4/applybqsr/**
|
- software/gatk4/applybqsr/**
|
||||||
- tests/software/gatk4/applybqsr/**
|
- tests/software/gatk4/applybqsr/**
|
||||||
|
|
15
tests/software/flash/main.nf
Normal file
15
tests/software/flash/main.nf
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { FLASH } from '../../../software/flash/main.nf' addParams( options: [args:'-m 20 -M 100'] )
|
||||||
|
|
||||||
|
workflow test_flash {
|
||||||
|
|
||||||
|
def input = []
|
||||||
|
input = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
[ file("${launchDir}/tests/data/genomics/sarscov2/fastq/test_1.fastq.gz", checkIfExists: true),
|
||||||
|
file("${launchDir}/tests/data/genomics/sarscov2/fastq/test_2.fastq.gz", checkIfExists: true) ] ]
|
||||||
|
|
||||||
|
FLASH ( input )
|
||||||
|
}
|
11
tests/software/flash/test.yml
Normal file
11
tests/software/flash/test.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
- name: flash test_flash
|
||||||
|
command: nextflow run tests/software/flash -entry test_flash -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- flash
|
||||||
|
files:
|
||||||
|
- path: output/flash/test.merged.notCombined_2.fastq.gz
|
||||||
|
md5sum: 96ec044281fe60e0061976d928810314
|
||||||
|
- path: output/flash/test.merged.extendedFrags.fastq.gz
|
||||||
|
md5sum: da20afa705e8ea881e66960bb75607c9
|
||||||
|
- path: output/flash/test.merged.notCombined_1.fastq.gz
|
||||||
|
md5sum: 32451c87f89172c764bec19136592d29
|
Loading…
Reference in a new issue