forlilab / Meeko

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

IndexError: End of sequence hit #24

Closed alyferryhalo closed 1 year ago

alyferryhalo commented 2 years ago

Hello!

I tried to prepare one molecule (rdkit mol generated from SMILES) following instructions from readme.md but I got an error.

Code:

from meeko import MoleculePreparation
from rdkit import Chem
preparator = MoleculePreparation(hydrate=True)
smile = 'COc1ccccc1C(C)NS(=O)(=O)NC(=O)OCc1ccccc1'
mol = Chem.MolFromSmiles(smile)
preparator.prepare(mol)

Traceback:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Input In [7], in <cell line: 1>()
----> 1 preparator.prepare(mol)

File ~/anaconda3/envs/my-rdkit-env/lib/python3.9/site-packages/meeko/preparation.py:94, in MoleculePreparation.prepare(self, mol, is_protein_sidechain)
     92     raise TypeError("Molecule is not an instance of supported types: %s" % type(mol))
     93 setup_class = self._classes_setup[mol_type]
---> 94 setup = setup_class(mol, is_protein_sidechain)
     95 self.setup = setup
     96 # 1.  assign atom types (including HB types, vectors and stuff)
     97 # DISABLED TODO self.atom_typer.set_parm(mol)

File ~/anaconda3/envs/my-rdkit-env/lib/python3.9/site-packages/meeko/setup.py:109, in MoleculeSetup.__init__(self, mol, flexible_amides, is_protein_sidechain, assign_charges, template)
    107 self.is_protein_sidechain = False
    108 if template is None:
--> 109     self.process_mol(flexible_amides, is_protein_sidechain, assign_charges)
    110 else:
    111     if not isinstance(template, MoleculeSetup):

File ~/anaconda3/envs/my-rdkit-env/lib/python3.9/site-packages/meeko/setup.py:118, in MoleculeSetup.process_mol(self, flexible_amides, is_protein_sidechain, assign_charges)
    116 self.atom_true_count = self.get_num_mol_atoms()
    117 self.name = self.get_mol_name()
--> 118 self.init_atom(assign_charges)
    119 self.perceive_rings()
    120 self.init_bond(flexible_amides)

File ~/anaconda3/envs/my-rdkit-env/lib/python3.9/site-packages/meeko/setup.py:600, in RDKitMoleculeSetup.init_atom(self, assign_charges)
    598 """ initialize the atom table information """
    599 # extract the coordinates
--> 600 c = self.mol.GetConformers()[0]
    601 coords = c.GetPositions()
    602 # extract/generate charges

IndexError: End of sequence hit

Could please someone explain me how to deal with this error? Why did I get it?

diogomart commented 2 years ago

Hi,

The RDKit molecule passed to the preparator needs explicit hydrogens and 3D coordinates:

mol_h = Chem.AddHs(mol)
params_etkdg = Chem.rdDistGeom.ETKDGv3()
status_gen3d = Chem.rdDistGeom.EmbedMolecule(mol_h, params_etkdg)
preparator.prepare(mol_h)