haddock.modules package

Subpackages

Submodules

Module contents

HADDOCK3 modules.

class haddock.modules.BaseHaddockModule(order: int, path: Path, params_fname: str | Path)[source]

Bases: ABC

HADDOCK3 module’s base class.

add_parent_to_paths() None[source]

Add parent path to paths.

clean_output() None[source]

Clean module output folder.

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=0)[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).

finish_with_error(reason: object = 'Module has failed.') None[source]

Finish with error message.

static last_step_folder(folders, index)[source]

Retrieve last step folder.

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’.

name: str
property params: dict[str, Any]

Configuration parameters.

previous_path() Path[source]

Give the path from the previous calculation.

reset_params() None[source]

Reset parameters to the ones used to instantiate the class.

run(**params: Any) None[source]

Execute the module.

save_config(path: str | Path) None[source]

Save current parameters to a HADDOCK3 config file.

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', 'rigidbody': 'sampling', 'rmsdmatrix': 'analysis', '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]+_mdscoring|[0-9]+_emscoring|[0-9]+_topoaa|[0-9]+_topocg|[0-9]+_rigidbody|[0-9]+_lightdock|[0-9]+_gdock|[0-9]+_clustfcc|[0-9]+_rmsdmatrix|[0-9]+_clustrmsd|[0-9]+_seletopclusts|[0-9]+_alascan|[0-9]+_caprieval|[0-9]+_seletop|[0-9]+_contactmap|[0-9]+_ilrmsdmatrix|[0-9]+_mdref|[0-9]+_emref|[0-9]+_flexref|[0-9]+_exit)'

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]+_mdscoring|[0-9]+_emscoring|[0-9]+_topoaa|[0-9]+_topocg|[0-9]+_rigidbody|[0-9]+_lightdock|[0-9]+_gdock|[0-9]+_clustfcc|[0-9]+_rmsdmatrix|[0-9]+_clustrmsd|[0-9]+_seletopclusts|[0-9]+_alascan|[0)

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