forlilab / Meeko

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

NotImplementedError in OBMoleculeSetup.get_equivalent_atoms() #8

Closed avnikonenko closed 2 years ago

avnikonenko commented 2 years ago

Dear authors, I tried to convert molecule from smiles to pdbqt format, but the new version of Meeko returns error (old version worked correctly) - File "site-packages/meeko/setup.py", line 698, in get_equivalent_atoms raise NotImplementedError NotImplementedError version of the packages: numpy 1.20.3 scipy 1.6.2 rdkit 2021.03.5 meeko 0.3.0 code:

smi = 'O=C(C)Oc1ccccc1C(=O)O'

mol = Chem.MolFromSmiles(smi)
mol = Chem.AddHs(mol, addCoords=True)
params = AllChem.ETKDGv3()
params.useRandomCoords = False
params.randomSeed = 120
AllChem.EmbedMolecule(mol, params)
AllChem.UFFOptimizeMolecule(mol, maxIters=100)
molecule_sdf = Chem.MolToMolBlock(mol)

mol = obutils.load_molecule_from_string(molecule_sdf, molecule_format='SDF')

mol.AddHydrogens()
charge_model = ob.OBChargeModel.FindType("Gasteiger")
charge_model.ComputeCharges(mol)

preparator = MoleculePreparation(keep_nonpolar_hydrogens=False,
                                 hydrate=False, flexible_amides=False,
                                 rigid_macrocycles=False, min_ring_size=7, max_ring_size=33,
                                 rigidify_bonds_smarts=[], rigidify_bonds_indices=[],
                                 double_bond_penalty=50, atom_type_smarts={},
                                 is_protein_sidechain=False, add_index_map=False,
                                 stop_at_defaults=False, remove_smiles=False)
preparator.prepare(mol)

Could you help me please? Thank you!

diogomart commented 2 years ago

Hi,

You should pass the RDKit molecule to preparator.prepare() instead of passing the OpenBabel Molecule. In your script, delete the following lines:

molecule_sdf = Chem.MolToMolBlock(mol)

mol = obutils.load_molecule_from_string(molecule_sdf, molecule_format='SDF')

mol.AddHydrogens()
charge_model = ob.OBChargeModel.FindType("Gasteiger")
charge_model.ComputeCharges(mol)

The reason is that Meeko is now using RDKit instead of OpenBabel. However, we still kept OpenBabel around and in case we want to go back to it, but there's one function that we didn't implement yet in the OpenBabel side of the code, hence the NotImplementedError.

Best regards,

avnikonenko commented 2 years ago

Thank you!