Coverage for biobb_haddock/haddock/haddock3_run.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 Haddock3Run(common.HaddockStepBase): 

10 """ 

11 | biobb_haddock Haddock3Run 

12 | Wrapper class for the HADDOCK3 Run module. 

13 | The HADDOCK3 run module launches the HADDOCK3 execution for docking. 

14 

15 Args: 

16 input_haddock_wf_data (dir): Input folder containing all the files defined in the config. File type: input. `Sample folder <https://github.com/bioexcel/biobb_haddock/tree/master/biobb_haddock/test/data/haddock/input_haddock_wf_data>`_. Accepted formats: directory (edam:format_1915). 

17 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/data/haddock/haddock_wf_data_emref.zip>`_. Accepted formats: directory (edam:format_1915). 

18 haddock_config_path (str) (Optional): 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). 

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

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

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

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

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

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

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

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

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

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

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

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

31 

32 

33 Examples: 

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

35 

36 from biobb_haddock.haddock.haddock3_run import haddock3_run 

37 haddock3_run(input_haddock_wf_data='/path/to/myInputData', 

38 output_haddock_wf_data='/path/to/myOutputData', 

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

40 properties=prop) 

41 

42 Info: 

43 * wrapped_software: 

44 * name: HADDOCK3 

45 * version: 2025.5 

46 * license: Apache-2.0 

47 * ontology: 

48 * name: EDAM 

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

50 """ 

51 

52 def __init__( 

53 self, 

54 input_haddock_wf_data: str, 

55 output_haddock_wf_data: str, 

56 haddock_config_path: Optional[str] = None, 

57 properties: Optional[dict] = None, 

58 **kwargs, 

59 ) -> None: 

60 properties = properties or {} 

61 

62 # Call parent class constructor 

63 super().__init__(properties) 

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

65 

66 # Input/Output files 

67 self.io_dict = { 

68 "in": { 

69 "input_haddock_wf_data": input_haddock_wf_data, 

70 "haddock_config_path": haddock_config_path, 

71 }, 

72 "out": { 

73 "output_haddock_wf_data": output_haddock_wf_data, 

74 }, 

75 } 

76 

77 # Properties specific for HADDOCK Step 

78 self.haddock_step_name = "haddock3_run" 

79 # Handle configuration options from properties 

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

81 # Global HADDOCK configuration options 

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

83 # Properties specific for BB 

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

85 # Check the properties 

86 self.check_init(properties) 

87 

88 

89def haddock3_run( 

90 input_haddock_wf_data: str, 

91 output_haddock_wf_data: str, 

92 haddock_config_path: Optional[str] = None, 

93 properties: Optional[dict] = None, 

94 **kwargs, 

95) -> int: 

96 """Create :class:`Haddock3Run <biobb_haddock.haddock.haddock3_run>` class and 

97 execute the :meth:`launch() <biobb_haddock.haddock.haddock3_run.launch>` method.""" 

98 # Launch method inherited from HaddockStepBase 

99 return Haddock3Run(**dict(locals())).launch() 

100 

101 

102haddock3_run.__doc__ = Haddock3Run.__doc__ 

103main = Haddock3Run.get_main(haddock3_run, "Wrapper of the HADDOCK3 Haddock3Run module.") 

104 

105 

106if __name__ == "__main__": 

107 main()