On Feb 8, 2017, at 19:22, Markus Metz <metm...@gmail.com> wrote: > The question to you is: Is there another more elegant way of doing it? May be > I missed something from the python API?
I don't quite follow what you are looking for, though I have managed to condense your code somewhat, into: updatedMapping = None for ring in m.GetRingInfo().AtomRings(): if set(ring).issubset(maps): updatedMapping = ring if updatedMapping is not None: updatedMapping = sorted(updatedMapping) for i, atom_idx in enumerate(updatedMapping, 1): m.GetAtomWithIdx(atom_idx).SetProp("molAtomMapNumber", str(i)) Is it that you do not want to number the "*" atoms? In that case you can ask the query structure for the atoms with atomic number 0: >>> for atom in corea.GetAtoms(): ... print(atom.GetAtomicNum()) ... 0 6 6 6 6 6 6 0 and ignore numbering the atoms at those positions. Or that you don't want to include ring atoms which aren't ring atoms in the query structure? In which case you can ask the query structure for its rings: >>> corea.GetRingInfo().AtomRings() ((1, 6, 5, 4, 3, 2),) and use that to guide which atoms should/should not be numbered. Cheers, Andrew da...@dalkescientific.com ------------------------------------------------------------------------------ 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