Coverage for biobb_haddock/haddock/clust_fcc.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 ClustFCC class and the command line interface."""
5from typing import Optional
6import biobb_haddock.haddock.common as common
9class ClustFCC(common.HaddockStepBase):
10 """
11 | biobb_haddock ClustFCC
12 | Wrapper class for the HADDOCK3 ClustFCC module.
13 | The ClustFCC module. `HADDOCK3 ClustFCC module <https://www.bonvinlab.org/haddock3/modules/analysis/haddock.modules.analysis.clustfcc.html>`_ computes clusters of structures using FCC.
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_clustfcc.zip>`_. Accepted formats: directory (edam:format_1915).
18 output_cluster_zip_path (str) (Optional): Path to the output PDB file collection in zip format. File type: output. `Sample file <https://raw.githubusercontent.com/bioexcel/biobb_haddock/master/biobb_haddock/test/reference/haddock/ref_clustfcc.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.clust_fcc import clust_fcc
39 prop = { 'binary_path': 'haddock' }
40 clust_fcc(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_cluster_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_cluster_zip_path": output_cluster_zip_path
78 },
79 }
80 # Properties specific for BB
81 self.haddock_step_name = "clustfcc"
82 # Handle configuration options from properties
83 self.cfg = {k: v for k, v in properties.get("cfg", dict()).items()}
84 # Global HADDOCK configuration options
85 self.global_cfg = properties.get("global_cfg", dict(postprocess=False))
86 # Properties specific for BB
87 self.binary_path = properties.get("binary_path", "haddock3")
88 # Check the properties
89 self.check_init(properties)
91 def _handle_step_output(self):
92 """Handle how the output files from the step are copied to host."""
93 if output_cluster_zip_path := self.io_dict["out"].get("output_cluster_zip_path"):
94 self.copy_step_output(
95 lambda path: str(path.name) not in ["io.json", "params.cfg"],
96 output_cluster_zip_path
97 )
100def clust_fcc(
101 input_haddock_wf_data: str,
102 output_haddock_wf_data: str,
103 output_cluster_zip_path: Optional[str] = None,
104 haddock_config_path: Optional[str] = None,
105 properties: Optional[dict] = None,
106 **kwargs,
107) -> int:
108 """Create :class:`ClustFCC <biobb_haddock.haddock.clust_fcc>` class and
109 execute the :meth:`launch() <biobb_haddock.haddock.clust_fcc.launch>` method."""
110 # Launch method inherited from HaddockStepBase
111 return ClustFCC(**dict(locals())).launch()
114clust_fcc.__doc__ = ClustFCC.__doc__
115main = ClustFCC.get_main(clust_fcc, "Wrapper of the HADDOCK3 ClustFCC module.")
118if __name__ == "__main__":
119 main()