forlilab / Meeko

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

Converting list of DLG files to SDF: AttributeError #37

Closed pducrot closed 1 year ago

pducrot commented 1 year ago

Hi, I'm trying to use Meeko from python to convert a list of .dlg files to a single sdf file.

def read_pdbqt(name):
    if (name.endswith(".dlg")):
        pdbqt = PDBQTMolecule.from_file(f"docking/{name}", is_dlg=True, skip_typing=True)
        mname = name.replace("protein_", "")
        m = RDKitMolCreate.from_pdbqt_mol(pdbqt)[0]
#        m.SetProp("_Name", mname)
        return m

mols = [read_pdbqt(dlg) for dlg in os.listdir(f"docking")]

RDkit returns an error at the above commented "m.SetProp()" line: AttributeError: 'NoneType' object has no attribute 'SetProp'

Does RDKitMolCreate.from_pdbqt_mol return a list of regular RDkit molecular object, or is there a need to convert those and how? Reading the Meeko code, it seems that the molecule was generate using Chem.MolFromSmiles() and should therefore have a SetProp attribute. Thanks, Pierre

diogomart commented 1 year ago

Hi,

RDKitMolCreate.from_pdbqt_mol returns None objects, instead of RDKit molecules, if the REMARK SMILES line is missing in the DLG/PDBQT file (see code). This would happen if meeko was not used to prepare the PDBQT inputs for docking.

pducrot commented 1 year ago

Hi, thank you for your feedback. Actually, I prepared pdbqt files with Meeko, ran AutoDock/vina and the output .dlg files contain the smiles

DOCKED: REMARK SMILES Cn1cc(-c2cncc...
DOCKED: REMARK SMILES IDX 5 1 25 2 9 3 8...
DOCKED: REMARK SMILES IDX 28 14 29 15 30...
DOCKED: REMARK SMILES IDX 15 25 16 26 22...
pducrot commented 1 year ago

I see in your code line 175 of molecule_pdbqt.py that SMILES is expected in lines starting with REMARK SMILES, whereas the output dlg files from autodock start with DOCKED:

diogomart commented 1 year ago

The "DOCKED:" keyword is remove with is_dlg=True, so your DLG should work fine. I have no clue what is going on. Can you share the DLG?

pducrot commented 1 year ago

AS you can see above, I indeed set is_dlg to True. I'll generate a file with a public compound for you and share, cannot share this one.

diogomart commented 1 year ago

Sounds good, I'll then try to reproduce the problem

pducrot commented 1 year ago

After thorough investigation, I found the files that were blocking and addressed. It's all fine, thanks for you time and help.