Skip to content

Commit

Permalink
Merge pull request #112 from Ambys-Medicines/dsl2
Browse files Browse the repository at this point in the history
DSL2: updated modules
  • Loading branch information
lpantano committed Oct 8, 2021
2 parents 42894f2 + 540f805 commit b2ddd36
Show file tree
Hide file tree
Showing 18 changed files with 217 additions and 147 deletions.
12 changes: 10 additions & 2 deletions .nf-core.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
files_unchanged:
- lib/NfcoreSchema.groovy
lint:
files_unchanged:
- .markdownlint.yml
- assets/email_template.html
- assets/email_template.txt
- lib/NfcoreTemplate.groovy
- assets/multiqc_config.yaml
files_exist:
- bin/scrape_software_versions.py
- modules/local/get_software_versions.nf
1 change: 1 addition & 0 deletions modules/local/get_software_versions.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
include { saveFiles } from './functions'

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

process GET_SOFTWARE_VERSIONS {
label 'process_low'
Expand Down
1 change: 1 addition & 0 deletions modules/local/samplesheet_check.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
include { saveFiles } from './functions'

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

process SAMPLESHEET_CHECK {
label 'process_low'
Expand Down
54 changes: 32 additions & 22 deletions modules/nf-core/modules/samtools/flagstat/functions.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ 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
//
Expand Down Expand Up @@ -37,32 +44,35 @@ def getPathFromList(path_list) {
// 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_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)
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"
}
}
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"
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
10 changes: 6 additions & 4 deletions modules/nf-core/modules/samtools/flagstat/main.nf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'

params.options = [:]
options = initOptions(params.options)
Expand All @@ -23,12 +23,14 @@ process SAMTOOLS_FLAGSTAT {

output:
tuple val(meta), path("*.flagstat"), emit: flagstat
path "*.version.txt" , emit: version
path "versions.yml" , emit: versions

script:
def software = getSoftwareName(task.process)
"""
samtools flagstat $bam > ${bam}.flagstat
echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' > ${software}.version.txt
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
}
6 changes: 3 additions & 3 deletions modules/nf-core/modules/samtools/flagstat/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ output:
type: file
description: File containing samtools flagstat output
pattern: "*.{flagstat}"
- version:
- versions:
type: file
description: File containing software version
pattern: "*.{version.txt}"
description: File containing software versions
pattern: "versions.yml"
authors:
- "@drpatelh"
54 changes: 32 additions & 22 deletions modules/nf-core/modules/samtools/idxstats/functions.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ 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
//
Expand Down Expand Up @@ -37,32 +44,35 @@ def getPathFromList(path_list) {
// 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_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)
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"
}
}
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"
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
10 changes: 6 additions & 4 deletions modules/nf-core/modules/samtools/idxstats/main.nf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'

params.options = [:]
options = initOptions(params.options)
Expand All @@ -23,12 +23,14 @@ process SAMTOOLS_IDXSTATS {

output:
tuple val(meta), path("*.idxstats"), emit: idxstats
path "*.version.txt" , emit: version
path "versions.yml" , emit: versions

script:
def software = getSoftwareName(task.process)
"""
samtools idxstats $bam > ${bam}.idxstats
echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' > ${software}.version.txt
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
}
6 changes: 3 additions & 3 deletions modules/nf-core/modules/samtools/idxstats/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ output:
type: file
description: File containing samtools idxstats output
pattern: "*.{idxstats}"
- version:
- versions:
type: file
description: File containing software version
pattern: "*.{version.txt}"
description: File containing software versions
pattern: "versions.yml"
authors:
- "@drpatelh"
54 changes: 32 additions & 22 deletions modules/nf-core/modules/samtools/index/functions.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ 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
//
Expand Down Expand Up @@ -37,32 +44,35 @@ def getPathFromList(path_list) {
// 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_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)
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"
}
}
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"
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
10 changes: 6 additions & 4 deletions modules/nf-core/modules/samtools/index/main.nf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'

params.options = [:]
options = initOptions(params.options)
Expand All @@ -24,12 +24,14 @@ process SAMTOOLS_INDEX {
output:
tuple val(meta), path("*.bai"), optional:true, emit: bai
tuple val(meta), path("*.csi"), optional:true, emit: csi
path "*.version.txt" , emit: version
path "versions.yml" , emit: versions

script:
def software = getSoftwareName(task.process)
"""
samtools index $options.args $bam
echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' > ${software}.version.txt
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
}
6 changes: 3 additions & 3 deletions modules/nf-core/modules/samtools/index/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ output:
type: file
description: CSI index file
pattern: "*.{csi}"
- version:
- versions:
type: file
description: File containing software version
pattern: "*.{version.txt}"
description: File containing software versions
pattern: "versions.yml"
authors:
- "@drpatelh"
- "@ewels"

0 comments on commit b2ddd36

Please sign in to comment.