Coverage for biobb_pdb_tools/pdb_tools/biobb_pdb_delhetatm.py: 94%

32 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-04 08:26 +0000

1#!/usr/bin/env python3 

2 

3"""Module containing the Delhetatm class and the command line interface.""" 

4 

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 

9 

10 

11class Delhetatm(BiobbObject): 

12 """ 

13 | biobb_pdb_tools Delhetatm 

14 | Removes all HETATM records in the PDB file. 

15 | This tool removes all HETATM records in the PDB file. It can be used to remove all HETATM records from a PDB file. 

16 

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 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). 

20 properties (dic): 

21 * **binary_path** (*str*) - ("pdb_delhetatm") Path to the pdb_delhetatm 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. 

24 

25 Examples: 

26 This is a use example of how to use the building block from Python:: 

27 

28 from biobb_pdb_tools.pdb_tools.biobb_pdb_delhetatm import biobb_pdb_delhetatm 

29 

30 biobb_pdb_delhetatm(input_file_path='/path/to/input.pdb', 

31 output_file_path='/path/to/output.pdb') 

32 

33 Info: 

34 * wrapped_software: 

35 * name: pdb_tools 

36 * version: >=2.5.0 

37 * license: Apache-2.0 

38 * ontology: 

39 * name: EDAM 

40 * schema: http://edamontology.org/EDAM.owl 

41 

42 """ 

43 

44 def __init__( 

45 self, input_file_path, output_file_path, properties=None, **kwargs 

46 ) -> None: 

47 properties = properties or {} 

48 

49 super().__init__(properties) 

50 self.locals_var_dict = locals().copy() 

51 

52 self.io_dict = { 

53 "in": {"input_file_path": input_file_path}, 

54 "out": {"output_file_path": output_file_path}, 

55 } 

56 

57 self.binary_path = properties.get("binary_path", "pdb_delhetatm") 

58 self.properties = properties 

59 self.check_init(properties) 

60 

61 @launchlogger 

62 def launch(self) -> int: 

63 """Execute the :class:`Delhetatm <biobb_pdb_tools.pdb_tools.pdb_delhetatm>` object.""" 

64 

65 if self.check_restart(): 

66 return 0 

67 self.stage_files() 

68 

69 self.cmd = [ 

70 self.binary_path, 

71 self.stage_io_dict["in"]["input_file_path"], 

72 ">", 

73 self.io_dict["out"]["output_file_path"], 

74 ] 

75 

76 fu.log(" ".join(self.cmd), self.out_log, self.global_log) 

77 

78 fu.log( 

79 "Creating command line with instructions and required arguments", 

80 self.out_log, 

81 self.global_log, 

82 ) 

83 

84 self.run_biobb() 

85 self.copy_to_host() 

86 self.remove_tmp_files() 

87 self.check_arguments(output_files_created=True, raise_exception=False) 

88 

89 return self.return_code 

90 

91 

92def biobb_pdb_delhetatm( 

93 input_file_path: str, 

94 output_file_path: str, 

95 properties: Optional[dict] = None, 

96 **kwargs, 

97) -> int: 

98 """Create :class:`Delhetatm <biobb_pdb_tools.pdb_tools.pdb_delhetatm>` class and 

99 execute the :meth:`launch() <biobb_pdb_tools.pdb_tools.pdb_delhetatm.launch>` method.""" 

100 return Delhetatm(**dict(locals())).launch() 

101 

102 

103biobb_pdb_delhetatm.__doc__ = Delhetatm.__doc__ 

104main = Delhetatm.get_main(biobb_pdb_delhetatm, "Removes all HETATM records in the PDB file.") 

105 

106if __name__ == "__main__": 

107 main()