Coverage for biobb_chemistry/test/unitests/test_babel/test_babel_pdbqt_records.py: 100%
18 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-06 12:40 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-06 12:40 +0000
1# type: ignore
2from biobb_chemistry.babelm.common import remove_non_pdbqt_records
4# PDBQT written by Open Babel 3.2 from a PDB with COMPND and AUTHOR records
5PDBQT = """REMARK Name = ligand.pdb
6COMPND STI.sdf
7AUTHOR GENERATED BY OPEN BABEL 2.4.1
8REMARK 1 active torsions:
9ROOT
10ATOM 1 C UNL 1 2.740 -0.022 8.889 0.00 0.00 +0.000 C
11ENDROOT
12BRANCH 1 2
13ATOM 2 N UNL 1 3.020 1.310 8.512 0.00 0.00 +0.000 NA
14ENDBRANCH 1 2
15TORSDOF 1
16"""
19class TestRemoveNonPdbqtRecords():
20 def test_pdbqt_output(self, tmp_path):
21 path = tmp_path / "ligand.pdbqt"
22 path.write_text(PDBQT)
23 remove_non_pdbqt_records("pdbqt", str(path), None)
24 assert path.read_text() == "".join(line for line in PDBQT.splitlines(keepends=True) if not line.startswith(("COMPND", "AUTHOR")))
26 def test_format_from_extension(self, tmp_path):
27 path = tmp_path / "ligand.pdbqt"
28 path.write_text(PDBQT)
29 remove_non_pdbqt_records("", str(path), None)
30 assert "COMPND" not in path.read_text()
32 def test_other_formats_untouched(self, tmp_path):
33 path = tmp_path / "ligand.pdb"
34 path.write_text(PDBQT)
35 remove_non_pdbqt_records("pdb", str(path), None)
36 assert path.read_text() == PDBQT