Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update utils subworkflows #4766

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions subworkflows/nf-core/utils_nextflow_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.yaml.snakeyaml.Yaml
import groovy.json.JsonOutput
import nextflow.extension.FilesEx

/*
========================================================================================
Expand All @@ -16,7 +17,7 @@ workflow UTILS_NEXTFLOW_PIPELINE {
take:
print_version // bool
dump_parameters // bool
output_directory // path: base directory used to publish pipeline results
outdir // path: base directory used to publish pipeline results
check_conda_channels // bool

main:
Expand All @@ -32,8 +33,8 @@ workflow UTILS_NEXTFLOW_PIPELINE {
//
// Dump pipeline parameters to a JSON file
//
if (dump_parameters && output_directory) {
dumpParametersToJSON(output_directory)
if (dump_parameters && outdir) {
dumpParametersToJSON(outdir)
}

//
Expand All @@ -42,9 +43,6 @@ workflow UTILS_NEXTFLOW_PIPELINE {
if (check_conda_channels) {
checkCondaChannels()
}

emit:
out = true
}

/*
Expand Down Expand Up @@ -74,16 +72,15 @@ def getWorkflowVersion() {
//
// Dump pipeline parameters to a JSON file
//
def dumpParametersToJSON(output_directory) {
def output_d = new File("${output_directory}/pipeline_info/")
if (!output_d.exists()) {
output_d.mkdirs()
}

def dumpParametersToJSON(outdir) {
def timestamp = new java.util.Date().format( 'yyyy-MM-dd_HH-mm-ss')
def output_pf = new File(output_d, "params_${timestamp}.json")
def filename = "params_${timestamp}.json"
def temp_pf = new File(workflow.launchDir.toString(), ".${filename}")
def jsonStr = JsonOutput.toJson(params)
output_pf.text = JsonOutput.prettyPrint(jsonStr)
temp_pf.text = JsonOutput.prettyPrint(jsonStr)

FilesEx.copyTo(temp_pf.toPath(), "${outdir}/pipeline_info/params_${timestamp}.json")
temp_pf.delete()
}

//
Expand Down
7 changes: 2 additions & 5 deletions subworkflows/nf-core/utils_nextflow_pipeline/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ input:
type: boolean
description: |
Check if the conda channel priority is correct.
output:
- out:
type: boolean
description: |
Dummy output for making using in process chaining.
output: []
authors:
- "@adamrtalbot"
- "@drpatelh"
maintainers:
- "@adamrtalbot"
- "@drpatelh"
- "@maxulysse"
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,12 @@ nextflow_function {

function "getWorkflowVersion"

when {
function {
"""
// no inputs
"""
}
}

then {
assert function.success
assert snapshot(function.result).match()
}

}


test("Test Function dumpParametersToJSON") {

function "dumpParametersToJSON"
Expand All @@ -43,29 +33,16 @@ nextflow_function {

then {
assert function.success
assert function.result =~ /publish_dir_mode/
assert function.result =~ /copy/
}

}

test("Test Function checkCondaChannels") {

function "checkCondaChannels"

when {
function {
"""
// no inputs
"""
}
}

then {
assert function.success
assert snapshot(function.result).match()
}

}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ nextflow_workflow {

then {
assert workflow.success
assert snapshot(workflow.out).match()
}

}

test("Should print version") {
Expand All @@ -51,10 +49,8 @@ nextflow_workflow {
assert workflow.success
assert workflow.stdout.contains("nextflow_workflow v9.9.9")
}

}


test("Should dump params") {

when {
Expand All @@ -73,9 +69,7 @@ nextflow_workflow {

then {
assert workflow.success
assert snapshot(workflow.out).match()
}

}

test("Should not create params JSON if no output directory") {
Expand All @@ -96,9 +90,6 @@ nextflow_workflow {

then {
assert workflow.success
assert snapshot(workflow.out, path(params.outdir).list()).match()
}

}

}

This file was deleted.

Loading
Loading