Skip to content

Commit

Permalink
Merge pull request #117 from forlilab/fix_charge_parsing
Browse files Browse the repository at this point in the history
Fix charge parsing
  • Loading branch information
diogomart authored Aug 9, 2024
2 parents c44bfc7 + cea4e3e commit ba461a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion meeko/molecule_pdbqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions test/rdkitmol_from_docking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit ba461a7

Please sign in to comment.