Coverage for biobb_model / model / fix_amides.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 FixAmides 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 FixAmides(BiobbObject):
12 """
13 | biobb_model FixAmides
14 | Fix amide groups from residues.
15 | Flip the clashing amide groups to avoid clashes.
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/5s2z.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_amide_pdb_path.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_amides import fix_amides
31 prop = { 'restart': False }
32 fix_amides(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:`FixAmides <model.fix_amides.FixAmides>` 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 "amide",
89 "--fix",
90 "All",
91 ]
93 if self.modeller_key:
94 self.cmd.insert(1, self.modeller_key)
95 self.cmd.insert(1, "--modeller_key")
97 # Run Biobb block
98 self.run_biobb()
100 # Copy files to host
101 self.copy_to_host()
103 # Remove temporal files
104 self.remove_tmp_files()
106 self.check_arguments(output_files_created=True, raise_exception=False)
107 return self.return_code
110def fix_amides(
111 input_pdb_path: str,
112 output_pdb_path: str,
113 properties: Optional[dict] = None,
114 **kwargs,
115) -> int:
116 """Create :class:`FixAmides <model.fix_amides.FixAmides>` class and
117 execute the :meth:`launch() <model.fix_amides.FixAmides.launch>` method."""
118 return FixAmides(**dict(locals())).launch()
121fix_amides.__doc__ = FixAmides.__doc__
122main = FixAmides.get_main(fix_amides, "Flip the clashing amide groups to avoid clashes.")
124if __name__ == "__main__":
125 main()