nf-core_modules/modules/idr/main.nf
Harshil Patel 9fb26ae462
Add IDR module (#908)
* Add IDR module

* Add meta and implement main todos

* Modifying idr tests

* Update tests/config/test_data.config

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update tests/config/test_data.config

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update main.nf

* Update tests/config/test_data.config

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update test with new file name

Co-authored-by: Jose Espinosa-Carrasco <kadomu@gmail.com>
2021-10-30 10:52:13 +02:00

56 lines
1.9 KiB
Text

// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process IDR {
tag "$prefix"
label 'process_low'
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::idr=2.0.4.2" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/idr:2.0.4.2--py39hcbe4a3b_5"
} else {
container "quay.io/biocontainers/idr:2.0.4.2--py38h9af456f_5"
}
input:
path peaks
val peak_type
val prefix
output:
path "*idrValues.txt", emit: idr
path "*log.txt" , emit: log
path "*.png" , emit: png
path "versions.yml" , emit: versions
script:
if (peaks.toList().size < 2) {
log.error "[ERROR] idr needs at least two replicates only one provided."
}
def peak_types = ['narrowPeak', 'broadPeak', 'bed']
if (!peak_types.contains(peak_type)) {
log.error "[ERROR] Invalid option: '${peak_type}'. Valid options for 'peak_type': ${peak_types.join(', ')}."
}
def idr_vals = prefix ? "${prefix}.idrValues.txt" : "idrValues.txt"
def log_file = prefix ? "${prefix}.log.txt" : "log.txt"
"""
idr \\
--samples $peaks \\
--input-file-type $peak_type \\
--output-file $idr_vals \\
--log-output-file $log_file \\
--plot \\
$options.args
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$(echo \$(idr --version 2>&1) | sed 's/^.*IDR //; s/ .*\$//')
END_VERSIONS
"""
}