Coverage for biobb_pdb_tools/pdb_tools/biobb_pdb_uniqname.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 Pdbuniqname(BiobbObject): 

12 """ 

13 | biobb_pdb_tools Pdbuniqname 

14 | Renames atoms sequentially (C1, C2, O1, ...) for each HETATM residue. 

15 | This tool renames atoms sequentially (C1, C2, O1, ...) for each HETATM residue in a PDB file. It can be used to rename atoms sequentially for each HETATM residue in 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 atoms renamed. 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_uniqname") Path to the pdb_uniqname 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_uniqname import biobb_pdb_uniqname 

29 

30 biobb_pdb_uniqname(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_uniqname") 

58 self.properties = properties 

59 self.check_init(properties) 

60 

61 @launchlogger 

62 def launch(self) -> int: 

63 """Execute the :class:`Pdbuniqname <biobb_pdb_tools.pdb_tools.pdb_uniqname>` 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 

87 self.remove_tmp_files() 

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

89 

90 return self.return_code 

91 

92 

93def biobb_pdb_uniqname( 

94 input_file_path: str, 

95 output_file_path: str, 

96 properties: Optional[dict] = None, 

97 **kwargs, 

98) -> int: 

99 """Create :class:`Pdbuniqname <biobb_pdb_tools.pdb_tools.pdb_uniqname>` class and 

100 execute the :meth:`launch() <biobb_pdb_tools.pdb_tools.pdb_uniqname.launch>` method.""" 

101 return Pdbuniqname(**dict(locals())).launch() 

102 

103 

104biobb_pdb_uniqname.__doc__ = Pdbuniqname.__doc__ 

105main = Pdbuniqname.get_main(biobb_pdb_uniqname, "Removes all HETATM records in the PDB file.") 

106 

107if __name__ == "__main__": 

108 main()