OpenMS
ParamCWLFile Class Reference

Load from JSON (in a Common Workflow Language (CWL) compatible way) into the Param class. More...

#include <OpenMS/FORMAT/ParamCWLFile.h>

Static Public Member Functions

static bool load (const std::string &filename, Param &param)
 Read JSON file that is formatted in CWL conforming style. More...
 

Detailed Description

Load from JSON (in a Common Workflow Language (CWL) compatible way) into the Param class.

The JSON file must contain one top level mapping of param value names to actual values. These values can be one of the following types:

  • null
  • boolean
  • int
  • long
  • float
  • double
  • string
  • a CWL style file path ({ "class": "File", "path": "./myFolder/myFile.txt" })
  • an array of these

param value names match the command line option without the leading '-'. Optionally the ':' can be replaced with a double underscore "__".

{
"in": {
"class": "File",
"path": "./myFolder/myFile.txt"
},
"out_prefix": "test_cwl_",
"algorithm:threshold": 5,
"algorithm:score_type": "ID"
}

Same file with "__" instead of ':' as the section separator.

{
"in": {
"class": "File",
"path": "./myFolder/myFile.txt"
},
"out_prefix": "test_cwl_",
"algorithm__threshold": 5,
"algorithm__score_type": "ID"
}

Member Function Documentation

◆ load()

static bool load ( const std::string &  filename,
Param param 
)
static

Read JSON file that is formatted in CWL conforming style.

Parameters
filenameThe file from where to read the Param object.
paramA param object with pre-filled defaults, which are updated by the values in the JSON file
Returns
returns true if file was successfully loaded; false if an unknown (non-default) parameter name was encountered in the JSON file
Exceptions
Exception::FileNotFoundis thrown if the file could not be found
Exception::ParseErroris thrown if an error occurs during parsing