Coverage for biobb_haddock/haddock/contact_map.py: 95%
22 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-03 15:55 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-03 15:55 +0000
1#!/usr/bin/env python3
3"""Module containing the HADDOCK3 ContactMap class and the command line interface."""
5from typing import Optional
6import biobb_haddock.haddock.common as common
9class ContactMap(common.HaddockStepBase):
10 """
11 | biobb_haddock ContactMap
12 | Wrapper class for the HADDOCK3 ContactMap module.
13 | The ContactMap module. `HADDOCK3 ContactMap module <https://www.bonvinlab.org/haddock3/modules/analysis/haddock.modules.analysis.contactmap.html>`_ computes contacts between chains in complexes and generates heatmaps and chordcharts.
15 Args:
16 input_haddock_wf_data (dir): Path to the input directory containing all the current Haddock workflow data. File type: input. `Sample file <https://github.com/bioexcel/biobb_haddock/raw/master/biobb_haddock/test/data/haddock/haddock_wf_data_rigid.zip>`_. Accepted formats: directory (edam:format_1915).
17 output_haddock_wf_data (dir): Path to the output directory 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 output_contactmap_zip_path (str) (Optional): Path to the output contact map files in zip format. File type: output. `Sample file <https://raw.githubusercontent.com/bioexcel/biobb_haddock/master/biobb_haddock/test/reference/haddock/ref_contactmap.zip>`_. Accepted formats: zip (edam:format_3987).
19 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).
20 properties (dict - Python dictionary object containing the tool parameters, not input/output files):
21 * **cfg** (*dict*) - ({}) Haddock configuration options specification.
22 * **global_cfg** (*dict*) - ({"postprocess": False}) `Global configuration options <https://www.bonvinlab.org/haddock3-user-manual/global_parameters.html>`_ specification.
23 * **binary_path** (*str*) - ("haddock") Path to the haddock haddock executable binary.
24 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
25 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
26 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
27 * **container_path** (*str*) - (None) Path to the binary executable of your container.
28 * **container_image** (*str*) - (None) Container Image identifier.
29 * **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
30 * **container_working_dir** (*str*) - (None) Path to the internal CWD in the container.
31 * **container_user_id** (*str*) - (None) User number id to be mapped inside the container.
32 * **container_shell_path** (*str*) - ("/bin/bash") Path to the binary executable of the container shell.
35 Examples:
36 This is a use example of how to use the building block from Python::
38 from biobb_haddock.haddock.contact_map import contact_map
39 prop = { 'binary_path': 'haddock' }
40 contact_map(input_haddock_wf_data='/path/to/myInputData',
41 output_haddock_wf_data='/path/to/myOutputData',
42 properties=prop)
44 Info:
45 * wrapped_software:
46 * name: HADDOCK3
47 * version: 2025.5
48 * license: Apache-2.0
49 * ontology:
50 * name: EDAM
51 * schema: http://edamontology.org/EDAM.owl
52 """
54 def __init__(
55 self,
56 input_haddock_wf_data: str,
57 output_haddock_wf_data: str,
58 output_contactmap_zip_path: Optional[str] = None,
59 haddock_config_path: Optional[str] = None,
60 properties: Optional[dict] = None,
61 **kwargs,
62 ) -> None:
63 properties = properties or {}
65 # Call parent class constructor
66 super().__init__(properties)
67 self.locals_var_dict = locals().copy()
69 # Input/Output files
70 self.io_dict = {
71 "in": {
72 "input_haddock_wf_data": input_haddock_wf_data,
73 "haddock_config_path": haddock_config_path,
74 },
75 "out": {
76 "output_haddock_wf_data": output_haddock_wf_data,
77 "output_contactmap_zip_path": output_contactmap_zip_path,
78 },
79 }
81 # Properties specific for BB
82 self.haddock_step_name = "contactmap"
83 # Handle configuration options from properties
84 self.cfg = {k: v for k, v in properties.get("cfg", dict()).items()}
85 # Global HADDOCK configuration options
86 self.global_cfg = properties.get("global_cfg", dict(postprocess=False))
87 # Properties specific for BB
88 self.binary_path = properties.get("binary_path", "haddock3")
89 # Check the properties
90 self.check_init(properties)
92 def _handle_step_output(self):
93 """Handle how the output files from the step are copied to host."""
94 if output_contactmap_zip_path := self.io_dict["out"].get("output_contactmap_zip_path"):
95 self.copy_step_output(
96 lambda path: str(path).endswith((".html", ".tsv")),
97 output_contactmap_zip_path
98 )
101def contact_map(
102 input_haddock_wf_data: str,
103 output_haddock_wf_data: str,
104 output_contactmap_zip_path: Optional[str] = None,
105 haddock_config_path: Optional[str] = None,
106 properties: Optional[dict] = None,
107 **kwargs,
108) -> int:
109 """Create :class:`ContactMap <biobb_haddock.haddock.contact_map>` class and
110 execute the :meth:`launch() <biobb_haddock.haddock.contact_map.launch>` method."""
111 # Launch method inherited from HaddockStepBase
112 return ContactMap(**dict(locals())).launch()
115contact_map.__doc__ = ContactMap.__doc__
116main = ContactMap.get_main(contact_map, "Wrapper of the HADDOCK3 ContactMap module.")
119if __name__ == "__main__":
120 main()