Coverage for biobb_pdb_tools/pdb_tools/biobb_pdb_delhetatm.py: 76%
45 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 12:37 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 12:37 +0000
1#!/usr/bin/env python3
3"""Module containing the Delhetatm class and the command line interface."""
5import argparse
6from typing import Optional
8from biobb_common.configuration import settings
9from biobb_common.generic.biobb_object import BiobbObject
10from biobb_common.tools import file_utils as fu
11from biobb_common.tools.file_utils import launchlogger
14class Delhetatm(BiobbObject):
15 """
16 | biobb_pdb_tools Delhetatm
17 | Removes all HETATM records in the PDB file.
18 | This tool removes all HETATM records in the PDB file. It can be used to remove all HETATM records from a PDB file.
20 Args:
21 input_file_path (str): PDB file. File type: input. `Sample file <https://raw.githubusercontent.com/bioexcel/biobb_pdb_tools/master/biobb_pdb_tools/test/data/pdb_tools/1AKI.pdb>`_. Accepted formats: pdb (edam:format_1476).
22 output_file_path (str): PDB file with all HETATM records removed. File type: output. `Sample file <https://raw.githubusercontent.com/bioexcel/biobb_pdb_tools/master/biobb_pdb_tools/test/reference/pdb_tools/ref_pdb_delhetatm.pdb>`_. Accepted formats: pdb (edam:format_1476).
23 properties (dic):
24 * **binary_path** (*str*) - ("pdb_delhetatm") Path to the pdb_delhetatm executable binary.
25 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
26 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
28 Examples:
29 This is a use example of how to use the building block from Python::
31 from biobb_pdb_tools.pdb_tools.biobb_pdb_delhetatm import biobb_pdb_delhetatm
33 biobb_pdb_delhetatm(input_file_path='/path/to/input.pdb',
34 output_file_path='/path/to/output.pdb')
36 Info:
37 * wrapped_software:
38 * name: pdb_tools
39 * version: >=2.5.0
40 * license: Apache-2.0
41 * ontology:
42 * name: EDAM
43 * schema: http://edamontology.org/EDAM.owl
45 """
47 def __init__(
48 self, input_file_path, output_file_path, properties=None, **kwargs
49 ) -> None:
50 properties = properties or {}
52 super().__init__(properties)
53 self.locals_var_dict = locals().copy()
55 self.io_dict = {
56 "in": {"input_file_path": input_file_path},
57 "out": {"output_file_path": output_file_path},
58 }
60 self.binary_path = properties.get("binary_path", "pdb_delhetatm")
61 self.properties = properties
63 self.check_properties(properties)
64 self.check_arguments()
66 @launchlogger
67 def launch(self) -> int:
68 """Execute the :class:`Delhetatm <biobb_pdb_tools.pdb_tools.pdb_delhetatm>` object."""
70 if self.check_restart():
71 return 0
72 self.stage_files()
74 self.cmd = [
75 self.binary_path,
76 self.stage_io_dict["in"]["input_file_path"],
77 ">",
78 self.io_dict["out"]["output_file_path"],
79 ]
81 fu.log(" ".join(self.cmd), self.out_log, self.global_log)
83 fu.log(
84 "Creating command line with instructions and required arguments",
85 self.out_log,
86 self.global_log,
87 )
89 self.run_biobb()
90 self.copy_to_host()
92 self.tmp_files.extend([self.stage_io_dict.get("unique_dir", "")])
93 self.remove_tmp_files()
94 self.check_arguments(output_files_created=True, raise_exception=False)
96 return self.return_code
99def biobb_pdb_delhetatm(
100 input_file_path: str,
101 output_file_path: str,
102 properties: Optional[dict] = None,
103 **kwargs,
104) -> int:
105 """Create :class:`Delhetatm <biobb_pdb_tools.pdb_tools.pdb_delhetatm>` class and
106 execute the :meth:`launch() <biobb_pdb_tools.pdb_tools.pdb_delhetatm.launch>` method."""
107 return Delhetatm(
108 input_file_path=input_file_path,
109 output_file_path=output_file_path,
110 properties=properties,
111 **kwargs,
112 ).launch()
114biobb_pdb_delhetatm.__doc__ = Delhetatm.__doc__
117def main():
118 """Command line execution of this building block. Please check the command line documentation."""
119 parser = argparse.ArgumentParser(
120 description="Removes all HETATM records in the PDB file.",
121 formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999),
122 )
123 parser.add_argument("--config", required=True, help="Configuration file")
124 required_args = parser.add_argument_group("required arguments")
125 required_args.add_argument(
126 "--input_file_path",
127 required=True,
128 help="Description for the first input file path. Accepted formats: pdb.",
129 )
130 required_args.add_argument(
131 "--output_file_path",
132 required=True,
133 help="Description for the output file path. Accepted formats: pdb.",
134 )
136 args = parser.parse_args()
137 args.config = args.config or "{}"
138 properties = settings.ConfReader(config=args.config).get_prop_dic()
140 biobb_pdb_delhetatm(
141 input_file_path=args.input_file_path,
142 output_file_path=args.output_file_path,
143 properties=properties,
144 )
147if __name__ == "__main__":
148 main()