-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'nf-core:master' into backfill_software_licenses_meta
- Loading branch information
Showing
17 changed files
with
547 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// 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() | ||
} | ||
|
||
// | ||
// Extract name of module from process name using $task.process | ||
// | ||
def getProcessName(task_process) { | ||
return task_process.tokenize(':')[-1] | ||
} | ||
|
||
// | ||
// 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) { | ||
def ioptions = initOptions(args.options) | ||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ] | ||
|
||
// Do not publish versions.yml unless running from pytest workflow | ||
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) { | ||
return null | ||
} | ||
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// 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 | ||
|
||
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: | ||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" | ||
def control = params.control_bam ? "-c $control_bam" : '' | ||
def pvalues = params.pvalues ? "-f ${prefix}.pvalues.bedGraph" : "" | ||
def pileup = params.pileup ? "-k ${prefix}.pileup.bedGraph" : "" | ||
def bed = params.bed ? "-b ${prefix}.intervals.bed" : "" | ||
def blacklist = params.blacklist_bed ? "-E $blacklist_bed" : "" | ||
def duplicates = "" | ||
if (params.save_duplicates) { | ||
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 \\ | ||
$blacklist \\ | ||
$control | ||
cat <<-END_VERSIONS > versions.yml | ||
${getProcessName(task.process)}: | ||
${getSoftwareName(task.process)}: \$(echo \$(Genrich --version 2>&1) | sed 's/^Genrich, version //; s/ .*\$//') | ||
END_VERSIONS | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: genrich | ||
description: Peak-calling for ChIP-seq and ATAC-seq enrichment experiments | ||
keywords: | ||
- peak-calling | ||
- ChIP-seq | ||
- ATAC-seq | ||
tools: | ||
- genrich: | ||
description: | | ||
Genrich is a peak-caller for genomic enrichment assays (e.g. ChIP-seq, ATAC-seq). | ||
It analyzes alignment files generated following the assay and produces a file | ||
detailing peaks of significant enrichment. | ||
homepage: https://github.com/jsh58/Genrich | ||
documentation: https://github.com/jsh58/Genrich#readme | ||
tool_dev_url: https://github.com/jsh58/Genrich | ||
doi: "" | ||
licence: ['MIT'] | ||
|
||
input: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- treatment_bam: | ||
type: file | ||
description: Coordinate sorted BAM/SAM file from treatment sample | ||
pattern: "*.{bam,sam}" | ||
- control_bam: | ||
type: file | ||
description: Coordinate sorted BAM/SAM file from control sample | ||
pattern: "*.{bam,sam}" | ||
- blacklist_bed: | ||
type: file | ||
description: Bed file containing genomic intervals to exclude from the analysis | ||
pattern: "*.{bed}" | ||
|
||
output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- peaks: | ||
type: file | ||
description: Output file is in ENCODE narrowPeak format | ||
pattern: "*.{narrowPeak}" | ||
- bedgraph_pvalues: | ||
type: file | ||
description: bedGraph file containing p/q values | ||
pattern: "*.{pvalues.bedGraph}" | ||
- bedgraph_pileup: | ||
type: file | ||
description: bedGraph file containing pileups and p-values | ||
pattern: "*.{pileup.bedGraph}" | ||
- bed_intervals: | ||
type: file | ||
description: Bed file containing annotated intervals | ||
pattern: "*.{intervals.bed}" | ||
- duplicates: | ||
type: file | ||
description: Text output file containing intervals corresponding to PCR duplicates | ||
pattern: "*.{intervals.txt}" | ||
- version: | ||
type: file | ||
description: File containing software version | ||
pattern: "*.{version.txt}" | ||
|
||
authors: | ||
- "@JoseEspinosa" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// 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() | ||
} | ||
|
||
// | ||
// Extract name of module from process name using $task.process | ||
// | ||
def getProcessName(task_process) { | ||
return task_process.tokenize(':')[-1] | ||
} | ||
|
||
// | ||
// 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) { | ||
def ioptions = initOptions(args.options) | ||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ] | ||
|
||
// Do not publish versions.yml unless running from pytest workflow | ||
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) { | ||
return null | ||
} | ||
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" | ||
} | ||
} |
Oops, something went wrong.