Skip to content

Commit

Permalink
adapt pipeline use nf-schema 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nvnieuwk committed Aug 13, 2024
1 parent cedc5bb commit 4105abf
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 48 deletions.
2 changes: 1 addition & 1 deletion assets/schema_input.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/nf-core/testpipeline/master/assets/schema_input.json",
"title": "nf-core/testpipeline pipeline - params.input schema",
"description": "Schema for the file provided with params.input",
Expand Down
116 changes: 108 additions & 8 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ params {
plaintext_email = false
monochrome_logs = false
hook_url = null
help = false
version = false
validate_params = false

// Config options
config_profile_name = null
Expand All @@ -48,12 +48,10 @@ params {
max_cpus = 16
max_time = '240.h'

// Schema validation default options
validationFailUnrecognisedParams = false
validationLenientMode = false
validationSchemaIgnoreParams = 'genomes,igenomes_base'
validationShowHiddenParams = false
validate_params = true
// Help options
help = false
helpFull = false
showHidden = false

}

Expand Down Expand Up @@ -180,7 +178,7 @@ singularity.registry = 'quay.io'

// Nextflow plugins
plugins {
id 'nf-validation@1.1.3' // Validation of pipeline parameters and creation of an input channel from a sample sheet
id 'nf-schema@2.1.0' // Validation of pipeline parameters and creation of an input channel from a sample sheet
}

// Load igenomes.config if required
Expand Down Expand Up @@ -235,6 +233,108 @@ manifest {
doi = ''
}

validation {
monochromeLogs = false
// Use --help, --help <parameter> or --helpFull to show a help message
help {
enabled = true
beforeText = nfCoreLogo()
command = "nextflow run ${manifest.name} -profile <docker/singularity/.../institute> --input samplesheet.csv --outdir <OUTDIR>"
afterText = workflowCitations()
}
}

def workflowCitations() {
return "If you use ${manifest.name} for your analysis please cite:\n\n" +
"* The pipeline\n" +
" ${manifest.doi}\n\n" +
"* The nf-core framework\n" +
" https://doi.org/10.1038/s41587-020-0439-x\n\n" +
"* Software dependencies\n" +
" https://github.com/${manifest.name}/blob/master/CITATIONS.md"
}

def nfCoreLogo() {
def Map colors = logColours(validation.monochromeLogs)
return String.format(
"""\n
-${colors.dim}----------------------------------------------------${colors.reset}-
${colors.green},--.${colors.black}/${colors.green},-.${colors.reset}
${colors.blue} ___ __ __ __ ___ ${colors.green}/,-._.--~\'${colors.reset}
${colors.blue} |\\ | |__ __ / ` / \\ |__) |__ ${colors.yellow}} {${colors.reset}
${colors.blue} | \\| | \\__, \\__/ | \\ |___ ${colors.green}\\`-._,-`-,${colors.reset}
${colors.green}`._,._,\'${colors.reset}
${colors.purple} ${manifest.name} ${manifest.version}${colors.reset}
-${colors.dim}----------------------------------------------------${colors.reset}-
""".stripIndent()
)
}

def logColours(monochrome_logs=true) {
Map colorcodes = [:]

// Reset / Meta
colorcodes['reset'] = monochrome_logs ? '' : "\033[0m"
colorcodes['bold'] = monochrome_logs ? '' : "\033[1m"
colorcodes['dim'] = monochrome_logs ? '' : "\033[2m"
colorcodes['underlined'] = monochrome_logs ? '' : "\033[4m"
colorcodes['blink'] = monochrome_logs ? '' : "\033[5m"
colorcodes['reverse'] = monochrome_logs ? '' : "\033[7m"
colorcodes['hidden'] = monochrome_logs ? '' : "\033[8m"

// Regular Colors
colorcodes['black'] = monochrome_logs ? '' : "\033[0;30m"
colorcodes['red'] = monochrome_logs ? '' : "\033[0;31m"
colorcodes['green'] = monochrome_logs ? '' : "\033[0;32m"
colorcodes['yellow'] = monochrome_logs ? '' : "\033[0;33m"
colorcodes['blue'] = monochrome_logs ? '' : "\033[0;34m"
colorcodes['purple'] = monochrome_logs ? '' : "\033[0;35m"
colorcodes['cyan'] = monochrome_logs ? '' : "\033[0;36m"
colorcodes['white'] = monochrome_logs ? '' : "\033[0;37m"

// Bold
colorcodes['bblack'] = monochrome_logs ? '' : "\033[1;30m"
colorcodes['bred'] = monochrome_logs ? '' : "\033[1;31m"
colorcodes['bgreen'] = monochrome_logs ? '' : "\033[1;32m"
colorcodes['byellow'] = monochrome_logs ? '' : "\033[1;33m"
colorcodes['bblue'] = monochrome_logs ? '' : "\033[1;34m"
colorcodes['bpurple'] = monochrome_logs ? '' : "\033[1;35m"
colorcodes['bcyan'] = monochrome_logs ? '' : "\033[1;36m"
colorcodes['bwhite'] = monochrome_logs ? '' : "\033[1;37m"

// Underline
colorcodes['ublack'] = monochrome_logs ? '' : "\033[4;30m"
colorcodes['ured'] = monochrome_logs ? '' : "\033[4;31m"
colorcodes['ugreen'] = monochrome_logs ? '' : "\033[4;32m"
colorcodes['uyellow'] = monochrome_logs ? '' : "\033[4;33m"
colorcodes['ublue'] = monochrome_logs ? '' : "\033[4;34m"
colorcodes['upurple'] = monochrome_logs ? '' : "\033[4;35m"
colorcodes['ucyan'] = monochrome_logs ? '' : "\033[4;36m"
colorcodes['uwhite'] = monochrome_logs ? '' : "\033[4;37m"

// High Intensity
colorcodes['iblack'] = monochrome_logs ? '' : "\033[0;90m"
colorcodes['ired'] = monochrome_logs ? '' : "\033[0;91m"
colorcodes['igreen'] = monochrome_logs ? '' : "\033[0;92m"
colorcodes['iyellow'] = monochrome_logs ? '' : "\033[0;93m"
colorcodes['iblue'] = monochrome_logs ? '' : "\033[0;94m"
colorcodes['ipurple'] = monochrome_logs ? '' : "\033[0;95m"
colorcodes['icyan'] = monochrome_logs ? '' : "\033[0;96m"
colorcodes['iwhite'] = monochrome_logs ? '' : "\033[0;97m"

// Bold High Intensity
colorcodes['biblack'] = monochrome_logs ? '' : "\033[1;90m"
colorcodes['bired'] = monochrome_logs ? '' : "\033[1;91m"
colorcodes['bigreen'] = monochrome_logs ? '' : "\033[1;92m"
colorcodes['biyellow'] = monochrome_logs ? '' : "\033[1;93m"
colorcodes['biblue'] = monochrome_logs ? '' : "\033[1;94m"
colorcodes['bipurple'] = monochrome_logs ? '' : "\033[1;95m"
colorcodes['bicyan'] = monochrome_logs ? '' : "\033[1;96m"
colorcodes['biwhite'] = monochrome_logs ? '' : "\033[1;97m"

return colorcodes
}

// Load modules.config for DSL2 module specific options
includeConfig 'conf/modules.config'

Expand Down
14 changes: 7 additions & 7 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/nf-core/testpipeline/master/nextflow_schema.json",
"title": "nf-core/testpipeline pipeline parameters",
"description": "An example pipeline used to test new nf-core infrastructure and common code.",
"type": "object",
"definitions": {
"$defs": {
"input_output_options": {
"title": "Input/output options",
"type": "object",
Expand Down Expand Up @@ -278,19 +278,19 @@
},
"allOf": [
{
"$ref": "#/definitions/input_output_options"
"$ref": "#/$defs/input_output_options"
},
{
"$ref": "#/definitions/reference_genome_options"
"$ref": "#/$defs/reference_genome_options"
},
{
"$ref": "#/definitions/institutional_config_options"
"$ref": "#/$defs/institutional_config_options"
},
{
"$ref": "#/definitions/max_job_request_options"
"$ref": "#/$defs/max_job_request_options"
},
{
"$ref": "#/definitions/generic_options"
"$ref": "#/$defs/generic_options"
}
]
}
1 change: 1 addition & 0 deletions null/pipeline_info/execution_trace_2024-08-13_15-33-42.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
task_id hash native_id name status exit submit duration realtime %cpu peak_rss peak_vmem rchar wchar
14 changes: 3 additions & 11 deletions subworkflows/local/utils_nfcore_testpipeline_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/

include { UTILS_NFVALIDATION_PLUGIN } from '../../nf-core/utils_nfvalidation_plugin'
include { paramsSummaryMap } from 'plugin/nf-validation'
include { fromSamplesheet } from 'plugin/nf-validation'
include { paramsSummaryMap } from 'plugin/nf-schema'
include { samplesheetToList } from 'plugin/nf-schema'
include { UTILS_NEXTFLOW_PIPELINE } from '../../nf-core/utils_nextflow_pipeline'
include { completionEmail } from '../../nf-core/utils_nfcore_pipeline'
include { completionSummary } from '../../nf-core/utils_nfcore_pipeline'
Expand Down Expand Up @@ -54,14 +54,7 @@ workflow PIPELINE_INITIALISATION {
//
// Validate parameters and generate parameter summary to stdout
//
pre_help_text = nfCoreLogo(monochrome_logs)
post_help_text = '\n' + workflowCitation() + '\n' + dashedLine(monochrome_logs)
def String workflow_command = "nextflow run ${workflow.manifest.name} -profile <docker/singularity/.../institute> --input samplesheet.csv --outdir <OUTDIR>"
UTILS_NFVALIDATION_PLUGIN (
help,
workflow_command,
pre_help_text,
post_help_text,
validate_params,
"nextflow_schema.json"
)
Expand All @@ -80,8 +73,7 @@ workflow PIPELINE_INITIALISATION {
//
// Create channel from input file provided through params.input
//
Channel
.fromSamplesheet("input")
Channel.fromList(samplesheetToList(params.input, "assets/schema_input.json"))
.map {
meta, fastq_1, fastq_2 ->
if (!fastq_2) {
Expand Down
25 changes: 4 additions & 21 deletions subworkflows/nf-core/utils_nfvalidation_plugin/main.nf

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

0 comments on commit 4105abf

Please sign in to comment.