add additional ucsc tools (#506)

* add additional ucsc tools

* Update software/ucsc/wigtobigwig/meta.yml

Co-authored-by: Kevin Menden <kevin.menden@live.com>

* Update the functions.nf and software name for ucsc/wigtobigwig and bigwigaverageoverbed.

Co-authored-by: Kevin Menden <kevin.menden@live.com>
This commit is contained in:
JIANHONG OU 2021-05-20 15:39:33 -04:00 committed by GitHub
parent e75f88c68a
commit ce68395240
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 350 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,38 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process UCSC_BIGWIGAVERAGEOVERBED {
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), meta:meta, publish_by_meta:['id']) }
conda (params.enable_conda ? "bioconda::ucsc-bigwigaverageoverbed=377" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/ucsc-bigwigaverageoverbed:377--h0b8a92a_2"
} else {
container "quay.io/biocontainers/ucsc-bigwigaverageoverbed:377--h0b8a92a_2"
}
input:
tuple val(meta), path(bed)
path bigwig
output:
tuple val(meta), path("*.tab") , emit: tab
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
# there is a bug that bigWigAverageOverBed can not handle ensembl seqlevels style.
bigWigAverageOverBed ${options.args} $bigwig $bed ${bed.getSimpleName()}.tab
echo \$(bigWigAverageOverBed 2>&1) | sed 's/bigWigAverageOverBed v//; s/ - Compute.*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,46 @@
name: ucsc_bigwigaverageoverbed
description: compute average score of bigwig over bed file
keywords:
- bigwig
- bedGraph
tools:
- ucsc:
description: Compute average score of big wig over each bed, which may have introns.
homepage: None
documentation: None
tool_dev_url: None
doi: ""
licence: ['varies; see http://genome.ucsc.edu/license']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bed:
type: file
description: bed file
pattern: "*.{bed}"
- bigwig:
type: file
description: bigwig file
pattern: "*.{bigwig,bw}"
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}"
- tab:
type: file
description: tab file
pattern: "*.{tab}"
authors:
- "@jianhong"

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,41 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process UCSC_WIGTOBIGWIG {
tag '$wig'
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::ucsc-wigtobigwig=377" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/ucsc-wigtobigwig:377--h0b8a92a_2"
} else {
container "quay.io/biocontainers/ucsc-wigtobigwig:377--h0b8a92a_2"
}
input:
path wig
path chromsizes
output:
path "*.bw" , emit: bw
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
"""
wigToBigWig \\
$options.args \\
$wig \\
$chromsizes \\
${wig.getSimpleName()}.bw
echo \$(wigToBigWig 2>&1) | sed 's/wigToBigWig v //; s/ - Convert.*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,37 @@
name: ucsc_wigtobigwig
description: Convert ascii format wig file to binary big wig format
keywords:
- wig
- bigwig
tools:
- ucsc:
description: |
Convert ascii format wig file (in fixedStep, variableStep
or bedGraph format) to binary big wig format
homepage: None
documentation: None
tool_dev_url: None
doi: ""
licence: ['varies; see http://genome.ucsc.edu/license']
input:
- wig:
type: file
description: wig file
pattern: "*.{wig}"
- chromsizes:
type: file
description: chromosome sizes file
output:
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
- bw:
type: file
description: bigwig file
pattern: "*.{bw}"
authors:
- "@jianhong"

View file

@ -659,6 +659,14 @@ ucsc/bedgraphtobigwig:
- software/ucsc/bedgraphtobigwig/**
- tests/software/ucsc/bedgraphtobigwig/**
ucsc/bigwigaverageoverbed:
- software/ucsc/bigwigaverageoverbed/**
- tests/software/ucsc/bigwigaverageoverbed/**
ucsc/wigtobigwig:
- software/ucsc/wigtobigwig/**
- tests/software/ucsc/wigtobigwig/**
unicycler:
- software/unicycler/**
- tests/software/unicycler/**

View file

@ -0,0 +1,14 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { UCSC_BIGWIGAVERAGEOVERBED } from '../../../../software/ucsc/bigwigaverageoverbed/main.nf' addParams( options: [:] )
workflow test_ucsc_bigwigaverageoverbed {
input = [ [ id: 'test' ], // meta map
[ file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true ) ]
]
bigwig = file(params.test_data['sarscov2']['illumina']['test_bigwig'], checkIfExists: true)
UCSC_BIGWIGAVERAGEOVERBED ( input, bigwig )
}

View file

@ -0,0 +1,8 @@
- name: ucsc bigwigaverageoverbed test_ucsc_bigwigaverageoverbed
command: nextflow run tests/software/ucsc/bigwigaverageoverbed -entry test_ucsc_bigwigaverageoverbed -c tests/config/nextflow.config
tags:
- ucsc
- ucsc/bigwigaverageoverbed
files:
- path: output/ucsc/test.tab
md5sum: d92334d90353577571eaf777933dce9b

View file

@ -0,0 +1,14 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { UCSC_WIGTOBIGWIG } from '../../../../software/ucsc/wigtobigwig/main.nf' addParams( options: [:] )
workflow test_ucsc_wigtobigwig {
input = file(params.test_data['sarscov2']['illumina']['test_wig_gz'], checkIfExists: true)
sizes = file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true)
UCSC_WIGTOBIGWIG ( input, sizes )
}

View file

@ -0,0 +1,8 @@
- name: ucsc wigtobigwig test_ucsc_wigtobigwig
command: nextflow run tests/software/ucsc/wigtobigwig -entry test_ucsc_wigtobigwig -c tests/config/nextflow.config
tags:
- ucsc
- ucsc/wigtobigwig
files:
- path: output/ucsc/test.bw
md5sum: b64af7003665dc51fae958216b06ed95