Discussion:
[Rdkit-discuss] Delete several Atoms
Changge Ji
2017-06-25 17:16:32 UTC
Permalink
Dear all,

Is there an easy way to delete several atoms in a molecule according to an index list ?

RWMol RemoveAtom() can only delete one atom each time.
And after that, the index changed.

Many Thanks.

Best,
Changge


Changge Ji
Brian Kelley
2017-06-25 17:22:06 UTC
Permalink
Yes, go backwards through the index list.

for index in sorted(indices, reverse=True):
mol.RemoveAtom(index)

Indices are only changed if they are higher than the removed index.
----
Brian Kelley
Post by Changge Ji
Dear all,
Is there an easy way to delete several atoms in a molecule according to an index list ?
RWMol RemoveAtom() can only delete one atom each time.
And after that, the index changed.
Many Thanks.
Best,
Changge
Changge Ji
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Continue reading on narkive:
Loading...