mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
ucsc_bed12tobigbed (previous pull request had conflicts) (#302)
* Add files via upload * Add files via upload * Add files via upload * Add files via upload * Update pytest_software.yml * Update main.nf * fix linting error * Delete test.yml * Create functions.nf * Update main.nf * change test data * revert to !>=20.11.0-edge
This commit is contained in:
parent
a13d859c87
commit
af3bc225c0
7 changed files with 131 additions and 0 deletions
59
software/ucsc/bed12tobigbed/functions.nf
Normal file
59
software/ucsc/bed12tobigbed/functions.nf
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* -----------------------------------------------------
|
||||||
|
* 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.publish_by_id = args.publish_by_id ?: false
|
||||||
|
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_id) {
|
||||||
|
path_list.add(args.publish_id)
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
software/ucsc/bed12tobigbed/main.nf
Normal file
41
software/ucsc/bed12tobigbed/main.nf
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
def options = initOptions(params.options)
|
||||||
|
|
||||||
|
def VERSION = '377'
|
||||||
|
|
||||||
|
process UCSC_BED12TOBIGBED {
|
||||||
|
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), publish_id:meta.id) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::ucsc-bedtobigbed=377" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/ucsc-bedtobigbed:377--h446ed27_1"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/ucsc-bedtobigbed:377--h446ed27_1"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(bed)
|
||||||
|
path sizes
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*.bigBed"), emit: bigbed
|
||||||
|
path "*.version.txt" , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
"""
|
||||||
|
bedToBigBed \\
|
||||||
|
$bed \\
|
||||||
|
$sizes \\
|
||||||
|
${prefix}.bigBed
|
||||||
|
echo $VERSION > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
|
@ -415,6 +415,10 @@ trimgalore:
|
||||||
- software/trimgalore/**
|
- software/trimgalore/**
|
||||||
- tests/software/trimgalore/**
|
- tests/software/trimgalore/**
|
||||||
|
|
||||||
|
ucsc_bed12tobigbed:
|
||||||
|
- software/ucsc/bed12tobigbed/**
|
||||||
|
- tests/software/ucsc/bed12tobigbed/**
|
||||||
|
|
||||||
ucsc_bedgraphtobigwig:
|
ucsc_bedgraphtobigwig:
|
||||||
- software/ucsc/bedgraphtobigwig/**
|
- software/ucsc/bedgraphtobigwig/**
|
||||||
- tests/software/ucsc/bedgraphtobigwig/**
|
- tests/software/ucsc/bedgraphtobigwig/**
|
||||||
|
|
1
tests/data/generic/sizes/test.sizes
Normal file
1
tests/data/generic/sizes/test.sizes
Normal file
|
@ -0,0 +1 @@
|
||||||
|
chr7 159138663
|
4
tests/data/genomics/sarscov2/bed/test.bed12
Normal file
4
tests/data/genomics/sarscov2/bed/test.bed12
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
MT192765.1 1242 1264 nCoV-2019_5_LEFT 1 + 1242 1264 0 2 10,12, 0,10,
|
||||||
|
MT192765.1 1573 1595 nCoV-2019_6_LEFT 2 + 1573 1595 0 2 7,15, 0,7,
|
||||||
|
MT192765.1 1623 1651 nCoV-2019_5_RIGHT 1 - 1623 1651 0 2 14,14, 0,14,
|
||||||
|
MT192765.1 1942 1964 nCoV-2019_6_RIGHT 2 - 1942 1964 0 2 11,11 0,11,
|
15
tests/software/ucsc/bed12tobigbed/main.nf
Normal file
15
tests/software/ucsc/bed12tobigbed/main.nf
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { UCSC_BED12TOBIGBED } from '../../../../software/ucsc/bed12tobigbed/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_ucsc_bed12tobigbed {
|
||||||
|
|
||||||
|
def input = []
|
||||||
|
input = [ [ id: 'test' ], // meta map
|
||||||
|
[ file("${launchDir}/tests/data/genomics/sarscov2/bed/test.bed12", checkIfExists: true )] ]
|
||||||
|
sizes = file("${launchDir}/tests/data/genomics/sarscov2/general/test.genome.sizes", checkIfExists: true)
|
||||||
|
|
||||||
|
UCSC_BED12TOBIGBED ( input, sizes )
|
||||||
|
}
|
7
tests/software/ucsc/bed12tobigbed/test.yml
Normal file
7
tests/software/ucsc/bed12tobigbed/test.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- name: ucsc bed12tobigbed
|
||||||
|
command: nextflow run ./tests/software/ucsc/bed12tobigbed -entry test_ucsc_bed12tobigbed -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- ucsc_bed12tobigbed
|
||||||
|
files:
|
||||||
|
- path: output/ucsc/test.bigBed
|
||||||
|
md5sum: 98cf0d0baa3ae5a330c80afbb8bc2b18
|
Loading…
Reference in a new issue