2021-10-22 10:22:02 +00:00
|
|
|
// Import generic module functions
|
|
|
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
|
|
|
|
|
|
|
params.options = [:]
|
|
|
|
options = initOptions(params.options)
|
|
|
|
|
|
|
|
process GENRICH {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_high'
|
|
|
|
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::genrich=0.6.1" : null)
|
|
|
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
|
|
|
container "https://depot.galaxyproject.org/singularity/genrich:0.6.1--h5bf99c6_1"
|
|
|
|
} else {
|
|
|
|
container "quay.io/biocontainers/genrich:0.6.1--h5bf99c6_1"
|
|
|
|
}
|
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(treatment_bam)
|
|
|
|
path control_bam
|
|
|
|
path blacklist_bed
|
2021-10-29 14:37:39 +00:00
|
|
|
val save_pvalues
|
|
|
|
val save_pileup
|
|
|
|
val save_bed
|
|
|
|
val save_duplicates
|
2021-10-22 10:22:02 +00:00
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*narrowPeak") , emit: peaks
|
|
|
|
tuple val(meta), path("*pvalues.bedGraph"), optional:true, emit: bedgraph_pvalues
|
|
|
|
tuple val(meta), path("*pileup.bedGraph") , optional:true, emit: bedgraph_pileup
|
|
|
|
tuple val(meta), path("*intervals.bed") , optional:true, emit: bed_intervals
|
|
|
|
tuple val(meta), path("*duplicates.txt") , optional:true, emit: duplicates
|
|
|
|
path "versions.yml" , emit: versions
|
|
|
|
|
|
|
|
script:
|
2021-10-29 14:37:39 +00:00
|
|
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
|
|
|
def control = control_bam ? "-c $control_bam" : ''
|
|
|
|
def blacklist = blacklist_bed ? "-E $blacklist_bed" : ""
|
|
|
|
def pvalues = save_pvalues ? "-f ${prefix}.pvalues.bedGraph" : ""
|
|
|
|
def pileup = save_pileup ? "-k ${prefix}.pileup.bedGraph" : ""
|
|
|
|
def bed = save_bed ? "-b ${prefix}.intervals.bed" : ""
|
2021-10-22 10:22:02 +00:00
|
|
|
def duplicates = ""
|
2021-10-29 14:37:39 +00:00
|
|
|
if (save_duplicates) {
|
2021-10-22 10:22:02 +00:00
|
|
|
if (options.args.contains('-r')) {
|
|
|
|
duplicates = "-R ${prefix}.duplicates.txt"
|
|
|
|
} else {
|
|
|
|
log.info '[Genrich] Duplicates can only be saved if they are filtered, defaulting to -r option (Remove PCR duplicates).'
|
|
|
|
duplicates = "-r -R ${prefix}.duplicates.txt"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
Genrich \\
|
|
|
|
-t $treatment_bam \\
|
|
|
|
$options.args \\
|
|
|
|
$control \\
|
|
|
|
$blacklist \\
|
|
|
|
-o ${prefix}.narrowPeak \\
|
|
|
|
$pvalues \\
|
|
|
|
$pileup \\
|
|
|
|
$bed \\
|
|
|
|
$duplicates \\
|
|
|
|
$control
|
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
${getProcessName(task.process)}:
|
|
|
|
${getSoftwareName(task.process)}: \$(echo \$(Genrich --version 2>&1) | sed 's/^Genrich, version //; s/ .*\$//')
|
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
}
|