Schema for Nextflow pipeline specs¶
Title: Schema for Nextflow pipeline specs
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
Description: Schema to validate Nextflow pipeline specs
| Property | Type |
|---|---|
| + $schema | string |
| + $id | string |
| + title | string |
| + description | string |
| + type | const |
| - $defs | object |
| - properties | object |
| - dependentRequired | object |
| - allOf | array of object |
$schema¶
Title: schema
| Type | string |
| Required | Yes |
| Restrictions | |
|---|---|
| Min length | 1 |
$id¶
Title: ID URI
| Type | string |
| Required | Yes |
| Restrictions | |
|---|---|
| Min length | 1 |
title¶
Title: Title
| Type | string |
| Required | Yes |
| Restrictions | |
|---|---|
| Min length | 1 |
description¶
Title: Description
| Type | string |
| Required | Yes |
| Restrictions | |
|---|---|
| Min length | 1 |
type¶
Title: Top level type
| Type | const |
| Required | Yes |
Specific value: "object"
$defs¶
Title: Parameter groups
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
Description: A slightly strange use of a JSON schema standard that we use for Nextflow schema is $defs.
JSON schema can group variables together in an object, but then the validation expects this structure to exist in the data that it is validating.
In reality, we have a very long "flat" list of parameters, all at the top level of params.foo.
In order to give some structure to log outputs, documentation and so on, we group parameters into $defs.
Each def is an object with a title, description and so on.
However, as they are under $defs scope they are effectively ignored by the validation and so their nested nature is not a problem.
We then bring the contents of each definition object back to the "flat" top level for validation using a series of allOf statements at the end of the schema,
which reference the specific definition keys.
| Property | Type |
|---|---|
| - ^.*$ | object |
^.*$¶
All properties whose name matches the regular expression
^.*$(Test) must respect the following conditions
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
| Property | Type |
|---|---|
| + title | string |
| + type | const |
| - fa_icon | string |
| - description | string |
| - required | array |
| + properties | object |
| - dependentRequired | object |
title¶
| Type | string |
| Required | Yes |
| Restrictions | |
|---|---|
| Min length | 1 |
type¶
| Type | const |
| Required | Yes |
Specific value: "object"
fa_icon¶
| Type | string |
| Required | No |
| Restrictions | |
|---|---|
| Must match regular expression | ^fa Test |
description¶
| Type | string |
| Required | No |
required¶
| Type | array |
| Required | No |
Description: Any parameters that must be specified should be set as required in the schema.
Tip
Make sure you do set null as a default value for the parameter, otherwise it will have a value even if not supplied by the pipeline user and the required property will have no effect.
This is not done with a property key like other things described below, but rather by naming
the parameter in the required array in the definition object / top-level object.
For more information, see the JSON schema documentation.
properties¶
| Type | object |
| Required | Yes |
| Additional properties | Any type allowed |
| Defined in | #/$defs/parameterOptions |
| Property | Type |
|---|---|
| - ^.*$ | Combination |
^.*$¶
All properties whose name matches the regular expression
^.*$(Test) must respect the following conditions
| Type | combining |
| Required | No |
| Additional properties | Any type allowed |
| All of(Requirement) |
|---|
| standardKeywords |
| customKeywords |
standardKeywords¶
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
| Defined in | #/$defs/standardKeywords |
Description: Allowed standard JSON Schema properties.
| Property | Type |
|---|---|
| - type | Combination |
| - format | enum (of string) |
| - pattern | string |
| - description | string |
| - default | integer, boolean, string, number or null |
| - examples | array |
| - deprecated | boolean |
| - minLength | integer |
| - maxLength | integer |
| - minimum | number |
| - exclusiveMinimum | number |
| - maximum | number |
| - exclusiveMaximum | number |
| - multipleOf | number |
| - enum | array |
| - const | integer, boolean, string, number or null |
type¶
| Type | combining |
| Required | No |
| Additional properties | Any type allowed |
Description: Variable type, taken from the JSON schema keyword vocabulary:
stringnumber(float)integerboolean(true / false)object(currently only supported for file validation)array(currently only supported for file validation)
Validation checks that the supplied parameter matches the expected type, and will fail with an error if not.
This JSON schema type is not supported:
null
| Any of(Option) |
|---|
| typeAnnotation |
| item 1 |
typeAnnotation¶
| Type | enum (of string) |
| Required | No |
| Defined in | #/$defs/typeAnnotation |
Must be one of:
- "string"
- "boolean"
- "integer"
- "number"
- "null"
item 1¶
| Type | array |
| Required | No |
| Each item of this array must be | Description |
|---|---|
| typeAnnotation | - |
typeAnnotation¶
| Type | enum (of string) |
| Required | No |
| Same definition as | defs_pattern1_properties_pattern1_pattern2_i0_type_anyOf_i0 |
format¶
| Type | enum (of string) |
| Required | No |
Description: Formats can be used to give additional validation checks against string values for certain properties.
Non-standard key (values)
The format key is a standard JSON schema key,
however we primarily use it for validating file / directory path operations with non-standard schema values.
Example usage is as follows:
The available format types are below:
file-path- States that the provided value is a file. Does not check its existence, but it does check if the path is not a directory.
directory-path- States that the provided value is a directory. Does not check its existence, but if it exists, it does check that the path is not a file.
path- States that the provided value is a path (file or directory). Does not check its existence.
file-path-pattern- States that the provided value is a glob pattern that will be used to fetch files. Checks that the pattern is valid and that at least one file is found.
Must be one of:
- "file-path"
- "directory-path"
- "path"
- "file-path-pattern"
- "date-time"
- "date"
- "time"
- "email"
- "uri"
- "regex"
pattern¶
| Type | string |
| Required | No |
| Format | regex |
Description: Regular expression which the string must match in order to pass validation.
- See the JSON schema docs for details.
- Use https://regex101.com/ for help with writing regular expressions.
For example, this pattern only validates if the supplied string ends in .fastq, .fq, .fastq.gz or .fq.gz:
| Restrictions | |
|---|---|
| Min length | 1 |
description¶
| Type | string |
| Required | No |
Description: A short description of what the parameter does, written in markdown. Printed in docs and terminal help text. Should be maximum one short sentence.
default¶
| Type | integer, boolean, string, number or null |
| Required | No |
| Defined in | #/$defs/allTypes |
Description: Default value for the parameter.
Should match the type and validation patterns set for the parameter in other fields.
Tip
If no default should be set, completely omit this key from the schema.
Do not set it as an empty string, or null.
However, parameters with no defaults should be set to null within your Nextflow config file.
Note
When creating a schema using nf-core schema build, this field will be automatically created based
on the default value defined in the pipeline config files.
Generally speaking, the two should always be kept in sync to avoid unexpected problems and usage errors. In some rare cases, this may not be possible (for example, a dynamic groovy expression cannot be encoded in JSON), in which case try to specify as "sensible" a default within the schema as possible.
examples¶
| Type | array |
| Required | No |
Description: A list of examples for the current parameter
| Each item of this array must be | Description |
|---|---|
| allTypes | - |
allTypes¶
| Type | integer, boolean, string, number or null |
| Required | No |
| Same definition as | default |
deprecated¶
| Type | boolean |
| Required | No |
Description: !!! example "Extended key"
A boolean JSON flag that instructs anything using the schema that this parameter/field is deprecated and should not be used. This can be useful to generate messages telling the user that a parameter has changed between versions.
JSON schema states that this is an informative key only, but in nf-schema this will cause a validation error if the parameter/field is used.
Tip
Using the errorMessage keyword can be useful to provide more information about the deprecation and what to use instead.
minLength¶
| Type | integer |
| Required | No |
| Defined in | #/$defs/nonNegativeInteger |
Description: Specify a minimum / maximum string length with minLength and maxLength.
- See the JSON schema docs for details.
| Restrictions | |
|---|---|
| Minimum | ≥ 0 |
maxLength¶
| Type | integer |
| Required | No |
| Same definition as | minLength |
Description: Specify a minimum / maximum string length with minLength and maxLength.
- See the JSON schema docs for details.
minimum¶
| Type | number |
| Required | No |
Description: Specify a minimum / maximum value for an integer or float number length with minimum and maximum.
- See the JSON schema docs for details.
If x is the value being validated, the following must hold true:
x≥minimumx≤maximum
Note
The JSON schema doc also mention exclusiveMinimum, exclusiveMaximum and multipleOf keys.
Because nf-schema uses stock JSON schema validation libraries, these should work for validating keys.
However, they are not officially supported within the Nextflow schema ecosystem and so some interfaces may not recognise them.
exclusiveMinimum¶
| Type | number |
| Required | No |
Description: Specify a minimum / maximum value for an integer or float number length with minimum and maximum.
- See the JSON schema docs for details.
If x is the value being validated, the following must hold true:
x≥minimumx≤maximum
Note
The JSON schema doc also mention exclusiveMinimum, exclusiveMaximum and multipleOf keys.
Because nf-schema uses stock JSON schema validation libraries, these should work for validating keys.
However, they are not officially supported within the Nextflow schema ecosystem and so some interfaces may not recognise them.
maximum¶
| Type | number |
| Required | No |
Description: Specify a minimum / maximum value for an integer or float number length with minimum and maximum.
- See the JSON schema docs for details.
If x is the value being validated, the following must hold true:
x≥minimumx≤maximum
Note
The JSON schema doc also mention exclusiveMinimum, exclusiveMaximum and multipleOf keys.
Because nf-schema uses stock JSON schema validation libraries, these should work for validating keys.
However, they are not officially supported within the Nextflow schema ecosystem and so some interfaces may not recognise them.
exclusiveMaximum¶
| Type | number |
| Required | No |
Description: Specify a minimum / maximum value for an integer or float number length with minimum and maximum.
- See the JSON schema docs for details.
If x is the value being validated, the following must hold true:
x≥minimumx≤maximum
Note
The JSON schema doc also mention exclusiveMinimum, exclusiveMaximum and multipleOf keys.
Because nf-schema uses stock JSON schema validation libraries, these should work for validating keys.
However, they are not officially supported within the Nextflow schema ecosystem and so some interfaces may not recognise them.
multipleOf¶
| Type | number |
| Required | No |
Description: The 'integer' or 'number' parameter value should be a multiple of this value
enum¶
| Type | array |
| Required | No |
Description: An array of enumerated values: the parameter must match one of these values exactly to pass validation.
- See the JSON schema docs for details.
- Available for strings, numbers and integers.
| Each item of this array must be | Description |
|---|---|
| allTypes | - |
allTypes¶
| Type | integer, boolean, string, number or null |
| Required | No |
| Same definition as | default |
const¶
| Type | integer, boolean, string, number or null |
| Required | No |
| Same definition as | default |
Description: The parameter value should be equal to this value
customKeywords¶
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
| Defined in | #/$defs/customKeywords |
Description: Additional custom JSON Schema properties.
| Property | Type |
|---|---|
| - errorMessage | string |
| - exists | boolean |
| - schema | string |
| - help_text | string |
| - fa_icon | string |
| - hidden | boolean |
| - mimetype | string |
errorMessage¶
| Type | string |
| Required | No |
Description:
Non-standard key
If validation fails, an error message is printed to the terminal, so that the end user knows what to fix. However, these messages are not always very clear - especially to newcomers.
To improve this experience, pipeline developers can set a custom errorMessage for a given parameter in a the schema.
If validation fails, this errorMessage is printed after the original error message to guide the pipeline users to an easier solution.
For example, instead of printing:
We can set
"input": {
"type": "string",
"pattern": "^\S+\.csv$",
"errorMessage": "File name must end in '.csv' cannot contain spaces"
}
and get:
* --input (samples.yml): "samples.yml" does not match regular expression [^\S+\.csv$] (File name must end in '.csv' cannot contain spaces)
| Restrictions | |
|---|---|
| Min length | 1 |
exists¶
| Type | boolean |
| Required | No |
Description: When a format is specified for a value, you can provide the key exists set to true in order to validate that the provided path exists. Set this to false to validate that the path does not exist.
Example usage is as follows:
Note
If the parameter is an S3, Azure or Google Cloud URI path, this validation is ignored.
Warning
Make sure to only use the exists keyword in combination with any file path format. Using exists on a normal string will assume that it's a file and will probably fail unexpectedly.
schema¶
| Type | string |
| Required | No |
Description: Path to a JSON schema file used to validate the supplied file.
Should only be set when format is file-path.
Tip
Setting this field is key to working with sample sheet validation and channel generation, as described in the sample sheet section of the nf-schema docs.
These schema files are typically stored in the pipeline assets directory, but can be anywhere.
Note
If the parameter is set to null, false or an empty string, this validation is ignored. The file won't be validated.
| Restrictions | |
|---|---|
| Min length | 1 |
| Must match regular expression | \.json$ Test |
help_text¶
| Type | string |
| Required | No |
Description:
Non-standard key
A longer text with usage help for the parameter, written in markdown. Can include newlines with multiple paragraphs and more complex markdown structures.
Typically hidden by default in documentation and interfaces, unless explicitly clicked / requested.
fa_icon¶
| Type | string |
| Required | No |
Description:
Non-standard key
A text identifier corresponding to an icon from Font Awesome. Used for easier visual navigation of documentation and pipeline interfaces.
Should be the font-awesome class names, for example:
| Restrictions | |
|---|---|
| Must match regular expression | ^fa Test |
hidden¶
| Type | boolean |
| Required | No |
Description:
Non-standard key
A boolean JSON flag that instructs anything using the schema that this is an unimportant parameter.
Typically used to keep the pipeline docs / UIs uncluttered with common parameters which are not used by the majority of users.
For example, --plaintext_email and --monochrome_logs.
mimetype¶
| Type | string |
| Required | No |
Description: MIME type for a file path. Setting this value informs downstream tools about what kind of file is expected.
Should only be set when format is file-path.
The following properties are required¶
- type
- description
dependentRequired¶
| Type | object |
| Required | No |
| Additional properties | Each additional property must conform to the schema |
| Property | Type |
|---|---|
| - | array of string |
additionalProperties¶
| Type | array of string |
| Required | No |
| Default | [] |
| Each item of this array must be | Description |
|---|---|
| additionalProperties items | - |
additionalProperties items¶
| Type | string |
| Required | No |
properties¶
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
| Same definition as | properties |
dependentRequired¶
| Type | object |
| Required | No |
| Additional properties | Each additional property must conform to the schema |
| Property | Type |
|---|---|
| - | array of string |
additionalProperties¶
| Type | array of string |
| Required | No |
| Default | [] |
| Each item of this array must be | Description |
|---|---|
| additionalProperties items | - |
additionalProperties items¶
| Type | string |
| Required | No |
allOf¶
Title: Combine definition groups
| Type | array of object |
| Required | No |
| Each item of this array must be | Description |
|---|---|
| allOf items | - |
allOf items¶
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
| Property | Type |
|---|---|
| + $ref | string |
$ref¶
| Type | string |
| Required | Yes |
| Restrictions | |
|---|---|
| Must match regular expression | ^#/\$defs/[^/]+$ Test |
Generated using json-schema-for-humans