Formatting

The keywords “MUST”, “MUST NOT”, “SHOULD”, etc. are to be interpreted as described in RFC 2119.

1 Strict syntax

nf-core/configs MUST be Nextflow strict syntax compliant to ensure compatibility with all nf-core pipelines.

Compliance of a config to the strict syntax can be checked using the methods described in the strict syntax migration guide.

1.1 Variables

Variables MUST be defined as parameters (params) for reusing information in different parts of a config.

- def variable_name = <code>
+ params.variable_name = <code>

Variables that are defined using a condition MUST be wrapped in a closure and executed with the .call() function.

params.variable_name = {
    if (large_data == true) {
        return 'small'
    } else {
        return 'big'
    }
}.call()

1.2 Functions

Functions MUST NOT be used within a config.

1.3 Conditional statements

Simple if-else statements SHOULD be written using a ternary operator.

process.executor = params.slurm ? 'slurm' : 'local'

Larger conditions SHOULD be written using if-else statements. Switch conditions MUST NOT be used.

queue = {
  if (task.memory >= 216.GB) {
      if (task.time >= 7.d) {
          return 'longmem'
      } else {
          return 'mem'
      }
  } else {
      if (task.time >= 21.d) {
          return 'long60'
      } else if (task.time >= 7.d) {
          return 'long'
      } else if (task.time >= 48.h) {
          return 'medium'
      } else {
          return 'short'
      }
  }
}

If related HPCs are being referred to in a single config, conditional sub-config files MAY be included by passing a closure to includeConfig():

includeConfig ({
    if (condition) {
        return "conf1.config"
    } else if (condition2) {
        return "conf2.config"
    } else {
        return "/dev/null"
    }
}.call())

1.4 Environmental variables

Environmental variables MUST be referenced with a System.getenv call.

scratch      = "/scratch/${System.getenv('USER')}"