Coverage for biobb_model / model / fix_ssbonds.py: 88%
33 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-22 13:18 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-22 13:18 +0000
1#!/usr/bin/env python3
3"""Module containing the FixSSBonds class and the command line interface."""
5from typing import Optional
7from biobb_common.generic.biobb_object import BiobbObject
8from biobb_common.tools.file_utils import launchlogger
11class FixSSBonds(BiobbObject):
12 """
13 | biobb_model FixSSBonds
14 | Fix SS bonds from residues.
15 | Fix the SS bonds in a PDB structure.
17 Args:
18 input_pdb_path (str): Input PDB file path. File type: input. `Sample file <https://github.com/bioexcel/biobb_model/raw/master/biobb_model/test/data/model/1aki.pdb>`_. Accepted formats: pdb (edam:format_1476).
19 output_pdb_path (str): Output PDB file path. File type: output. `Sample file <https://raw.githubusercontent.com/bioexcel/biobb_model/master/biobb_model/test/reference/model/output_ssbonds.pdb>`_. Accepted formats: pdb (edam:format_1476).
20 properties (dict - Python dictionary object containing the tool parameters, not input/output files):
21 * **modeller_key** (*str*) - (None) Modeller license key.
22 * **binary_path** (*str*) - ("check_structure") Path to the check_structure 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.
27 Examples:
28 This is a use example of how to use the building block from Python::
30 from biobb_model.model.fix_ssbonds import fix_ssbonds
31 prop = { 'restart': False }
32 fix_ssbonds(input_pdb_path='/path/to/myStructure.pdb',
33 output_pdb_path='/path/to/newStructure.pdb',
34 properties=prop)
36 Info:
37 * wrapped_software:
38 * name: In house
39 * license: Apache-2.0
40 * ontology:
41 * name: EDAM
42 * schema: http://edamontology.org/EDAM.owl
43 """
45 def __init__(
46 self,
47 input_pdb_path: str,
48 output_pdb_path: str,
49 properties: Optional[dict] = None,
50 **kwargs,
51 ) -> None:
52 properties = properties or {}
54 # Call parent class constructor
55 super().__init__(properties)
56 self.locals_var_dict = locals().copy()
58 # Input/Output files
59 self.io_dict = {
60 "in": {"input_pdb_path": input_pdb_path},
61 "out": {"output_pdb_path": output_pdb_path},
62 }
64 # Properties specific for BB
65 self.binary_path = properties.get("binary_path", "check_structure")
66 self.modeller_key = properties.get("modeller_key")
68 # Check the properties
69 self.check_properties(properties)
70 self.check_arguments()
72 @launchlogger
73 def launch(self) -> int:
74 """Execute the :class:`FixSSBonds <model.fix_ssbonds.FixSSBonds>` object."""
76 # Setup Biobb
77 if self.check_restart():
78 return 0
79 self.stage_files()
81 self.cmd = [
82 self.binary_path,
83 "-i",
84 self.stage_io_dict["in"]["input_pdb_path"],
85 "-o",
86 self.stage_io_dict["out"]["output_pdb_path"],
87 "--force_save",
88 "--non_interactive",
89 "getss",
90 "--mark",
91 "All",
92 ]
94 if self.modeller_key:
95 self.cmd.insert(1, self.modeller_key)
96 self.cmd.insert(1, "--modeller_key")
98 # Run Biobb block
99 self.run_biobb()
101 # Copy files to host
102 self.copy_to_host()
104 # Remove temporal files
105 self.remove_tmp_files()
107 self.check_arguments(output_files_created=True, raise_exception=False)
108 return self.return_code
111def fix_ssbonds(
112 input_pdb_path: str,
113 output_pdb_path: str,
114 properties: Optional[dict] = None,
115 **kwargs,
116) -> int:
117 """Create :class:`FixSSBonds <model.fix_ssbonds.FixSSBonds>` class and
118 execute the :meth:`launch() <model.fix_ssbonds.FixSSBonds.launch>` method."""
119 return FixSSBonds(**dict(locals())).launch()
122fix_ssbonds.__doc__ = FixSSBonds.__doc__
123main = FixSSBonds.get_main(fix_ssbonds, "Fix SS bonds from residues")
125if __name__ == "__main__":
126 main()