Prepare run
Logic pertraining to preparing the run files and folders.
- haddock.gear.prepare_run.check_if_modules_are_installed(params: MutableMapping[str, Any]) None [source]
Validate if third party-libraries are installed.
- haddock.gear.prepare_run.check_if_path_exists(path: str | Path) None [source]
Check if a path exists and raises an error if it does not exist.
For example given this path “../config/project_01/file.txt” it would find the following path “../config/project-01”.
- Parameters:
path (AnyStr | PathLike) – The path to check.
- Returns:
None – If the path does exist.
- Raises:
ValueError – If the path does not exist.
- haddock.gear.prepare_run.check_mandatory_argments_are_present(params: Iterable[str]) None [source]
Confirm order key exists in config.
- haddock.gear.prepare_run.check_run_dir_exists(run_dir: str | Path) None [source]
Check whether the run directory exists.
- haddock.gear.prepare_run.check_specific_validations(params: MutableMapping[str, Any]) None [source]
Make specific validations.
- haddock.gear.prepare_run.config_key_error() Generator[None, None, None] [source]
Raise ConfigurationError on KeyError.
- haddock.gear.prepare_run.copy_input_files_to_data_dir(data_dir: Path, modules_params: MutableMapping[str, Any], start: int = 0) None [source]
Copy input files to data directory.
- Parameters:
data_dir (Path) – The data/ directory inside the run directory. Must contain reference to the run directory.
modules_params (dict) – A dictionary with the parameters of the modules. The paths to data in the dictionary are updated to the new paths copied to the data/ folder.
start (int, default to 0) – The starting number of the step folders prefix.
- haddock.gear.prepare_run.copy_molecules_to_data_dir(data_dir: Path, topoaa_params: MutableMapping[str, Any], preprocess: bool = True) None [source]
Copy molecules to data directory and to topoaa parameters.
- Parameters:
data_dir (Path) – The data/ directory inside the run directory. Must contain reference to the run directory.
topoaa_params (dict) – A dictionary containing the topoaa parameters.
preprocess (bool) – Whether to preprocess input molecules. Defaults to
True
. Seehaddock.gear.preprocessing
.
- haddock.gear.prepare_run.copy_molecules_to_topology(molecules: Iterable[str], topoaa_params: MutableMapping[str, Any]) None [source]
Copy molecules to mandatory topology module.
- haddock.gear.prepare_run.create_data_dir(run_dir: str | Path) Path [source]
Create initial files for HADDOCK3 run.
- Returns:
pathlib.Path – A path referring only to ‘data’.
- haddock.gear.prepare_run.fuzzy_match(user_input: Iterable[str], possibilities: Iterable[str]) list[tuple[str, str]] [source]
Find the closest possibility to the user supplied input.
- Parameters:
user_input (list(string)) – List of strings with the faulty input given by the user.
possibilities (list(string)) – List of strings with all possible options that would be valid in this context.
- Returns:
list(string, string) – The closest string from the possibilities to each string of the user_input. With as first element of the tuple the user_input string, and as second element the matched possibility.
- haddock.gear.prepare_run.gen_defaults_module_param_path(module_name_: str) Path [source]
Build path to default parameters of a module.
- Parameters:
module_name_ (str) – Name of the module
- Returns:
Path – Path to the module YAML defaults parameter.
- haddock.gear.prepare_run.get_expandable_parameters(user_config: MutableMapping[str, Any], defaults: MutableMapping[str, Any], module_name: str, max_mols: int) set[str] [source]
Get configuration expandable blocks.
- Parameters:
user_config (dict) – The user configuration file for a module.
defaults (dict) – The default configuration file defined for the module.
module_name (str) – The name the module being processed.
max_mols (int) – The max number of molecules allowed.
- haddock.gear.prepare_run.identify_modules(params: Iterable[str]) list[str] [source]
Identify keys (headings) belonging to HADDOCK3 modules.
- haddock.gear.prepare_run.inject_in_modules(modules_params: MutableMapping[str, Any], key: Any, value: Any) None [source]
Inject a parameter in each module.
- haddock.gear.prepare_run.populate_mol_parameters(modules_params: MutableMapping[str, Any]) None [source]
Populate modules subdictionaries with the needed molecule mol_ parameters.
The mol_ prefixed parameters is a subclass of the expandable parameters.
See gear.expandable_parameters.
Modules require these parameters to be repeated for the number of input molecules.
This function adds mol_ parameters to the user input parameters, one per each molecule.
- Parameters:
modules_params (dict) – A dictionary containing only modules’ keys:subdictionaries parameters. That is, without the general parameters.
- Returns:
None – Alter the dictionary in place.
- haddock.gear.prepare_run.populate_topology_molecule_params(topoaa: MutableMapping[str, Any]) None [source]
Populate topoaa molX subdictionaries.
- haddock.gear.prepare_run.save_configuration_files(configs: dict, datadir: str | Path) dict [source]
Write a copy of configuration files (GitHub issue #578).
- Parameters:
configs (dict) – Dictionnary holding the various configuration files [‘raw_input, ‘cleaned_input’, ‘loaded_cleaned_input’, ‘final_cfg’, ‘enhanced_haddock_params’]
datadir (str or
libpath.Path
) – Directory where to write the configuration.
- Returns:
added_files (dict) – Dictionary of paths leading to saved configuration files.
- haddock.gear.prepare_run.setup_run(workflow_path: str | Path, restart_from: int | None = None, extend_run: str | Path | None = None) tuple[dict[str, Any], dict[str, Any]] [source]
Set up an HADDOCK3 run.
This function sets up a HADDOCK3 considering the options –restart and –extend-run. The list of actions presented below does not necessary represents the exact order in which it happens.
Always performed:
read the user configuration file
completes the user configuration file with the default values for the non-specified parameters
validate the config file * confirm modules’ names are correctly spelled * check if requested modules are installed * check additional validations
validate modules’ parameters
copy input files to data/ directory * for
--restart
copies only after the restart number
Performed when
--restart
:remove folders after –restart number
remove also folders from data/ dir after the
--restart
numrenumber step folders according to the number of modules
Performed when
--extend-run
:renumber step folders according to the number of modules
Performed when start from scratch:
check mandatory arguments are present in the config file
check run-dir exists
copy molecules to topology key (also in
--restart
)populate topology parameters (also in
--restart
)copy molecules to data dir
- Parameters:
workflow_path (str or pathlib.Path) – The path to the configuration file.
restart_from (int) – The step to restart the run from (inclusive). Defaults to None, which ignores this option.
extend_run (str or Path) – The path created with haddock3-copy to start the run from. Defaults to None, which ignores this option.
- Returns:
tuple of two dicts – A dictionary with the parameters for the haddock3 modules. A dictionary with the general run parameters.
- haddock.gear.prepare_run.update_step_contents_to_step_names(prev_names: Iterable[str], new_names: Iterable[str], folder: str | Path) None [source]
Update step folder names in files after the –restart option.
Runs over the folders defined in new_names.
- Parameters:
prev_names (list) – List of step names to find in file contents.
new_names (list) – List of new step names to replace prev_names. Both lists need to be synchronized. That is, the first index of prev_names should correspond to the old names of new_names.
folder (str or Path) – Folder where the step folders are. Usually run directory or data directory.
- Returns:
None – Save files in place.
- haddock.gear.prepare_run.update_step_names_in_file(file_: Path, prev_names: Iterable[str], new_names: Iterable[str]) None [source]
Update step names in file following the –restart option.
- haddock.gear.prepare_run.update_step_names_in_subfolders(folder: Path, prev_names: Iterable[str], new_names: Iterable[str]) None [source]
Update step names in subfolders.
Some modules may generate subfolders. This function update its files accordingly to the –restart feature.
- haddock.gear.prepare_run.validate_module_names_are_not_misspelled(params: MutableMapping[str, Any]) None [source]
Validate module names are not misspelled in step definitions.
- Parameters:
params (dict) – The user configuration file.
- haddock.gear.prepare_run.validate_module_params_values(module_name: str, args: dict) None [source]
Validate individual parameters for a module.
- Parameters:
module_name – Name of the module to be analyzed
args (dict) – Dictionnary of key/value present in user config file for a module
- Raises:
ConfigError – If there is any parameter given by the user that is not following the types or ranges/choices allowed in the defaults.cfg of the module.
- haddock.gear.prepare_run.validate_modules_names(params: Iterable[str]) None [source]
Validate all modules names are spelled correctly.
- haddock.gear.prepare_run.validate_modules_params(modules_params: MutableMapping[str, Any], max_mols: int) None [source]
Validate individual parameters for each module.
- Raises:
ConfigError – If there is any parameter given by the user that is not defined in the defaults.cfg of the module.
- haddock.gear.prepare_run.validate_ncs_params(params: dict) None [source]
Validate Non-Crystallographic Symmetry parameters.
This is a particular case where: - ncs_sta1_X == ncs_sta2_X - ncs_end1_X == ncs_end2_X - ncs_seg1_X != ncs_seg2_X
- Parameters:
params (dict) – Dictionary of key/value present in user config file for a module
- Raises:
ConfigurationError – Issue detected when validating NCS parameters.
- haddock.gear.prepare_run.validate_param_range(param: dict, val: Any) str | None [source]
Check if provided value is in range/choices defined for this parameter.
- Parameters:
param (dict) – Dictionnary of key/value present in user config file for a module
val ([bool, int, float, str, list]) – The provided value for a parameter
- Returns:
May return a string explaining the issue with the provided value range
- haddock.gear.prepare_run.validate_param_type(param: dict, val: Any) str | None [source]
Check if provided parameter type is similar to defined defaults ones.
- Parameters:
param (dict) – Dictionnary of key/value present in user config file for a module
val ([bool, int, float, str, list]) – The provided value for a parameter
- Returns:
May return a string explaining the issue with the provided value type
- haddock.gear.prepare_run.validate_parameters_are_not_incompatible(params: MutableMapping[str, Any], incompatible_params: MutableMapping[str, Any]) None [source]
Validate parameters are not incompatible.
- Parameters:
params (ParamMap) – A mapping of parameter names to their values.
- Raises:
ValueError – If any parameter in params is incompatible with another parameter as defined by incompatible_params.
- haddock.gear.prepare_run.validate_parameters_are_not_misspelled(params: Iterable[str], reference_parameters: Iterable[str]) None [source]
Validate general parameters are not misspelled.
- haddock.gear.prepare_run.validate_params(params)[source]
Validate the parameter file.
#1 : checks for mandatory parameters #2 : checks for correct modules
- haddock.gear.prepare_run.validate_value(default_yaml: dict, key: str, value: Any) None [source]
Validate queried value for a specific parameter of a module.
- Parameters:
default_yaml (dict) – Dictionnary of key/value present in user config file for a module
key (str) – Key to be analyzed
value ([bool, int, float, str, list]) – The provided value for a parameter
- Raises:
ConfigError – If there is any parameter given by the user that is not following the types or ranges/choices allowed in the defaults.cfg of the module.