Coverage for biobb_pdb_tools/pdb_tools/biobb_pdb_keepcoord.py: 94%
32 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-04 08:26 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-04 08:26 +0000
1#!/usr/bin/env python3
3"""Module containing the Pdbkeepcoord class and the command line interface."""
5from typing import Optional
6from biobb_common.generic.biobb_object import BiobbObject
7from biobb_common.tools import file_utils as fu
8from biobb_common.tools.file_utils import launchlogger
11class Pdbkeepcoord(BiobbObject):
12 """
13 | biobb_pdb_tools Pdbkeepcoord
14 | Removes all non-coordinate records from the file.
15 | Keeps only MODEL, ENDMDL, END, ATOM, HETATM, CONECT records from a PDB file.
17 Args:
18 input_file_path (str): Input 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).
19 output_file_path (str): PDB file with only coordinate records. File type: output. `Sample file <https://raw.githubusercontent.com/bioexcel/biobb_pdb_tools/master/biobb_pdb_tools/test/reference/pdb_tools/ref_pdb_keepcoord.pdb>`_. Accepted formats: pdb (edam:format_1476).
20 properties (dic):
21 * **binary_path** (*str*) - ("pdb_keepcoord") Path to the pdb_keepcoord executable binary.
22 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
23 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
25 Examples:
26 This is a use example of how to use the building block from Python::
28 from biobb_pdb_tools.pdb_tools.biobb_pdb_keepcoord import biobb_pdb_keepcoord
30 # Keep only coordinate records
31 biobb_pdb_keepcoord(input_file_path='/path/to/input.pdb',
32 output_file_path='/path/to/output.pdb')
34 Info:
35 * wrapped_software:
36 * name: pdb_tools
37 * version: >=2.5.0
38 * license: Apache-2.0
39 * ontology:
40 * name: EDAM
41 * schema: http://edamontology.org/EDAM.owl
43 """
45 def __init__(
46 self, input_file_path, output_file_path, properties=None, **kwargs
47 ) -> None:
48 properties = properties or {}
50 super().__init__(properties)
51 self.locals_var_dict = locals().copy()
53 self.io_dict = {
54 "in": {"input_file_path": input_file_path},
55 "out": {"output_file_path": output_file_path},
56 }
58 self.binary_path = properties.get("binary_path", "pdb_keepcoord")
59 self.properties = properties
60 self.check_init(properties)
62 @launchlogger
63 def launch(self) -> int:
64 """Execute the :class:`Pdbkeepcoord <biobb_pdb_tools.pdb_tools.pdb_keepcoord>` object."""
66 if self.check_restart():
67 return 0
68 self.stage_files()
70 self.cmd = [
71 self.binary_path,
72 self.stage_io_dict["in"]["input_file_path"],
73 ">",
74 self.io_dict["out"]["output_file_path"],
75 ]
77 fu.log(" ".join(self.cmd), self.out_log, self.global_log)
79 fu.log(
80 "Creating command line with instructions and required arguments",
81 self.out_log,
82 self.global_log,
83 )
85 self.run_biobb()
86 self.copy_to_host()
87 self.remove_tmp_files()
88 self.check_arguments(output_files_created=True, raise_exception=False)
90 return self.return_code
93def biobb_pdb_keepcoord(
94 input_file_path: str,
95 output_file_path: str,
96 properties: Optional[dict] = None,
97 **kwargs,
98) -> int:
99 """Create :class:`Pdbkeepcoord <biobb_pdb_tools.pdb_tools.pdb_keepcoord>` class and
100 execute the :meth:`launch() <biobb_pdb_tools.pdb_tools.pdb_keepcoord.launch>` method."""
102 return Pdbkeepcoord(**dict(locals())).launch()
105biobb_pdb_keepcoord.__doc__ = Pdbkeepcoord.__doc__
106main = Pdbkeepcoord.get_main(biobb_pdb_keepcoord, "Removes all non-coordinate records from the file. Keeps only MODEL, ENDMDL, END, ATOM, HETATM, CONECT records.")
108if __name__ == "__main__":
109 main()