mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-23 03:28:17 +00:00
Cooler dump (#516)
* add software/cooler * fix the wrong files uploaded. * create a branch for cooler/dump * remove the bin size from metadata.
This commit is contained in:
parent
0745213729
commit
8d4c6de50d
6 changed files with 173 additions and 0 deletions
68
software/cooler/dump/functions.nf
Normal file
68
software/cooler/dump/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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
software/cooler/dump/main.nf
Normal file
39
software/cooler/dump/main.nf
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process COOLER_DUMP {
|
||||||
|
tag "$meta.id"
|
||||||
|
label 'process_high'
|
||||||
|
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::cooler=0.8.11" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/cooler:0.8.11--pyh3252c3a_0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/cooler:0.8.11--pyh3252c3a_0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(cool)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*.bedpe"), emit: bedpe
|
||||||
|
path "*.version.txt" , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
"""
|
||||||
|
cooler dump \\
|
||||||
|
$options.args \\
|
||||||
|
-o ${prefix}.bedpe \\
|
||||||
|
$cool
|
||||||
|
|
||||||
|
echo \$(cooler --version 2>&1) | sed 's/cooler, version //' > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
41
software/cooler/dump/meta.yml
Normal file
41
software/cooler/dump/meta.yml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
name: cooler_dump
|
||||||
|
description: Dump a cooler’s data to a text stream.
|
||||||
|
keywords:
|
||||||
|
- dump
|
||||||
|
tools:
|
||||||
|
- cooler:
|
||||||
|
description: Sparse binary format for genomic interaction matrices
|
||||||
|
homepage: https://cooler.readthedocs.io/en/latest/index.html
|
||||||
|
documentation: https://cooler.readthedocs.io/en/latest/index.html
|
||||||
|
tool_dev_url: https://github.com/open2c/cooler
|
||||||
|
doi: "10.1093/bioinformatics/btz540"
|
||||||
|
licence: ['BSD-3-clause']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- cool:
|
||||||
|
type: file
|
||||||
|
description: Path to COOL file
|
||||||
|
pattern: "*.{cool,mcool}"
|
||||||
|
|
||||||
|
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}"
|
||||||
|
- bedpe:
|
||||||
|
type: file
|
||||||
|
description: Output text file
|
||||||
|
pattern: "*.bedpe"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@jianhong"
|
|
@ -178,6 +178,10 @@ cnvkit:
|
||||||
- software/cnvkit/**
|
- software/cnvkit/**
|
||||||
- tests/software/cnvkit/**
|
- tests/software/cnvkit/**
|
||||||
|
|
||||||
|
cooler/dump:
|
||||||
|
- software/cooler/dump/**
|
||||||
|
- tests/software/cooler/dump/**
|
||||||
|
|
||||||
cutadapt:
|
cutadapt:
|
||||||
- software/cutadapt/**
|
- software/cutadapt/**
|
||||||
- tests/software/cutadapt/**
|
- tests/software/cutadapt/**
|
||||||
|
|
13
tests/software/cooler/dump/main.nf
Normal file
13
tests/software/cooler/dump/main.nf
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { COOLER_DUMP } from '../../../../software/cooler/dump/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_cooler_dump {
|
||||||
|
|
||||||
|
input = [ [ id:'test' ], // meta map
|
||||||
|
file("https://raw.githubusercontent.com/open2c/cooler/master/tests/data/toy.asymm.16.cool", checkIfExists: true) ]
|
||||||
|
|
||||||
|
COOLER_DUMP ( input )
|
||||||
|
}
|
8
tests/software/cooler/dump/test.yml
Normal file
8
tests/software/cooler/dump/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
- name: cooler dump test_cooler_dump
|
||||||
|
command: nextflow run tests/software/cooler/dump -entry test_cooler_dump -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- cooler/dump
|
||||||
|
- cooler
|
||||||
|
files:
|
||||||
|
- path: output/cooler/test.bedpe
|
||||||
|
md5sum: 38e9b0b8cc74f55a15e8ab01023048bd
|
Loading…
Reference in a new issue