To perform automatic validation of parameters:
- Define a
schema.yaml
detailing the necessary parameters.- For a template parameter definition, see template schema
- For an example, see example schema
- (Optional) Define any necessary custom types and approriate validation functions
- The custom schema type must define a
custom_schema_types
namespace containing a Maptypes
with keys being the type and the values being the function for validating the type. - For an example, see custom types
- The custom schema type must define a
- In
methods.config
, include theschema.config
file and call the validation functions:- (Optional) If a custom schema is defined, call
schema.load_custom_types("/path/to/custom/schema.config")
- Call
schema.validate()
, optionally with an argument pointing to theschema.yaml
file. By default,"${projectDir}/config/schema.yaml"
will be used.
- (Optional) If a custom schema is defined, call
Integer
String
- With this type, an additional definition
allow_empty
can be specified to allow an empty string as input. By default, empty strings will not be allowed.
- With this type, an additional definition
Number
List
Bool
Namespace
- a Groovy
Map
- a Groovy
Path
- With this type, an additional definition
mode
must be specified, indicating whether the associated parameter needs to be readable (mode: 'r'
) or writeable (mode: 'w'
)
- With this type, an additional definition
InputNamespace
- Validation type for a namespace specifying inputs
input: <<InputNamespace>>
BAM:
...
ListFASTQPairs
- Validation type for a list of FASTQ pair Maps
input:
FASTQ: <<ListFASTQPairs>>
- read_group_identifier: <readgroup ID>
sample: <sample ID>
...
- read_group_identifier: <readgroup ID>
sample: <sample ID>
...
InputBAMNamespace
- Validation type for a namespace containing BAMs
input:
BAM: <<InputBAMNamespace>>
normal:
- "/path/to/bam"
- "/path/to/bam"
tumor:
- "/path/to/bam"
- "/path/to/bam"
BAMEntryList
- Validation type for a list of BAMs
input:
BAM:
normal: <<BAMEntryList>>
- "/path/to/bam"
- "/path/to/bam"
tumor: <<BAMEntryList>>
- "/path/to/bam"
- "/path/to/bam"
validate
- The entrypoint function for validating the parameters- Positional args:
position name type required default description 1 file_path
String No "${projectDir}/config/schema.yaml"
Path to the schema.yaml
file
- Positional args:
load_custom_types
- Function for loading custom types- Positional args:
position name type required default description 1 custom_types_path
String Yes null
Path to config file defining custom types 2 purge_existing_custom_types
Boolean No false
Option to overwrite previously loaded custom types
- Positional args:
validate_parameter
- Function for recursively validating a parameter- Positional args:
position name type required default description 1 options
Map Yes none Map object where parameter should be defined 2 name
String Yes none Name of the parameter 3 properties
Map Yes none Map object containing the schema properties for the parameter to validate
- Positional args:
check_path
- Function for validating paths and proper permissions- Positional args:
position name type required default description 1 p
String Yes none Path to to validate 2 mode
String Yes none Permission to check, w
to check if path is writeable andr
to check if path is readable
- Positional args:
validate_specific
- Function for validating specific namespaces and schemas along with an exclusion list- Positional args:
position name type required default description 1 file_path
String or Map Yes none Path to the schema.yaml
file or loaded schema as a Map2 params_to_validate
Map Yes none Namespace of parameters to validate 3 keys_to_exclude
List No []
List of parameters to skip validation
- Positional args:
To perform validation, load custom types, if any, and call the validate
function.
Example:
includeConfig "/path/to/schema.config"
...
methods {
...
setup = {
...
schema.load_custom_types("/path/to/custom.config")
schema.validate()
}
}