Modules
HADDOCK3 allows users to compose modular simulation workflows. Workflows are composed in steps, and each step is a HADDOCK3 module. There are modules for sampling, refinement, analysis, etc.
Parent code for modules
HADDOCK3 modules.
- class haddock.modules.BaseHaddockModule(order: int, path: Path, params_fname: str | Path)[source]
Bases:
ABC
HADDOCK3 module’s base class.
- abstract classmethod confirm_installation() None [source]
Confirm the third-party software needed for the module is installed.
HADDOCK3’s own modules should just return.
- export_io_models(faulty_tolerance: float = 0.0) None [source]
Export input/output to the ModuleIO interface.
- Modules that do not perform any operation on PDB files should have
input = output.
This function implements a common interface for all modules.
- Parameters:
faulty_tolerance (int, default 0) – The percentage of missing output allowed. If 20 is given, raises an error if 20% of the expected output is missing (not saved to disk).
- log(msg: str, level: str = 'info') None [source]
Log a message with a common header.
Currently the header is the [MODULE NAME] in square brackets.
- Parameters:
msg (str) – The log message.
level (str) – The level log: ‘debug’, ‘info’, … Defaults to ‘info’.
- update_params(update_from_cfg_file: str | Path | None = None, **params: Any) None [source]
Update the modules parameters.
Add/update to the current modules parameters the ones given in the function call. If you want to enterily replace the modules parameters to their default values use the reset_params() method.
Update takes places recursively, that is, nested dictionaries will be updated accordingly.
To update the current config with the parameters defined in an HADDOCK3 configuration file use the update_from_cfg_file parameter.
To update from a JSON file, first load the JSON into a dictionary and unpack the dictionary to the function call.
Examples
>>> m.update_params(param1=value1, param2=value2)
>>> m.update_params(**param_dict)
>>> m.update_params(update_from_cfg_file=path_to_file)
# if you wish to start from scratch >>> m.reset_params() >>> m.update_params(…)
- haddock.modules.get_engine(mode: str, params: dict[Any, Any]) partial[HPCScheduler | Scheduler | MPIScheduler] [source]
Create an engine to run the jobs.
- Parameters:
mode (str) – The type of engine to create
params (dict) – A dictionary containing parameters for the engine. get_engine will retrieve from params only those parameters needed and ignore the others.
- haddock.modules.get_module_steps_folders(folder: str | Path, modules: Container[int] | None = None) list[str] [source]
Return a sorted list of the step folders in a running directory.
Example
Consider the folder structure:
- run_dir/
0_topoaa/ 1_rigidbody/ 2_caprieval/ 3_bad_module_name/ data/
>>> get_module_steps_folders("run_dir") >>> ["0_topoaa", "1_rigidbody", "2_caprieval"]
- Parameters:
folder (str or Path) – Path to the run directory, or to the folder containing the step folders.
- Returns:
list of str – List containing strings with the names of the step folders.
- haddock.modules.is_step_folder(path: str | Path) bool [source]
Assess whether a folder is a possible step folder.
The folder is considered a step folder if has a zero or positive integer index followed by a name of a module.
- Parameters:
path (str or pathlib.Path) – The path to the folder.
- Returns:
bool – Whether the folder is a step folder or not.
- haddock.modules.modules_category = {'alascan': 'analysis', 'caprieval': 'analysis', 'clustfcc': 'analysis', 'clustrmsd': 'analysis', 'contactmap': 'analysis', 'emref': 'refinement', 'emscoring': 'scoring', 'exit': 'extras', 'flexref': 'refinement', 'gdock': 'sampling', 'ilrmsdmatrix': 'analysis', 'lightdock': 'sampling', 'mdref': 'refinement', 'mdscoring': 'scoring', 'openmm': 'refinement', 'rigidbody': 'sampling', 'rmsdmatrix': 'analysis', 'sasascore': 'scoring', 'seletop': 'analysis', 'seletopclusts': 'analysis', 'topoaa': 'topology', 'topocg': 'topology'}
Indexes each module in its specific category. Keys are Paths to the module, values are their categories. Categories are the modules parent folders.
- haddock.modules.step_folder_regex = '([0-9]+_topoaa|[0-9]+_topocg|[0-9]+_mdscoring|[0-9]+_sasascore|[0-9]+_emscoring|[0-9]+_gdock|[0-9]+_rigidbody|[0-9]+_lightdock|[0-9]+_mdref|[0-9]+_emref|[0-9]+_flexref|[0-9]+_openmm|[0-9]+_exit|[0-9]+_rmsdmatrix|[0-9]+_ilrmsdmatrix|[0-9]+_caprieval|[0-9]+_contactmap|[0-9]+_clustfcc|[0-9]+_seletopclusts|[0-9]+_alascan|[0-9]+_seletop|[0-9]+_clustrmsd)'
String for regular expression to match module folders in a run directory.
It will match folders with a numeric prefix followed by underscore (“_”) followed by the name of a module.
Example: https://regex101.com/r/roHls9/1
- haddock.modules.step_folder_regex_re = re.compile('([0-9]+_topoaa|[0-9]+_topocg|[0-9]+_mdscoring|[0-9]+_sasascore|[0-9]+_emscoring|[0-9]+_gdock|[0-9]+_rigidbody|[0-9]+_lightdock|[0-9]+_mdref|[0-9]+_emref|[0-9]+_flexref|[0-9]+_openmm|[0-9]+_exit|[0-9])
Compiled regular expression from
step_folder_regex
.It will match folders with a numeric prefix followed by underscore (“_”) followed by the name of a module.
Example: https://regex101.com/r/roHls9/1
Parent code for CNS modules
Functionalities related to CNS modules.
- class haddock.modules.base_cns_module.BaseCNSModule(order: int, path: Path, initial_params: str | Path, cns_script: str | Path)[source]
Bases:
BaseHaddockModule
Operation module for CNS.
Contains additional functionalities excusive for CNS modules.
- abstract classmethod confirm_installation() None
Confirm the third-party software needed for the module is installed.
HADDOCK3’s own modules should just return.
- export_io_models(faulty_tolerance: float = 0.0) None
Export input/output to the ModuleIO interface.
- Modules that do not perform any operation on PDB files should have
input = output.
This function implements a common interface for all modules.
- Parameters:
faulty_tolerance (int, default 0) – The percentage of missing output allowed. If 20 is given, raises an error if 20% of the expected output is missing (not saved to disk).
- get_ambig_fnames(prev_ambig_fnames: list[None | str | Path]) list[str | Path] | None [source]
Get the correct ambiguous restraint names.
- Parameters:
prev_ambig_fnames (list) – list of ambig_fname files encoded in previous models
- Returns:
ambig_fnames (list or None) – list of ambig_fname files to be used by the CNS module
- static last_step_folder(folders, index)
Retrieve last step folder.
- log(msg: str, level: str = 'info') None
Log a message with a common header.
Currently the header is the [MODULE NAME] in square brackets.
- Parameters:
msg (str) – The log message.
level (str) – The level log: ‘debug’, ‘info’, … Defaults to ‘info’.
- save_envvars(filename: str | Path = 'envvars') None [source]
Save envvars needed for CNS to a file in the module’s folder.
- update_params(update_from_cfg_file: str | Path | None = None, **params: Any) None
Update the modules parameters.
Add/update to the current modules parameters the ones given in the function call. If you want to enterily replace the modules parameters to their default values use the reset_params() method.
Update takes places recursively, that is, nested dictionaries will be updated accordingly.
To update the current config with the parameters defined in an HADDOCK3 configuration file use the update_from_cfg_file parameter.
To update from a JSON file, first load the JSON into a dictionary and unpack the dictionary to the function call.
Examples
>>> m.update_params(param1=value1, param2=value2)
>>> m.update_params(**param_dict)
>>> m.update_params(update_from_cfg_file=path_to_file)
# if you wish to start from scratch >>> m.reset_params() >>> m.update_params(…)
General Default parameters
General default parameters can be defined in the main section of the configuration file, but can also be defined for each individual module (step). In the later case, overriding the general definition.