Thanks, Greg!
I suspected as much so I started on a workaround, which I’ll post here for the
record
Best regards, Jan
mol = Chem.MolFromSmiles('COC.C=C.C=CC')
rxn_smarts = ['[C:1]=[C:2]>>[*:1][*:2]']
fragments = Chem.GetMolFrags(mol,asMols=True)
for i,fragment in enumerate(fragments):
for smarts in rxn_smarts:
patt = Chem.MolFromSmarts(smarts.split(">>")[0])
while fragment.HasSubstructMatch(patt):
rxn = AllChem.ReactionFromSmarts(smarts)
ps = rxn.RunReactants((fragment,))
fragment = ps[0][0]
if i == 0:
mol = fragment
else:
mol = Chem.CombineMols(mol,fragment)
print Chem.MolToSmiles(mol)
On 25 Jun 2018, at 15:14, Greg Landrum
<[email protected]<mailto:[email protected]>> wrote:
Hi Jan,
Not at the moment. The reaction code brings across mapped atoms in the
reactants along with anything reachable from them via a bond.
It's probably not that hard to add an option to allow this to happen, but it
seems like something of an unusual use case.
If you want to require that there's an additional fragment in the reactants,
you could do the following:
In [17]: mol = Chem.MolFromSmiles('COC.C=C')
...:
...: rxn_smarts = '([*:3].[C:1]=[C:2])>>([*:3].[*:1][*:2])'
...:
...: rxn = AllChem.ReactionFromSmarts(rxn_smarts)
...: ps = rxn.RunReactants((mol,))
...: new_mol = ps[0][0]
...: print(Chem.MolToSmiles(new_mol))
...:
...:
CC.COC
But that won't work if you don't have a second fragment there
-greg
On Mon, Jun 25, 2018 at 5:10 AM Jan Halborg Jensen
<[email protected]<mailto:[email protected]>> wrote:
The following code returns ‘CC’, i.e. the COC molecule is removed. I had a look
at the documentation for RunReactants and do not see a way to change this.
Is there any way to get the code to return ‘COC.CC’?
Thanks, Jan
mol = Chem.MolFromSmiles('COC.C=C')
rxn_smarts = '[C:1]=[C:2]>>[*:1][*:2]'
rxn = AllChem.ReactionFromSmarts(rxn_smarts)
ps = rxn.RunReactants((mol,))
new_mol = ps[0][0]
print Chem.MolToSmiles(new_mol)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org<http://slashdot.org>! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
[email protected]<mailto:[email protected]>
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss