[Rdkit-discuss] GetMolFrags asMols with persistent atom indexes
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Joshua M. <jos...@be...> - 2018-06-26 09:53:07
|
Hey All, I am chopping parts out of molecules and picking up the pieces using the Chem.GetMolFrags() function. I would like to separate fragments into distinct mol objects but keep the original atom indexes however setting the asMols=True flag seems to reset the indexes, is this expected behaviour? Is there a way around this? Here's some code: In [1]: from rdkit import Chem In [2]: m = Chem.MolFromSmiles('c1ccccc1.CCO') In [3]: Chem.GetMolFrags(m) Out[3]: ((0, 1, 2, 3, 4, 5), (6, 7, 8)) <----- desired indexes In [4]: frags = Chem.GetMolFrags(m, asMols=True) In [5]: for frag in frags: ...: print([a.GetIdx() for a in frag.GetAtoms()]) ...: [0, 1, 2, 3, 4, 5] [0, 1, 2] < ------ indexes have been reset Many thanks in advance, Josh |