mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-09-20 23:32:05 +00:00
Add module: dedup
(#907)
* Specify more guidelines on input channels * Linting * Updates based on code review * Update README.md * Fix broken sentence * feat: add megahit module, currently decompressed output * Update main.nf * Update tests/modules/megahit/test.yml Co-authored-by: Maxime Borry <maxibor@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * feat: compress all outputs, remove md5sums due to gz stochasicity * fix: wrong conda channel for pigz * fix: broken singleend tests and update meta.yml * Missed one * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * fix: pigz formatting * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Apply suggestions from code review * Add dedup (tests and version not working) * Fix dedup and tests Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> Co-authored-by: Maxime Borry <maxibor@users.noreply.github.com>
This commit is contained in:
parent
a0bc08732c
commit
e27553b989
6 changed files with 215 additions and 0 deletions
78
modules/dedup/functions.nf
Normal file
78
modules/dedup/functions.nf
Normal file
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// 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()
|
||||
}
|
||||
|
||||
//
|
||||
// Extract name of module from process name using $task.process
|
||||
//
|
||||
def getProcessName(task_process) {
|
||||
return task_process.tokenize(':')[-1]
|
||||
}
|
||||
|
||||
//
|
||||
// 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) {
|
||||
def ioptions = initOptions(args.options)
|
||||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||
|
||||
// Do not publish versions.yml unless running from pytest workflow
|
||||
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
|
||||
return null
|
||||
}
|
||||
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"
|
||||
}
|
||||
}
|
47
modules/dedup/main.nf
Normal file
47
modules/dedup/main.nf
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process DEDUP {
|
||||
tag "$meta.id"
|
||||
label 'process_low'
|
||||
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::dedup=0.12.8" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/dedup:0.12.8--hdfd78af_1"
|
||||
} else {
|
||||
container "quay.io/biocontainers/dedup:0.12.8--hdfd78af_1"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(bam)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*_rmdup.bam"), emit: bam // _rmdup is hardcoded output from dedup
|
||||
tuple val(meta), path("*.json") , emit: json
|
||||
tuple val(meta), path("*.hist") , emit: hist
|
||||
tuple val(meta), path("*log") , emit: log
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
script:
|
||||
prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
|
||||
"""
|
||||
dedup \\
|
||||
-Xmx${task.memory.toGiga()}g \\
|
||||
-i $bam \\
|
||||
-o . \\
|
||||
$options.args
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$( echo \$(dedup --version 2>&1) | tail -n 1 | sed 's/.* v//')
|
||||
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
60
modules/dedup/meta.yml
Normal file
60
modules/dedup/meta.yml
Normal file
|
@ -0,0 +1,60 @@
|
|||
name: dedup
|
||||
description: DeDup is a tool for read deduplication in paired-end read merging (e.g. for ancient DNA experiments).
|
||||
keywords:
|
||||
- dedup
|
||||
- deduplication
|
||||
- pcr duplicates
|
||||
- ancient DNA
|
||||
- paired-end
|
||||
- bam
|
||||
tools:
|
||||
- dedup:
|
||||
description: DeDup is a tool for read deduplication in paired-end read merging (e.g. for ancient DNA experiments).
|
||||
homepage: https://github.com/apeltzer/DeDup
|
||||
documentation: https://dedup.readthedocs.io/en/latest/
|
||||
tool_dev_url: https://github.com/apeltzer/DeDup
|
||||
doi: "10.1186/s13059-016-0918-z"
|
||||
licence: ['GPL v3']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- bam:
|
||||
type: file
|
||||
description: BAM/SAM file
|
||||
pattern: "*.{bam,sam}"
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- versions:
|
||||
type: file
|
||||
description: File containing software versions
|
||||
pattern: "versions.yml"
|
||||
- bam:
|
||||
type: file
|
||||
description: Deduplicated BAM file
|
||||
pattern: "*_rmdup.bam"
|
||||
- json:
|
||||
type: file
|
||||
description: JSON file for MultiQC
|
||||
pattern: "*.json"
|
||||
- hist:
|
||||
type: file
|
||||
description: Histogram data of amount of deduplication
|
||||
pattern: "*.hist"
|
||||
- log:
|
||||
type: file
|
||||
description: Dedup log information
|
||||
pattern: "*log"
|
||||
|
||||
|
||||
|
||||
authors:
|
||||
- "@jfy133"
|
|
@ -294,6 +294,10 @@ damageprofiler:
|
|||
- modules/damageprofiler/**
|
||||
- tests/modules/damageprofiler/**
|
||||
|
||||
dedup:
|
||||
- modules/dedup/**
|
||||
- tests/modules/dedup/**
|
||||
|
||||
deeptools/computematrix:
|
||||
- modules/deeptools/computematrix/**
|
||||
- tests/modules/deeptools/computematrix/**
|
||||
|
|
13
tests/modules/dedup/main.nf
Normal file
13
tests/modules/dedup/main.nf
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { DEDUP } from '../../../modules/dedup/main.nf' addParams( options: [args: "-m"] )
|
||||
|
||||
workflow test_dedup {
|
||||
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) ]
|
||||
|
||||
DEDUP ( input )
|
||||
}
|
13
tests/modules/dedup/test.yml
Normal file
13
tests/modules/dedup/test.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
- name: dedup test_dedup
|
||||
command: nextflow run tests/modules/dedup -entry test_dedup -c tests/config/nextflow.config
|
||||
tags:
|
||||
- dedup
|
||||
files:
|
||||
- path: output/dedup/test.paired_end.dedup.json
|
||||
md5sum: 2def0b54aba1fafa21b274f260de1b6f
|
||||
- path: output/dedup/test.paired_end.hist
|
||||
md5sum: df3492273a1db0d8152e35d9d5e38aa6
|
||||
- path: output/dedup/test.paired_end.log
|
||||
md5sum: 4b8855bd63b2f4b37da4cfb17e61fb00
|
||||
- path: output/dedup/test.paired_end_rmdup.bam
|
||||
md5sum: 8b0408fe3e258989095303a47e5b5061
|
Loading…
Reference in a new issue