Cooler digest (#517)

* add software/cooler

* fix the wrong files uploaded.

* create a branch for cooler/digest

Co-authored-by: Jose Espinosa-Carrasco <kadomu@gmail.com>
This commit is contained in:
JIANHONG OU 2021-06-09 05:39:22 -04:00 committed by GitHub
parent 8d4c6de50d
commit 580d1e194a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 175 additions and 0 deletions

View 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"
}
}
}

View file

@ -0,0 +1,42 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process COOLER_DIGEST {
tag '$fasta'
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:[:], publish_by_meta:[]) }
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:
path fasta
path chromsizes
val enzyme
output:
path "*.bed" , emit: bed
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
"""
cooler digest \\
$options.args \\
-o "${fasta.baseName}_${enzyme.replaceAll(/[^0-9a-zA-Z]+/, "_")}.bed" \\
$chromsizes \\
$fasta \\
$enzyme
echo \$(cooler --version 2>&1) | sed 's/cooler, version //' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,39 @@
name: cooler_digest
description: Generate fragment-delimited genomic bins
keywords:
- digest
- enzyme
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:
- fasta:
type: file
description: Genome assembly FASTA file or folder containing FASTA files (uncompressed).
pattern: "*.{fasta,fa}"
- chromsizes:
type: file
description: Path to a chromsizes file.
- enzyme:
type: String
description: Name of restriction enzyme. e.g. CviQI.
documentation: http://biopython.org/DIST/docs/cookbook/Restriction.html
output:
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
- bed:
type: file
description: A genome segmentation of restriction fragments as a BED file.
pattern: "*.{bed}"
authors:
- "@jianhong"

View file

@ -178,6 +178,10 @@ cnvkit:
- software/cnvkit/**
- tests/software/cnvkit/**
cooler/digest:
- software/cooler/digest/**
- tests/software/cooler/digest/**
cooler/dump:
- software/cooler/dump/**
- tests/software/cooler/dump/**

View file

@ -0,0 +1,14 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { COOLER_DIGEST } from '../../../../software/cooler/digest/main.nf' addParams( options: [:] )
workflow test_cooler_digest {
input = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
sizes = file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true)
enzyme = "CviQI"
COOLER_DIGEST ( input, sizes, enzyme )
}

View file

@ -0,0 +1,8 @@
- name: cooler digest test_cooler_digest
command: nextflow run tests/software/cooler/digest -entry test_cooler_digest -c tests/config/nextflow.config
tags:
- cooler/digest
- cooler
files:
- path: output/cooler/genome_CviQI.bed
md5sum: f02d3cfaf642b27d4cc197209845e096