Coverage for biobb_vs/test/unitests/test_gnina/test_gnina_select_pose.py: 100%

32 statements  

« prev     ^ index     » next       coverage.py v7.15.3, created at 2026-08-03 13:34 +0000

1# type: ignore 

2import pytest 

3from biobb_common.tools import test_fixtures as fx 

4 

5from biobb_vs.gnina.gnina_select_pose import gnina_select_pose 

6 

7 

8class TestGninaSelectPose(): 

9 def setup_class(self): 

10 fx.test_setup(self, 'gnina_select_pose') 

11 

12 def teardown_class(self): 

13 fx.test_teardown(self) 

14 pass 

15 

16 def test_gnina_select_pose(self): 

17 gnina_select_pose(properties=self.properties, **self.paths) 

18 assert fx.not_empty(self.paths['output_sdf_path']) 

19 # the record is copied verbatim, so it must match byte for byte 

20 assert fx.equal(self.paths['output_sdf_path'], self.paths['ref_output_sdf_path']) 

21 

22 def test_gnina_select_pose_out_of_range(self): 

23 # the poses file holds 6 records, so asking for the 99th must fail cleanly 

24 with pytest.raises(SystemExit): 

25 gnina_select_pose(input_sdf_path=self.paths['input_sdf_path'], 

26 output_sdf_path=self.paths['output_sdf_path'], 

27 properties={'pose': 99}) 

28 

29 def test_gnina_select_pose_unknown_sort_by(self): 

30 with pytest.raises(SystemExit): 

31 gnina_select_pose(input_sdf_path=self.paths['input_sdf_path'], 

32 output_sdf_path=self.paths['output_sdf_path'], 

33 properties={'sort_by': 'nonsense'}) 

34 

35 def test_gnina_select_pose_unknown_ligand(self): 

36 with pytest.raises(SystemExit): 

37 gnina_select_pose(input_sdf_path=self.paths['input_sdf_path'], 

38 output_sdf_path=self.paths['output_sdf_path'], 

39 properties={'ligand': 99}) 

40 

41 

42class TestGninaSelectPoseSorted(): 

43 def setup_class(self): 

44 fx.test_setup(self, 'gnina_select_pose_sorted') 

45 

46 def teardown_class(self): 

47 fx.test_teardown(self) 

48 pass 

49 

50 def test_gnina_select_pose_sorted(self): 

51 # reordering by empirical affinity surfaces a different pose than the 

52 # order gnina wrote, which ranks by CNN score 

53 gnina_select_pose(properties=self.properties, **self.paths) 

54 assert fx.not_empty(self.paths['output_sdf_path']) 

55 assert fx.equal(self.paths['output_sdf_path'], self.paths['ref_output_sdf_path'])