From 9e2a7b480f671dbf1a9f0d3f69e1555db8e6ec6e Mon Sep 17 00:00:00 2001 From: diogom Date: Fri, 3 May 2024 15:26:37 -0700 Subject: [PATCH 1/2] fix pdbqt charge parsing in molecule_pdbqt.py --- meeko/molecule_pdbqt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meeko/molecule_pdbqt.py b/meeko/molecule_pdbqt.py index 548448b7..0968bfab 100644 --- a/meeko/molecule_pdbqt.py +++ b/meeko/molecule_pdbqt.py @@ -129,7 +129,7 @@ def _read_ligand_pdbqt_file(pdbqt_string, poses_to_read=-1, energy_range=-1, is_ xyz = np.array([line[30:38].strip(), line[38:46].strip(), line[46:54].strip()], dtype=float) try: # PDBQT files from dry.py script are stripped from their partial charges. sigh... - partial_charges = float(line[71:77].strip()) + partial_charges = float(line[70:76].strip()) except: partial_charges = 0.0 atom_type = line[77:-1].strip() From cea4e3eb230f41481b1fe5a853487bbe94686489 Mon Sep 17 00:00:00 2001 From: diogom Date: Fri, 3 May 2024 15:33:39 -0700 Subject: [PATCH 2/2] test charge parsing in molecule_pdbqt.py --- test/rdkitmol_from_docking_test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/rdkitmol_from_docking_test.py b/test/rdkitmol_from_docking_test.py index 5ebc3c1b..76ccd01b 100644 --- a/test/rdkitmol_from_docking_test.py +++ b/test/rdkitmol_from_docking_test.py @@ -3,6 +3,7 @@ from meeko import MoleculePreparation from meeko import PDBQTWriterLegacy from rdkit import Chem +import numpy as np import pathlib import json import io @@ -108,6 +109,9 @@ def test_small_04(): run("small-04.sdf", wet=True) def test_meeko_free_energy_prop_vina(): fpath = datadir/ "vina-result-ethanol.pdbqt" pdbqt_mol = PDBQTMolecule.from_file(fpath) + ref_charges = [0.034, 0.152, -0.397, 0.21] + tolerance = 0.01 + assert np.all(np.abs(pdbqt_mol.atoms()["partial_charges"] - ref_charges) < tolerance) sd_string, failures = RDKitMolCreate.write_sd_string(pdbqt_mol) assert len(failures) == 0 sio = io.BytesIO(sd_string.encode())