Coverage for biobb_haddock/haddock/haddock3_extend.py: 95%

19 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-03 15:55 +0000

1#!/usr/bin/env python3 

2 

3"""Module containing the haddock3 run class and the command line interface.""" 

4 

5from typing import Optional 

6import biobb_haddock.haddock.common as common 

7 

8 

9class Haddock3Extend(common.HaddockStepBase): 

10 """ 

11 | biobb_haddock Haddock3Extend 

12 | Wrapper class for the HADDOCK3 extend module. 

13 | The `HADDOCK3 extend <https://www.bonvinlab.org/haddock3/tutorials/continuing_runs.html>`_. module continues the HADDOCK3 execution for docking of an already started run. 

14 

15 Args: 

16 input_haddock_wf_data (dir): Path to the input zipball containing all the current Haddock workflow data. File type: output. `Sample file <https://github.com/bioexcel/biobb_haddock/raw/master/biobb_haddock/test/reference/haddock/ref_topology.zip>`_. Accepted formats: zip (edam:format_3987). 

17 haddock_config_path (str): Haddock configuration CFG file path. File type: input. `Sample file <https://raw.githubusercontent.com/bioexcel/biobb_haddock/master/biobb_haddock/test/data/haddock/run.cfg>`_. Accepted formats: cfg (edam:format_1476). 

18 output_haddock_wf_data (dir): Path to the output zipball containing all the current Haddock workflow data. File type: output. `Sample file <https://github.com/bioexcel/biobb_haddock/raw/master/biobb_haddock/test/reference/haddock/ref_topology.zip>`_. Accepted formats: zip (edam:format_3987). 

19 properties (dict - Python dictionary object containing the tool parameters, not input/output files): 

20 * **cfg** (*dict*) - ({}) Haddock configuration options specification. 

21 * **global_cfg** (*dict*) - ({"postprocess": True}) `Global configuration options <https://www.bonvinlab.org/haddock3-user-manual/global_parameters.html>`_ specification. 

22 * **binary_path** (*str*) - ("haddock") Path to the haddock haddock executable binary. 

23 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files. 

24 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist. 

25 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory. 

26 * **container_path** (*str*) - (None) Path to the binary executable of your container. 

27 * **container_image** (*str*) - (None) Container Image identifier. 

28 * **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container. 

29 * **container_working_dir** (*str*) - (None) Path to the internal CWD in the container. 

30 * **container_user_id** (*str*) - (None) User number id to be mapped inside the container. 

31 * **container_shell_path** (*str*) - ("/bin/bash") Path to the binary executable of the container shell. 

32 

33 

34 Examples: 

35 This is a use example of how to use the building block from Python:: 

36 

37 from biobb_haddock.haddock.haddock3_extend import haddock3_extend 

38 haddock3_extend(input_haddock_wf_data='/path/to/myworkflowdata.zip', 

39 haddock_config_path='/path/to/myHaddockConfig.cfg', 

40 output_haddock_wf_data='/path/to/haddock_output.zip', 

41 properties=prop) 

42 

43 Info: 

44 * wrapped_software: 

45 * name: HADDOCK3 

46 * version: 2025.5 

47 * license: Apache-2.0 

48 * ontology: 

49 * name: EDAM 

50 * schema: http://edamontology.org/EDAM.owl 

51 """ 

52 

53 def __init__( 

54 self, 

55 input_haddock_wf_data: str, 

56 haddock_config_path: str, 

57 output_haddock_wf_data: str, 

58 properties: Optional[dict] = None, 

59 **kwargs, 

60 ) -> None: 

61 properties = properties or {} 

62 

63 # Call parent class constructor 

64 super().__init__(properties) 

65 self.locals_var_dict = locals().copy() 

66 

67 # Input/Output files 

68 self.io_dict = { 

69 "in": { 

70 "input_haddock_wf_data": input_haddock_wf_data, 

71 "haddock_config_path": haddock_config_path, 

72 }, 

73 "out": { 

74 "output_haddock_wf_data": output_haddock_wf_data, 

75 }, 

76 } 

77 

78 # Properties specific for BB 

79 self.haddock_step_name = "haddock3_extend" 

80 # Handle configuration options from properties 

81 self.cfg = {k: v for k, v in properties.get("cfg", dict()).items()} 

82 # Global HADDOCK configuration options 

83 self.global_cfg = properties.get("global_cfg", dict(postprocess=True)) 

84 # Properties specific for BB 

85 self.binary_path = properties.get("binary_path", "haddock3") 

86 # Check the properties 

87 self.check_init(properties) 

88 

89 

90def haddock3_extend( 

91 input_haddock_wf_data: str, 

92 haddock_config_path: str, 

93 output_haddock_wf_data: str, 

94 properties: Optional[dict] = None, 

95 **kwargs, 

96) -> int: 

97 """Create :class:`Haddock3Extend <biobb_haddock.haddock.haddock3_extend>` class and 

98 execute the :meth:`launch() <biobb_haddock.haddock.haddock3_extend.launch>` method.""" 

99 # Launch method inherited from HaddockStepBase 

100 return Haddock3Extend(**dict(locals())).launch() 

101 

102 

103haddock3_extend.__doc__ = Haddock3Extend.__doc__ 

104main = Haddock3Extend.get_main(haddock3_extend, "Wrapper of the HADDOCK3 Haddock3Extend module.") 

105 

106 

107if __name__ == "__main__": 

108 main()