Hi there at RDKit,
I have a set of atom indices from a molecule I want to keep, and any atom
which is not in this list I want to discard.
I thought of implementing this as follows:
#!/usr/bin/env python
from rdkit import Chem
mol = Chem.MolFromSmiles(CCC1CNCC1CC)
keep_atoms = [2,3,4] #
And as a follow up - running this:
#!/usr/bin/env python
from rdkit import Chem
mol = Chem.MolFromSmiles(CCC1CNCC1CC)
edit_mol = Chem.EditableMol(mol)
edit_mol.RemoveAtom(0)
for atom in edit_mol.GetMol().GetAtoms():
print atom.GetIdx()
gives seg fault...
jp@xxx:~/tmp$ test.py
I had a similar problem to this when removing atoms from a molecule. When you
remove an atom, the atoms IDs change, therefore resulting in a seg fault, or
your atoms not being in the correct range.
The way I got around this was to sort the IDs of the atoms I want to remove
from highest to
Hi JP,
Sarah was right on the trick of deleting atoms in the descending order of atom
index. Regarding the segment fault, this is very likely to be a memory
management issue. Make sure you assign the result of the GetMol() call to a
temporary variable to avoid the underlying object being
Thanks to both of you, nice trick...
-
Jean-Paul Ebejer
Early Stage Researcher
On 22 March 2012 16:34, Eddie Cao cao.yi...@gmail.com wrote:
Hi JP,
Sarah was right on the trick of deleting atoms in the descending order of
atom index. Regarding the segment fault, this is very likely to be a
5 matches
Mail list logo