forlilab / Meeko

Interfacing RDKit and AutoDock
GNU Lesser General Public License v2.1
171 stars 41 forks source link

problem about convert .pdbqt to .sdf #53

Closed dinghezier closed 11 months ago

dinghezier commented 1 year ago

Hello, when I try to use Meeko convert .pdbqt file to .sdf file, I can not get the final result. Can you help me to resolve this problem?

from meeko import PDBQTMolecule

pmol = PDBQTMolecule.from_file(dataset + '/' + ligand + '/' + 'ligand_out/' + a, skip_typing=True, poses_to_read=1)
f = Chem.SDWriter(dataset + '/' + ligand + '/' + 'ligand_out_sdf/' + a.split('.')[0]+'.sdf')
output_rdmol = pmol[0].export_rdkit_mol() 
f.write(output_rdmol)
f.close()

Why doesn't export_rdkit_mol work?

diogomart commented 1 year ago

Hello, "not working" is insufficient information, you'd need to post the error. In any case check the README for examples; your code is for older versions.

dinghezier commented 1 year ago

Hi, Here are the details of the problem,

>>> pdbqt_mol = PDBQTMolecule.from_file("D:\PYTHON\Meeko\example\hydrated_docking\ligand.pdbqt", skip_typing=True)
>>> print(pdbqt_mol)
<Molecule named ligand containing 1 poses of 13 atoms>
>>> rdkitmol_list = RDKitMolCreate.from_pdbqt_mol(pdbqt_mol)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\PYTHON\Meeko\meeko\rdkit_mol_create.py", line 181, in from_pdbqt_mol
    smiles, index_map, h_parent = cls.guess_flexres_smiles(resname, atom_names)
  File "D:\PYTHON\Meeko\meeko\rdkit_mol_create.py", line 231, in guess_flexres_smiles
    atom_names_in_smiles_order = cls.flexres[resname]["atom_names_in_smiles_order"]
KeyError: 'NCT'
diogomart commented 1 year ago

Looks like there's a flexible residue named "NCT" for which there's no template. So it won't make an RDKit molecule for it. But this should be handled and None should be produced in place of an RDKit molecule for that flexres. I think 5369c5239f1d8092cfec2cbd704aa78aa4eb2934 fixes it. Could you share your PDBQT?

rwxayheee commented 1 year ago

Hi @dinghezier and @diogomart, the attempt to guess smiles was likely triggered because missing of smiles in the input pdbqt (ligand.pdbqt from the hydrated docking example in this repository) but I’m also not sure how to pass the smiles of the ligand. How will Meeko normally pick up ligand smiles, would you please advise? Many thanks

diogomart commented 1 year ago

@rwxayheee good point. The smiles is in a PDBQT REMARK, for example, for water, smiles is just "O"

REMARK SMILES O
REMARK SMILES IDX 1 1
REMARK H PARENT 1 2 1 3
REMARK Flexibility Score: inf
ROOT
ATOM      1  O   UNL     1       0.009   0.404   0.000  1.00  0.00    -0.412 OA
ATOM      2  H   UNL     1      -0.787  -0.185   0.000  1.00  0.00     0.206 HD
ATOM      3  H   UNL     1       0.778  -0.219   0.000  1.00  0.00     0.206 HD
ENDROOT
TORSDOF 0
diogomart commented 11 months ago

Fixed the "fix"... 28c9fbfe3b778aa1bd5e8d7e4f3e6edf44633a0c

Closing, feel free to re-open if needed.