mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
New module: pbbam/pbmerge
(#752)
* 👌 IMPROVE: Add some pacbio test files * 📦 NEW: Add pbbam/pbmerge module * 🐛 FIX: Add optional arguments to command line * 👌 IMPROVE: Update to last templates version * 👌 IMPROVE: Update module to last template version * 👌 IMPROVE: Update test data config and test script * 👌 IMPROVE: Remove useless index + Fix Typos * 👌 IMPROVE: Add some pacbio test files * 📦 NEW: Add pbbam/pbmerge module * 🐛 FIX: Add optional arguments to command line * 👌 IMPROVE: Update to last templates version * 👌 IMPROVE: Update module to last template version * 👌 IMPROVE: Update test data config and test script * 👌 IMPROVE: Remove useless index + Fix Typos * 👌 IMPROVE: Update and clean code * 🐛 FIX: Update module path in test * 🐛 FIX: Add missing () + correct module path in test * 👌 IMPROVE: Update pbmerge from version 1.6.0 to 1.7.0 * 👌 IMPROVE: Change output filename suffix for something more generic * 🐛 Update test.yml * Apply suggestions from code review * Update tests/modules/pbbam/pbmerge/test.yml * Update tests/modules/pbbam/pbmerge/main.nf Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> Co-authored-by: Robert A. Petit III <robbie.petit@gmail.com> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
aa32a8a72e
commit
bcf2681b03
6 changed files with 198 additions and 0 deletions
78
modules/pbbam/pbmerge/functions.nf
Normal file
78
modules/pbbam/pbmerge/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"
|
||||
}
|
||||
}
|
42
modules/pbbam/pbmerge/main.nf
Normal file
42
modules/pbbam/pbmerge/main.nf
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process PBBAM_PBMERGE {
|
||||
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::pbbam=1.7.0" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/pbbam:1.7.0--h058f120_1"
|
||||
} else {
|
||||
container "quay.io/biocontainers/pbbam:1.7.0--h058f120_1"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(bam)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.bam"), emit: bam
|
||||
tuple val(meta), path("*.pbi"), emit: pbi
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
script:
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
pbmerge \\
|
||||
-o ${prefix}.bam \\
|
||||
$options.args \\
|
||||
*.bam
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
pbbam/pbmerge: \$( pbmerge --version|sed 's/pbmerge //' )
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
46
modules/pbbam/pbmerge/meta.yml
Normal file
46
modules/pbbam/pbmerge/meta.yml
Normal file
|
@ -0,0 +1,46 @@
|
|||
name: pbbam_pbmerge
|
||||
description: The pbbam software package provides components to create, query, & edit PacBio BAM files and associated indices. These components include a core C++ library, bindings for additional languages, and command-line utilities.
|
||||
keywords:
|
||||
- pbbam
|
||||
- pbbam/pbmerge
|
||||
tools:
|
||||
- pbbam:
|
||||
description: PacBio BAM C++ library
|
||||
homepage: https://github.com/PacificBiosciences/pbbioconda
|
||||
documentation: https://pbbam.readthedocs.io/en/latest/tools/pbmerge.html
|
||||
tool_dev_url: https://github.com/pacificbiosciences/pbbam/
|
||||
doi: ""
|
||||
licence: ['BSD-3-clause-Clear']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- bam:
|
||||
type: file
|
||||
description: BAM files to merge
|
||||
pattern: "*.bam"
|
||||
|
||||
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: The merged bam file
|
||||
pattern: "*.bam"
|
||||
- pbi:
|
||||
type: file
|
||||
description: BAM Pacbio index file
|
||||
pattern: "*.bam.pbi"
|
||||
|
||||
authors:
|
||||
- "@sguizard"
|
|
@ -731,6 +731,10 @@ pangolin:
|
|||
- modules/pangolin/**
|
||||
- tests/modules/pangolin/**
|
||||
|
||||
pbbam/pbmerge:
|
||||
- modules/pbbam/pbmerge/**
|
||||
- tests/modules/pbbam/pbmerge/**
|
||||
|
||||
pbccs:
|
||||
- modules/pbccs/**
|
||||
- tests/modules/pbccs/**
|
||||
|
|
18
tests/modules/pbbam/pbmerge/main.nf
Normal file
18
tests/modules/pbbam/pbmerge/main.nf
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { PBBAM_PBMERGE } from '../../../../modules/pbbam/pbmerge/main.nf' addParams( options: [suffix: '.merged'] )
|
||||
|
||||
workflow test_pbbam_pbmerge {
|
||||
|
||||
input = [
|
||||
[ id:'test' ], // meta map
|
||||
[
|
||||
file(params.test_data['homo_sapiens']['pacbio']['cluster'] , checkIfExists: true),
|
||||
file(params.test_data['homo_sapiens']['pacbio']['singletons'], checkIfExists: true)
|
||||
]
|
||||
]
|
||||
|
||||
PBBAM_PBMERGE ( input )
|
||||
}
|
10
tests/modules/pbbam/pbmerge/test.yml
Normal file
10
tests/modules/pbbam/pbmerge/test.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
- name: pbbam pbmerge test_pbbam_pbmerge
|
||||
command: nextflow run tests/modules/pbbam/pbmerge -entry test_pbbam_pbmerge -c tests/config/nextflow.config
|
||||
tags:
|
||||
- pbbam/pbmerge
|
||||
- pbbam
|
||||
files:
|
||||
- path: output/pbbam/test.merged.bam
|
||||
md5sum: 727c7ba1289192085c06890dda70f973
|
||||
- path: output/pbbam/test.merged.bam.pbi
|
||||
md5sum: edfadd3a81c598d1ee051899792db75d
|
Loading…
Reference in a new issue