YAML configs

Parse data from HADDOCK3 to YAML and YAML to HADDOCK3 and related.

Accross this file you will see references to “yaml” as variables and function names. In these cases, we always mean the HADDOCK3 YAML configuration files which have specific keys.

haddock.gear.yaml2cfg.find_incompatible_parameters(yaml_file: Path) dict[str, dict[str, Any]][source]

Reads a YAML configuration file and identifies nodes containing the ‘incompatible’ key.

This function takes the path to a YAML file, reads its contents, and searches for nodes that include an ‘incompatible’ key. It returns a dictionary where each key is a node name and each value is another dictionary representing the ‘incompatible’ parameters for that node.

Parameters:

yaml_file (Path) – The path to the YAML file to be read.

Returns:

incompatible_parameters (dict[str, dict[str, str]]) – A dictionary with node names as keys and their corresponding ‘incompatible’ parameters as values.

haddock.gear.yaml2cfg.flat_yaml_cfg(cfg: MutableMapping[str, Any]) dict[str, Any][source]

Flat a yaml config.

haddock.gear.yaml2cfg.read_from_yaml_config(cfg_file: Path | str, default_only: bool = True) dict[source]

Read config from yaml by collapsing the expert levels.

Parameters:
  • cfg_file – Path to a .yaml configuration file

  • default_only (bool) – Set the return value of this function; if True (default value), only returns default values, else return the fully loaded configuration file

Returns:

  • ycfg (dict) – The full default configuration file as a dict

  • OR

  • cfg (dict) – A dictionary containing only the default parameters values

haddock.gear.yaml2cfg.yaml2cfg_text(ymlcfg: dict, module: str, explevel: str, details: bool = False, mandatory_param: bool = False) str[source]

Convert HADDOCK3 YAML config to HADDOCK3 user config text.

Adds commentaries with help strings.

Parameters:
  • ymlcfg (dict) – The dictionary representing the HADDOCK3 config file.

  • module (str) – The module to which the config belongs to.

  • explevel (str) – The expert level to consider. Provides all parameters for that level and those of inferior hierarchy. If you give “all”, all parameters will be considered.

  • details (bool) – Whether to add the ‘long’ description of each parameter.

  • mandatory_param (bool) – Whether this current parameters are mandatory ones. Special case where this must be set as they do not contain default value, therefore the downstream functions are not valid anymore.

Returns:

textual_config (str) – Textual representation of a YAML configuration file.