Coverage for biobb_vs/test/unitests/test_utils/test_box_residues.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.18.0, created at 2026-12-03 15:52 +0000

1# type: ignore 

2from biobb_common.tools import test_fixtures as fx 

3from biobb_vs.utils.box_residues import box_residues 

4 

5 

6def assert_size_is_box_edge(box_pdb_path): 

7 """The SIZE written in the REMARK must be the full edge length of the box, which is 

8 what AutoDock Vina reads from --size_x/y/z, so it must match the span of the 8 box 

9 corner atoms.""" 

10 lines = open(box_pdb_path).read().splitlines() 

11 size = [float(value) for value in lines[0].split()[-3:]] 

12 corners = [line for line in lines if line.startswith('HETATM')] 

13 assert len(corners) == 8 

14 for axis in range(3): 

15 coords = [float(line[30 + 8 * axis:38 + 8 * axis]) for line in corners] 

16 span = max(coords) - min(coords) 

17 assert abs(span - size[axis]) < 1e-3, (axis, span, size[axis]) 

18 

19 

20class TestBoxResidues(): 

21 def setup_class(self): 

22 fx.test_setup(self, 'box_residues') 

23 

24 def teardown_class(self): 

25 fx.test_teardown(self) 

26 pass 

27 

28 def test_box_residues(self): 

29 box_residues(properties=self.properties, **self.paths) 

30 assert fx.not_empty(self.paths['output_pdb_path']) 

31 assert fx.equal_txt(self.paths['output_pdb_path'], self.paths['ref_output_pdb_path']) 

32 assert_size_is_box_edge(self.paths['output_pdb_path'])