Thanks for the replies guys,
@Stephen, yep that would work, the problem is that you would still have to
match the R groups back to the original structure using substructure
searching, which is a bit ambiguous.
@Paolo, that is both horrible and beautiful. Thanks a lot again :)!
Cheers,
Josh
On 2 July 2018 at 19:07, Stephen Roughley <s.d.rough...@googlemail.com>
wrote:
> You could try looping over all your atoms and calling setIntProp on each
> one to set a property with the original index, then get that property value
> back rather than the new atom indices.
>
> Steve
>
>
> On Mon, 2 Jul 2018, 17:43 Joshua Meyers, <joshua.mey...@benevolent.ai>
> wrote:
>
>> Hey Again,
>>
>> Back to this problem because I didn't isolate the problem well enough in
>> the first place - my bad!
>>
>> I would like to get the original atom indices of the r groups created by
>> the ReplaceCore function.
>> The issue is that the atom indices are reset by the ReplaceCore()
>> function (and seemingly any other function that deletes atoms).
>>
>> Any idea how I would get these?
>>
>> In [1]: from rdkit import Chem
>>
>> In [2]: from rdkit.Chem.Scaffolds import MurckoScaffold
>>
>> In [3]: m = Chem.MolFromSmiles('c1cc(C)c(CC(=O)[13C])cc1')
>>
>> In [4]: murcko = MurckoScaffold.GetScaffoldForMol(m)
>>
>> In [5]: rGroups = Chem.ReplaceCore(m, murcko, useChirality=True,
>> labelByIndex=True)
>>
>> In [6]: rGroup_idxs = []
>> ...: rGroups = Chem.GetMolFrags(rGroups, asMols=True,
>> fragsMolAtomMapping=rGroup_idxs)
>> ...: rGroup_idxs
>> ...:
>> Out[6]: [(0, 5), (1, 2, 3, 4, 6)]
>>
>> I know that the two sets of indices I want from the original molecule m
>> are
>> ((3,2),(5,6,7,8))
>>
>> (found by depicting the indices - see attached)
>>
>>
>>
>>
>> Any idea how I can achieve this?
>>
>> Cheers in advance,
>> Josh
>>
>>
>> On 26 June 2018 at 12:25, Paolo Tosco <paolo.tosco.m...@gmail.com> wrote:
>>
>>> Hi Josh,
>>>
>>> if you pass empty lists as the frags and as the fragsMolAtomMapping
>>> parameters of GetMolFrags() they will be filled with indices referring to
>>> the indices of the original molecule (see lines highlighted in red below).
>>>
>>> Hope that helps, cheers
>>> p.
>>> GetMolFrags(...)
>>>
>>>
>>>
>>> GetMolFrags( (Mol)mol [, (bool)asMols=False [, (bool)sanitizeFrags=True
>>> [, (AtomPairsParameters)frags=None [,
>>> (AtomPairsParameters)fragsMolAtomMapping=None]]]]) -> tuple :
>>> Finds the disconnected fragments from a molecule.
>>>
>>> For example, for the molecule 'CC(=O)[O-].[NH3+]C' GetMolFrags()
>>> returns
>>> ((0, 1, 2, 3), (4, 5))
>>>
>>> ARGUMENTS:
>>>
>>> - mol: the molecule to use
>>> - asMols: (optional) if this is provided and true, the fragments
>>> will be returned as molecules instead of atom ids.
>>> - sanitizeFrags: (optional) if this is provided and true, the
>>> fragments
>>> molecules will be sanitized before returning them. -
>>> frags: (optional, defaults to None) if this is provided as an empty list,
>>> the result will be mol.GetNumAtoms() long on return and will
>>> contain the
>>> fragment assignment for each Atom
>>> - fragsMolAtomMapping: (optional, defaults to None) if this is
>>> provided as
>>> an empty list, the result will be a a numFrags long list on
>>> return, and
>>> each entry will contain the indices of the Atoms in that fragment:
>>> [(0, 1, 2, 3), (4, 5)]
>>> RETURNS: a tuple of tuples with IDs for the atoms in each fragment
>>> or a tuple of molecules.
>>>
>>>
>>> On 26/06/2018 10:29, Joshua Meyers wrote:
>>>
>>> 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
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> <https://protect-eu.mimecast.com/s/v-qlCj2RATnXWjhWau71>
>>>
>>>
>>>
>>> _______________________________________________
>>> Rdkit-discuss mailing
>>> listRdkit-discuss@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>> <https://protect-eu.mimecast.com/s/LgDKCk5R6sOjxnhVTcRl>
>>>
>>>
>>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> <https://protect-eu.mimecast.com/s/v-qlCj2RATnXWjhWau71>______
>> _________________________________________
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>> <https://protect-eu.mimecast.com/s/LgDKCk5R6sOjxnhVTcRl>
>>
>
------------------------------------------------------------------------------
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