Commit be7b4318 authored by Chris Cheshire's avatar Chris Cheshire
Browse files

Updated bedgraphtobigwig

parent a56f8228
Loading
Loading
Loading
Loading
+37 −28
Original line number Diff line number Diff line
/*
 * -----------------------------------------------------
 *  Utility functions used in nf-core DSL2 module files
 * -----------------------------------------------------
 */
//
//  Utility functions used in nf-core DSL2 module files
//

/*
 * Extract name of software tool from process name using $task.process
 */
//
// 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
 */
//
// 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.publish_by_id = args.publish_by_id ?: false
    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
 */
//
// 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
 */
//
// 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_id) {
            path_list.add(args.publish_id)
        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) {
+2 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
include { initOptions; saveFiles; getSoftwareName } from './functions'

params.options = [:]
def options    = initOptions(params.options)
options        = initOptions(params.options)

def VERSION = '377'

@@ -11,7 +11,7 @@ process UCSC_BEDGRAPHTOBIGWIG {
    label 'process_medium'
    publishDir "${params.outdir}",
        mode: params.publish_dir_mode,
        saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) }
        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-bedgraphtobigwig=377" : null)
    if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
+46 −0
Original line number Diff line number Diff line
name: ucsc_bedgraphtobigwig
description: Convert a bedGraph file to bigWig format.
keywords:
  - bedgraph
  - bigwig
tools:
  - ucsc:
      description: Convert a bedGraph file to bigWig format.
      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 ]
  - bedgraph:
      type: file
      description: bedGraph file
      pattern: "*.{bedGraph}"
  - sizes:
      type: file
      description: chromosome sizes file
      pattern: "*.{sizes}"

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}"
  - bigwig:
      type: file
      description: bigWig file
      pattern: "*.{bigWig}"

authors:
  - "@drpatelh"