Re: [Rdkit-discuss] Chirality conservation during atom replacement

2016-06-22 Thread Brian Kelley
Christian, 
 I believe this was a bug fix where smarts chirality wasn't respected with 
dummy atoms.  We fixed this during an investigation about r-group 
decomposition, basically stereo cores were behaving oddly.


Brian Kelley

> On Jun 22, 2016, at 10:30 AM, Kramer, Christian  
> wrote:
> 
> Hi Andrew and Greg,
> 
> thanks a lot for the quick replies.
> 
> I tested Greg's suggested solution, and it works ... but only with the RDKit 
> version 2016.03.1. With Version 2015.09.2, I still get the wrong 
> stereochemistry after fragmentation (maybe relevant for people working with 
> older versions).
> 
> Bests,
> Christian
> 
> 
> Dr. Christian Kramer
> Computer-Aided Drug Design (CADD) Scientist
> 
> F. Hoffmann-La Roche Ltd
> Pharma Research and Early Development
> Bldg. 092/2.56
> CH-4070 Basel
> 
> Phone +41 61 682 2471
> mailto: christian.kra...@roche.com
> 
> Confidentiality Note: This message is intended only for the use of the named 
> recipient(s) and may contain confidential and/or proprietary information. If 
> you are not the intended recipient, please contact the sender and delete this 
> message. Any unauthorized use of the information contained in this message is 
> prohibited.
> 
>> On Tue, Jun 21, 2016 at 5:54 PM, Andrew Dalke  
>> wrote:
>> On Jun 21, 2016, at 5:26 PM, Greg Landrum wrote:
>> > Because chirality is represented relative to the ordering of the bonds 
>> > around an atom, it's pretty difficult to do this if you want to actually 
>> > break and add bonds on your own. This would probably be somewhat easier if 
>> > there were an RWMol.ReplaceBond() method analogous to the 
>> > RWMol.ReplaceAtom() method, but that's not available at the moment.
>>...
>> > p.s. this all reminds me that there's a long email from Andrew on this 
>> > topic that I still haven't worked my way all the way through. 
>> 
>> I pretty much had to give up with working in molecule space and switch to 
>> working in SMILES space.
>> 
>> That is, I did a SMARTS match or whatever to get the atom to change, 
>> backtracked to the original SMILES, which I tokenized to find the 
>> corresponding term, then at the token level substituted in the new group.
>> 
>> What made it relatively simple was that I wanted to fragment R-groups along 
>> non-ring single bonds. In that case, I find the pair of atoms (i, j), along 
>> the bond, find the token corresponding to atom j, insert "*.*" before that 
>> token, and reparse the modified SMILES.
>> 
>> On Jun 21, 2016, at 4:50 PM, Kramer, Christian wrote:
>> > Is there a simple way of preserving chirality during splits on chiral 
>> > atoms?
>> 
>> To preserve chirality, I had to map from the new molecule space back to the 
>> original molecule space, bearing in mind the newly added atom. Then figure 
>> out which chiralities were missing in the "*.*"-inserted molecule (since an 
>> asymmetric molecule with chirality in the core might have a symmetric core 
>> after fragmentation, causing chirality information to disappear), and 
>> determine which chirality terms to put back.
>> 
>> It's very tricky.
>> 
>> I was hoping to present this as the RDKit User's Group Meeting, but I won't 
>> be able to make it. :(
>> 
>> 
>> Andrew
>> da...@dalkescientific.com
>> 
>> 
>> --
>> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
>> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
>> present their vision of the future. This family event has something for
>> everyone, including kids. Get more information and register today.
>> http://sdm.link/attshape
>> ___
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
> 
> --
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https

Re: [Rdkit-discuss] Chirality conservation during atom replacement

2016-06-22 Thread Kramer, Christian
Hi Andrew and Greg,

thanks a lot for the quick replies.

I tested Greg's suggested solution, and it works ... but only with the
RDKit version 2016.03.1. With Version 2015.09.2, I still get the wrong
stereochemistry after fragmentation (maybe relevant for people working with
older versions).

Bests,
Christian


*Dr. Christian Kramer*

Computer-Aided Drug Design (CADD) Scientist


F. Hoffmann-La Roche Ltd

Pharma Research and Early Development
Bldg. 092/2.56

CH-4070 Basel


Phone +41 61 682 2471

mailto: christian.kra...@roche.com


*Confidentiality Note: *This message is intended only for the use of the
named recipient(s) and may contain confidential and/or proprietary
information. If you are not the intended recipient, please contact the
sender and delete this message. Any unauthorized use of the information
contained in this message is prohibited.

On Tue, Jun 21, 2016 at 5:54 PM, Andrew Dalke 
wrote:

> On Jun 21, 2016, at 5:26 PM, Greg Landrum wrote:
> > Because chirality is represented relative to the ordering of the bonds
> around an atom, it's pretty difficult to do this if you want to actually
> break and add bonds on your own. This would probably be somewhat easier if
> there were an RWMol.ReplaceBond() method analogous to the
> RWMol.ReplaceAtom() method, but that's not available at the moment.
>...
> > p.s. this all reminds me that there's a long email from Andrew on this
> topic that I still haven't worked my way all the way through. 
>
> I pretty much had to give up with working in molecule space and switch to
> working in SMILES space.
>
> That is, I did a SMARTS match or whatever to get the atom to change,
> backtracked to the original SMILES, which I tokenized to find the
> corresponding term, then at the token level substituted in the new group.
>
> What made it relatively simple was that I wanted to fragment R-groups
> along non-ring single bonds. In that case, I find the pair of atoms (i, j),
> along the bond, find the token corresponding to atom j, insert "*.*" before
> that token, and reparse the modified SMILES.
>
> On Jun 21, 2016, at 4:50 PM, Kramer, Christian wrote:
> > Is there a simple way of preserving chirality during splits on chiral
> atoms?
>
> To preserve chirality, I had to map from the new molecule space back to
> the original molecule space, bearing in mind the newly added atom. Then
> figure out which chiralities were missing in the "*.*"-inserted molecule
> (since an asymmetric molecule with chirality in the core might have a
> symmetric core after fragmentation, causing chirality information to
> disappear), and determine which chirality terms to put back.
>
> It's very tricky.
>
> I was hoping to present this as the RDKit User's Group Meeting, but I
> won't be able to make it. :(
>
>
> Andrew
> da...@dalkescientific.com
>
>
>
> --
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Chirality conservation during atom replacement

2016-06-21 Thread Andrew Dalke
On Jun 21, 2016, at 5:26 PM, Greg Landrum wrote:
> Because chirality is represented relative to the ordering of the bonds around 
> an atom, it's pretty difficult to do this if you want to actually break and 
> add bonds on your own. This would probably be somewhat easier if there were 
> an RWMol.ReplaceBond() method analogous to the RWMol.ReplaceAtom() method, 
> but that's not available at the moment.
   ...
> p.s. this all reminds me that there's a long email from Andrew on this topic 
> that I still haven't worked my way all the way through. 

I pretty much had to give up with working in molecule space and switch to 
working in SMILES space.

That is, I did a SMARTS match or whatever to get the atom to change, 
backtracked to the original SMILES, which I tokenized to find the corresponding 
term, then at the token level substituted in the new group.

What made it relatively simple was that I wanted to fragment R-groups along 
non-ring single bonds. In that case, I find the pair of atoms (i, j), along the 
bond, find the token corresponding to atom j, insert "*.*" before that token, 
and reparse the modified SMILES.

On Jun 21, 2016, at 4:50 PM, Kramer, Christian wrote:
> Is there a simple way of preserving chirality during splits on chiral atoms?

To preserve chirality, I had to map from the new molecule space back to the 
original molecule space, bearing in mind the newly added atom. Then figure out 
which chiralities were missing in the "*.*"-inserted molecule (since an 
asymmetric molecule with chirality in the core might have a symmetric core 
after fragmentation, causing chirality information to disappear), and determine 
which chirality terms to put back.

It's very tricky.

I was hoping to present this as the RDKit User's Group Meeting, but I won't be 
able to make it. :(


Andrew
da...@dalkescientific.com


--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Chirality conservation during atom replacement

2016-06-21 Thread Greg Landrum
Boy is the list busy today. I love it! :-)

Because chirality is represented relative to the ordering of the bonds
around an atom, it's pretty difficult to do this if you want to actually
break and add bonds on your own. This would probably be somewhat easier if
there were an RWMol.ReplaceBond() method analogous to the
RWMol.ReplaceAtom() method, but that's not available at the moment.

However! I think you can do the fragmentation you want with the function
Chem.FragmentOnSomeBonds(). Here's your example:


In [23]: mol = Chem.MolFromSmiles("F[C@](Cl)(Br)I")

In [24]: r =
Chem.FragmentOnSomeBonds(mol,(mol.GetBondBetweenAtoms(1,0).GetIdx(),))

In [25]: r
Out[25]: (,)

In [26]: Chem.MolToSmiles(r[0],True)
Out[26]: '[*][C@](Cl)(Br)I.[1*]F'



I think that this is what you're looking for.

Best,
-greg
p.s. this all reminds me that there's a long email from Andrew on this
topic that I still haven't worked my way all the way through. 



On Tue, Jun 21, 2016 at 4:50 PM, Kramer, Christian <
christian.kra...@roche.com> wrote:

> Hi RDKitters,
>
> I am having trouble with chirality conservation during fragmentation of
> molecules. Is there a simple way of preserving chirality during splits on
> chiral atoms? Am I missing a simple function? Andrew has brought this topic
> has come up on the mailing list before, but so far there has not been a
> simple answer...
>
> Here is an example where chirality is not preserved:
>
> ---
> > import rdkit
> > rdkit.__version__
> Out[2]: '2016.03.1'
>
> > from rdkit import Chem
> > mol = Chem.MolFromSmiles("F[C@](Cl)(Br)I")
> > Chem.MolToSmiles(mol,isomericSmiles=True)
> Out[5]: 'F[C@](Cl)(Br)I'
>
> > emol = Chem.EditableMol(mol)
> > emol.RemoveBond(1,0)
> > emol.AddAtom(Chem.Atom(0))
> Out[8]: 5
>
> > emol.AddAtom(Chem.Atom(0))
> Out[9]: 6
>
> > emol.AddBond(0,5,Chem.BondType.SINGLE)
> Out[10]: 4
>
> > emol.AddBond(1,6,Chem.BondType.SINGLE)
> Out[11]: 5
>
> > new_mol = emol.GetMol()
> > Chem.MolToSmiles(new_mol,isomericSmiles=True)
> Out[13]: '[*]F.[*][C@@](Cl)(Br)I'
> -
>
> Best regards,
> Christian
>
>
> *Dr. Christian Kramer*
>
> Computer-Aided Drug Design (CADD) Scientist
>
>
> F. Hoffmann-La Roche Ltd
>
> Pharma Research and Early Development
> Bldg. 092/2.56
>
> CH-4070 Basel.
>
>
> --
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Chirality conservation during atom replacement

2016-06-21 Thread Kramer, Christian
Hi RDKitters,

I am having trouble with chirality conservation during fragmentation of
molecules. Is there a simple way of preserving chirality during splits on
chiral atoms? Am I missing a simple function? Andrew has brought this topic
has come up on the mailing list before, but so far there has not been a
simple answer...

Here is an example where chirality is not preserved:

---
> import rdkit
> rdkit.__version__
Out[2]: '2016.03.1'

> from rdkit import Chem
> mol = Chem.MolFromSmiles("F[C@](Cl)(Br)I")
> Chem.MolToSmiles(mol,isomericSmiles=True)
Out[5]: 'F[C@](Cl)(Br)I'

> emol = Chem.EditableMol(mol)
> emol.RemoveBond(1,0)
> emol.AddAtom(Chem.Atom(0))
Out[8]: 5

> emol.AddAtom(Chem.Atom(0))
Out[9]: 6

> emol.AddBond(0,5,Chem.BondType.SINGLE)
Out[10]: 4

> emol.AddBond(1,6,Chem.BondType.SINGLE)
Out[11]: 5

> new_mol = emol.GetMol()
> Chem.MolToSmiles(new_mol,isomericSmiles=True)
Out[13]: '[*]F.[*][C@@](Cl)(Br)I'
-

Best regards,
Christian


*Dr. Christian Kramer*

Computer-Aided Drug Design (CADD) Scientist


F. Hoffmann-La Roche Ltd

Pharma Research and Early Development
Bldg. 092/2.56

CH-4070 Basel.
--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss