[Rdkit-discuss] Delete several Atoms

2017-06-25 Thread 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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Delete several Atoms

2017-06-25 Thread Brian Kelley
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

> On Jun 25, 2017, at 10:16 AM, Changge Ji  wrote:
> 
> 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
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
--
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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss