Maintaining cis/trans after fragmentation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Maintaining cis/trans after fragmentation

Sam Tonddast-Navaei
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Noel O'Boyle
Administrator

Look at the docs for OBStereoFacade and related classes. Stereo is stored in a Config object with refs to the four IDs of the atoms connected to the atoms of the double bond.


On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Geoff Hutchison
In reply to this post by Sam Tonddast-Navaei
> trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

As Noel indicated, OBStereoFacade (and related classes) are used to track stereochemistry. The "Up/Down" methods are marked deprecated - if you change the SMILES, the stereochemistry should be correct no matter what, but "up" and "down" are relative terms.

-Geoff
------------------------------------------------------------------------------
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Sam Tonddast-Navaei
In reply to this post by Noel O'Boyle
Thanks Noel, I figured it out thanks to your hint. Is there a function that allows to change the refs? It seems that in python Config.ref returns a tuple. I am trying to change the old ref_id to a new one.

Thanks for your help.

On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]> wrote:

Look at the docs for OBStereoFacade and related classes. Stereo is stored in a Config object with refs to the four IDs of the atoms connected to the atoms of the double bond.


On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Noel O'Boyle
Administrator
Configs are immutable. You need to create a new config, and then use setconfig or something like this.

On 26 Dec 2016 8:09 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Thanks Noel, I figured it out thanks to your hint. Is there a function that allows to change the refs? It seems that in python Config.ref returns a tuple. I am trying to change the old ref_id to a new one.

Thanks for your help.

On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]> wrote:

Look at the docs for OBStereoFacade and related classes. Stereo is stored in a Config object with refs to the four IDs of the atoms connected to the atoms of the double bond.


On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Noel O'Boyle
Administrator
If you are still suck, let us know and I'll put an example together.

On 26 Dec 2016 8:33 p.m., "Noel O'Boyle" <[hidden email]> wrote:
Configs are immutable. You need to create a new config, and then use setconfig or something like this.

On 26 Dec 2016 8:09 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Thanks Noel, I figured it out thanks to your hint. Is there a function that allows to change the refs? It seems that in python Config.ref returns a tuple. I am trying to change the old ref_id to a new one.

Thanks for your help.

On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]> wrote:

Look at the docs for OBStereoFacade and related classes. Stereo is stored in a Config object with refs to the four IDs of the atoms connected to the atoms of the double bond.


On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Noel O'Boyle
Administrator
Sorry - I did mean stuck. Maintaining stereo is tricky.

On 26 Dec 2016 8:34 p.m., "Noel O'Boyle" <[hidden email]> wrote:
If you are still suck, let us know and I'll put an example together.

On 26 Dec 2016 8:33 p.m., "Noel O'Boyle" <[hidden email]> wrote:
Configs are immutable. You need to create a new config, and then use setconfig or something like this.

On 26 Dec 2016 8:09 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Thanks Noel, I figured it out thanks to your hint. Is there a function that allows to change the refs? It seems that in python Config.ref returns a tuple. I am trying to change the old ref_id to a new one.

Thanks for your help.

On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]> wrote:

Look at the docs for OBStereoFacade and related classes. Stereo is stored in a Config object with refs to the four IDs of the atoms connected to the atoms of the double bond.


On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Sam Tonddast-Navaei
Hahaha, I actually do suck and still stuck :) 
An example script is always helpful and I would really appreciate it if you get a chance to

thanks again

On Mon, Dec 26, 2016 at 3:38 PM, Noel O'Boyle <[hidden email]> wrote:
Sorry - I did mean stuck. Maintaining stereo is tricky.

On 26 Dec 2016 8:34 p.m., "Noel O'Boyle" <[hidden email]> wrote:
If you are still suck, let us know and I'll put an example together.

On 26 Dec 2016 8:33 p.m., "Noel O'Boyle" <[hidden email]> wrote:
Configs are immutable. You need to create a new config, and then use setconfig or something like this.

On 26 Dec 2016 8:09 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Thanks Noel, I figured it out thanks to your hint. Is there a function that allows to change the refs? It seems that in python Config.ref returns a tuple. I am trying to change the old ref_id to a new one.

Thanks for your help.

On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]> wrote:

Look at the docs for OBStereoFacade and related classes. Stereo is stored in a Config object with refs to the four IDs of the atoms connected to the atoms of the double bond.


On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Sam Tonddast-Navaei
Hi Noel,

 I made this script:

#!/usr/bin/python
import pybel
import openbabel as ob

mol = pybel.readstring('smi','OC\C=C\Cl')
print 'OC\C=C\Cl'
facade = ob.OBStereoFacade(mol.OBMol)
a = mol.OBMol.NewAtom()
a.SetAtomicNum(9)

bonds = []
for bond in ob.OBMolBondIter(mol.OBMol):
        bonds.append(bond)
a0_index = bonds[1].GetBeginAtomIdx()   # C connected to O
b0_index = bonds[1].GetEndAtomIdx()     # first C in double-bond
b0_stereo = facade.GetCisTransStereo(b0_index-1)
b0_config = b0_stereo.GetConfig()
print b0_config.refs
mol.OBMol.DeleteBond(bonds[1])        # breaking the second bond
mol.OBMol.AddBond(b0_index, a.GetIdx(),0)
b0_config.refs = (5, 4294967294, 4, 4294967294)
b0_stereo.SetConfig(b0_config)
print b0_config.refs
print mol.write('smi')


Trying to cut the second bond in the SMILES, and then replacing the ref index of C to F in the Config using SetConfig. However at the end the final SMILES does not have stereo in it

output:

OC\C=C\Cl
(1L, 4294967294L, 4L, 4294967294L)
(5L, 4294967294L, 4L, 4294967294L)
OC.C(=CCl)F

Could you please let me know if I am missing something and how I can update the SMILES?

On Mon, Dec 26, 2016 at 3:41 PM, Sam Tonddast-Navaei <[hidden email]> wrote:
Hahaha, I actually do suck and still stuck :) 
An example script is always helpful and I would really appreciate it if you get a chance to

thanks again

On Mon, Dec 26, 2016 at 3:38 PM, Noel O'Boyle <[hidden email]> wrote:
Sorry - I did mean stuck. Maintaining stereo is tricky.

On 26 Dec 2016 8:34 p.m., "Noel O'Boyle" <[hidden email]> wrote:
If you are still suck, let us know and I'll put an example together.

On 26 Dec 2016 8:33 p.m., "Noel O'Boyle" <[hidden email]> wrote:
Configs are immutable. You need to create a new config, and then use setconfig or something like this.

On 26 Dec 2016 8:09 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Thanks Noel, I figured it out thanks to your hint. Is there a function that allows to change the refs? It seems that in python Config.ref returns a tuple. I am trying to change the old ref_id to a new one.

Thanks for your help.

On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]> wrote:

Look at the docs for OBStereoFacade and related classes. Stereo is stored in a Config object with refs to the four IDs of the atoms connected to the atoms of the double bond.


On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss





------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Sam Tonddast-Navaei
Dear colleagues,
 
 I just realized that if I add "addh()" before printing the SMILES I would get the correct transferred SMILES.

- Any clue why that makes it work?
- I also realized that in case of cis/trans stereo chemistry only one of the carbons returns "True" when calling HasCisTransStereo(atom_index). Could anyone elaborate why is this the case?

Thanks,
Sam

On Mon, Dec 26, 2016 at 5:08 PM, Sam Tonddast-Navaei <[hidden email]> wrote:
Hi Noel,

 I made this script:

#!/usr/bin/python
import pybel
import openbabel as ob

mol = pybel.readstring('smi','OC\C=C\Cl')
print 'OC\C=C\Cl'
facade = ob.OBStereoFacade(mol.OBMol)
a = mol.OBMol.NewAtom()
a.SetAtomicNum(9)

bonds = []
for bond in ob.OBMolBondIter(mol.OBMol):
        bonds.append(bond)
a0_index = bonds[1].GetBeginAtomIdx()   # C connected to O
b0_index = bonds[1].GetEndAtomIdx()     # first C in double-bond
b0_stereo = facade.GetCisTransStereo(b0_index-1)
b0_config = b0_stereo.GetConfig()
print b0_config.refs
mol.OBMol.DeleteBond(bonds[1])        # breaking the second bond
mol.OBMol.AddBond(b0_index, a.GetIdx(),0)
b0_config.refs = (5, 4294967294, 4, 4294967294)
b0_stereo.SetConfig(b0_config)
print b0_config.refs
print mol.write('smi')


Trying to cut the second bond in the SMILES, and then replacing the ref index of C to F in the Config using SetConfig. However at the end the final SMILES does not have stereo in it

output:

OC\C=C\Cl
(1L, 4294967294L, 4L, 4294967294L)
(5L, 4294967294L, 4L, 4294967294L)
OC.C(=CCl)F

Could you please let me know if I am missing something and how I can update the SMILES?

On Mon, Dec 26, 2016 at 3:41 PM, Sam Tonddast-Navaei <[hidden email]> wrote:
Hahaha, I actually do suck and still stuck :) 
An example script is always helpful and I would really appreciate it if you get a chance to

thanks again

On Mon, Dec 26, 2016 at 3:38 PM, Noel O'Boyle <[hidden email]> wrote:
Sorry - I did mean stuck. Maintaining stereo is tricky.

On 26 Dec 2016 8:34 p.m., "Noel O'Boyle" <[hidden email]> wrote:
If you are still suck, let us know and I'll put an example together.

On 26 Dec 2016 8:33 p.m., "Noel O'Boyle" <[hidden email]> wrote:
Configs are immutable. You need to create a new config, and then use setconfig or something like this.

On 26 Dec 2016 8:09 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Thanks Noel, I figured it out thanks to your hint. Is there a function that allows to change the refs? It seems that in python Config.ref returns a tuple. I am trying to change the old ref_id to a new one.

Thanks for your help.

On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]> wrote:

Look at the docs for OBStereoFacade and related classes. Stereo is stored in a Config object with refs to the four IDs of the atoms connected to the atoms of the double bond.


On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei" <[hidden email]> wrote:
Hello all,

 I am trying to break a molecule into two fragments using Pybel yet keeping the cis/trans stereochemisty information at the cleavage point when I substitute it by a dummy atom. Currently I am trying to copy the bond property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot he dummy atoms). However I figured out that both functions are returning False values.

I did a loop over all bonds and printed the following:

for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
        
        print temp_bond.GetIdx(), temp_bond.GetBO(), temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()

SMILES: OCCCC#CC#C/C=C/C(=O)OC
0 1 False False False
1 1 False False False
2 1 False False False
3 1 False False False
4 3 False False False
5 1 False False False
6 3 False False False
7 1 False False False
8 2 False False False
9 1 False False False
10 2 False False False
11 1 False False False
12 1 False False False 

Can someone help me what I am missing here and whether there is a smarter way of doing this?

Thanks for your time,
Sam 

------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss






------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Noel O'Boyle
Administrator
You have an off-by-one due to a misunderstanding of where the stereo
is stored. For cis-trans stereo, the stereobond is the double bond,
not the up/down single bonds. On top of this, the stereo code uses
atom Ids and not atom indices (I can't remember the rationale for
this). Anyhoo, here is a working piece of code that does what you
want:

import pybel
import openbabel as ob

mol = pybel.readstring('smi','OC\C=C\Cl')
m = mol.OBMol

# Add a chlorine atom to the molecule
a = m.NewAtom()
a.SetAtomicNum(9)

# Get the stereo bond - note! this is the double bond
stereobond = m.GetBond(2) # This is the third bond (when read from the
SMILES above)
assert stereobond.GetBO() == 2

facade = ob.OBStereoFacade(mol.OBMol)
stereo = facade.GetCisTransStereo(stereobond.GetId()) # Note use of
GetId() not GetIdx()
config = stereo.GetConfig()
print config.refs

mol.OBMol.DeleteBond(m.GetBond(1)) # breaking the second bond
mol.OBMol.AddBond(3, a.GetIdx(), 1)

# Note that the refs uses atom Ids (4294967294 is used to mark an
implicit stereo ref)
config.refs = (a.GetId(), 4294967294, 4, 4294967294)
stereo.SetConfig(config)

print mol.write('smi')  # OC.C(=C\Cl)/F


On 27 December 2016 at 03:30, Sam Tonddast-Navaei <[hidden email]> wrote:

> Dear colleagues,
>
>  I just realized that if I add "addh()" before printing the SMILES I would
> get the correct transferred SMILES.
>
> - Any clue why that makes it work?
> - I also realized that in case of cis/trans stereo chemistry only one of the
> carbons returns "True" when calling HasCisTransStereo(atom_index). Could
> anyone elaborate why is this the case?
>
> Thanks,
> Sam
>
> On Mon, Dec 26, 2016 at 5:08 PM, Sam Tonddast-Navaei <[hidden email]>
> wrote:
>>
>> Hi Noel,
>>
>>  I made this script:
>>
>>> #!/usr/bin/python
>>> import pybel
>>> import openbabel as ob
>>>
>>> mol = pybel.readstring('smi','OC\C=C\Cl')
>>> print 'OC\C=C\Cl'
>>> facade = ob.OBStereoFacade(mol.OBMol)
>>> a = mol.OBMol.NewAtom()
>>> a.SetAtomicNum(9)
>>>
>>> bonds = []
>>> for bond in ob.OBMolBondIter(mol.OBMol):
>>>         bonds.append(bond)
>>> a0_index = bonds[1].GetBeginAtomIdx()   # C connected to O
>>> b0_index = bonds[1].GetEndAtomIdx()     # first C in double-bond
>>> b0_stereo = facade.GetCisTransStereo(b0_index-1)
>>> b0_config = b0_stereo.GetConfig()
>>> print b0_config.refs
>>> mol.OBMol.DeleteBond(bonds[1])        # breaking the second bond
>>> mol.OBMol.AddBond(b0_index, a.GetIdx(),0)
>>> b0_config.refs = (5, 4294967294, 4, 4294967294)
>>> b0_stereo.SetConfig(b0_config)
>>> print b0_config.refs
>>> print mol.write('smi')
>>
>>
>> Trying to cut the second bond in the SMILES, and then replacing the ref
>> index of C to F in the Config using SetConfig. However at the end the final
>> SMILES does not have stereo in it
>>
>> output:
>>
>>> OC\C=C\Cl
>>> (1L, 4294967294L, 4L, 4294967294L)
>>> (5L, 4294967294L, 4L, 4294967294L)
>>> OC.C(=CCl)F
>>
>>
>> Could you please let me know if I am missing something and how I can
>> update the SMILES?
>>
>> On Mon, Dec 26, 2016 at 3:41 PM, Sam Tonddast-Navaei
>> <[hidden email]> wrote:
>>>
>>> Hahaha, I actually do suck and still stuck :)
>>> An example script is always helpful and I would really appreciate it if
>>> you get a chance to
>>>
>>> thanks again
>>>
>>> On Mon, Dec 26, 2016 at 3:38 PM, Noel O'Boyle <[hidden email]>
>>> wrote:
>>>>
>>>> Sorry - I did mean stuck. Maintaining stereo is tricky.
>>>>
>>>> On 26 Dec 2016 8:34 p.m., "Noel O'Boyle" <[hidden email]> wrote:
>>>>>
>>>>> If you are still suck, let us know and I'll put an example together.
>>>>>
>>>>> On 26 Dec 2016 8:33 p.m., "Noel O'Boyle" <[hidden email]> wrote:
>>>>>>
>>>>>> Configs are immutable. You need to create a new config, and then use
>>>>>> setconfig or something like this.
>>>>>>
>>>>>> On 26 Dec 2016 8:09 p.m., "Sam Tonddast-Navaei" <[hidden email]>
>>>>>> wrote:
>>>>>>>
>>>>>>> Thanks Noel, I figured it out thanks to your hint. Is there a
>>>>>>> function that allows to change the refs? It seems that in python Config.ref
>>>>>>> returns a tuple. I am trying to change the old ref_id to a new one.
>>>>>>>
>>>>>>> Thanks for your help.
>>>>>>>
>>>>>>> On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Look at the docs for OBStereoFacade and related classes. Stereo is
>>>>>>>> stored in a Config object with refs to the four IDs of the atoms connected
>>>>>>>> to the atoms of the double bond.
>>>>>>>>
>>>>>>>>
>>>>>>>> On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei"
>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>
>>>>>>>>> Hello all,
>>>>>>>>>
>>>>>>>>>  I am trying to break a molecule into two fragments using Pybel yet
>>>>>>>>> keeping the cis/trans stereochemisty information at the cleavage point when
>>>>>>>>> I substitute it by a dummy atom. Currently I am trying to copy the bond
>>>>>>>>> property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot
>>>>>>>>> he dummy atoms). However I figured out that both functions are returning
>>>>>>>>> False values.
>>>>>>>>>
>>>>>>>>> I did a loop over all bonds and printed the following:
>>>>>>>>>
>>>>>>>>>> for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
>>>>>>>>>>
>>>>>>>>>>         print temp_bond.GetIdx(), temp_bond.GetBO(),
>>>>>>>>>> temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> SMILES: OCCCC#CC#C/C=C/C(=O)OC
>>>>>>>>>> 0 1 False False False
>>>>>>>>>> 1 1 False False False
>>>>>>>>>> 2 1 False False False
>>>>>>>>>> 3 1 False False False
>>>>>>>>>> 4 3 False False False
>>>>>>>>>> 5 1 False False False
>>>>>>>>>> 6 3 False False False
>>>>>>>>>> 7 1 False False False
>>>>>>>>>> 8 2 False False False
>>>>>>>>>> 9 1 False False False
>>>>>>>>>> 10 2 False False False
>>>>>>>>>> 11 1 False False False
>>>>>>>>>> 12 1 False False False
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Can someone help me what I am missing here and whether there is a
>>>>>>>>> smarter way of doing this?
>>>>>>>>>
>>>>>>>>> Thanks for your time,
>>>>>>>>> Sam
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> OpenBabel-discuss mailing list
>>>>>>>>> [hidden email]
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>>>>>>>>>
>>>>>>>
>>>
>>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining cis/trans after fragmentation

Sam Tonddast-Navaei
Thanks Noel, it works like a charm!

On Wed, Dec 28, 2016 at 8:13 AM, Noel O'Boyle <[hidden email]> wrote:
You have an off-by-one due to a misunderstanding of where the stereo
is stored. For cis-trans stereo, the stereobond is the double bond,
not the up/down single bonds. On top of this, the stereo code uses
atom Ids and not atom indices (I can't remember the rationale for
this). Anyhoo, here is a working piece of code that does what you
want:

import pybel
import openbabel as ob

mol = pybel.readstring('smi','OC\C=C\Cl')
m = mol.OBMol

# Add a chlorine atom to the molecule
a = m.NewAtom()
a.SetAtomicNum(9)

# Get the stereo bond - note! this is the double bond
stereobond = m.GetBond(2) # This is the third bond (when read from the
SMILES above)
assert stereobond.GetBO() == 2

facade = ob.OBStereoFacade(mol.OBMol)
stereo = facade.GetCisTransStereo(stereobond.GetId()) # Note use of
GetId() not GetIdx()
config = stereo.GetConfig()
print config.refs

mol.OBMol.DeleteBond(m.GetBond(1)) # breaking the second bond
mol.OBMol.AddBond(3, a.GetIdx(), 1)

# Note that the refs uses atom Ids (4294967294 is used to mark an
implicit stereo ref)
config.refs = (a.GetId(), 4294967294, 4, 4294967294)
stereo.SetConfig(config)

print mol.write('smi')  # OC.C(=C\Cl)/F


On 27 December 2016 at 03:30, Sam Tonddast-Navaei <[hidden email]> wrote:
> Dear colleagues,
>
>  I just realized that if I add "addh()" before printing the SMILES I would
> get the correct transferred SMILES.
>
> - Any clue why that makes it work?
> - I also realized that in case of cis/trans stereo chemistry only one of the
> carbons returns "True" when calling HasCisTransStereo(atom_index). Could
> anyone elaborate why is this the case?
>
> Thanks,
> Sam
>
> On Mon, Dec 26, 2016 at 5:08 PM, Sam Tonddast-Navaei <[hidden email]>
> wrote:
>>
>> Hi Noel,
>>
>>  I made this script:
>>
>>> #!/usr/bin/python
>>> import pybel
>>> import openbabel as ob
>>>
>>> mol = pybel.readstring('smi','OC\C=C\Cl')
>>> print 'OC\C=C\Cl'
>>> facade = ob.OBStereoFacade(mol.OBMol)
>>> a = mol.OBMol.NewAtom()
>>> a.SetAtomicNum(9)
>>>
>>> bonds = []
>>> for bond in ob.OBMolBondIter(mol.OBMol):
>>>         bonds.append(bond)
>>> a0_index = bonds[1].GetBeginAtomIdx()   # C connected to O
>>> b0_index = bonds[1].GetEndAtomIdx()     # first C in double-bond
>>> b0_stereo = facade.GetCisTransStereo(b0_index-1)
>>> b0_config = b0_stereo.GetConfig()
>>> print b0_config.refs
>>> mol.OBMol.DeleteBond(bonds[1])        # breaking the second bond
>>> mol.OBMol.AddBond(b0_index, a.GetIdx(),0)
>>> b0_config.refs = (5, 4294967294, 4, 4294967294)
>>> b0_stereo.SetConfig(b0_config)
>>> print b0_config.refs
>>> print mol.write('smi')
>>
>>
>> Trying to cut the second bond in the SMILES, and then replacing the ref
>> index of C to F in the Config using SetConfig. However at the end the final
>> SMILES does not have stereo in it
>>
>> output:
>>
>>> OC\C=C\Cl
>>> (1L, 4294967294L, 4L, 4294967294L)
>>> (5L, 4294967294L, 4L, 4294967294L)
>>> OC.C(=CCl)F
>>
>>
>> Could you please let me know if I am missing something and how I can
>> update the SMILES?
>>
>> On Mon, Dec 26, 2016 at 3:41 PM, Sam Tonddast-Navaei
>> <[hidden email]> wrote:
>>>
>>> Hahaha, I actually do suck and still stuck :)
>>> An example script is always helpful and I would really appreciate it if
>>> you get a chance to
>>>
>>> thanks again
>>>
>>> On Mon, Dec 26, 2016 at 3:38 PM, Noel O'Boyle <[hidden email]>
>>> wrote:
>>>>
>>>> Sorry - I did mean stuck. Maintaining stereo is tricky.
>>>>
>>>> On 26 Dec 2016 8:34 p.m., "Noel O'Boyle" <[hidden email]> wrote:
>>>>>
>>>>> If you are still suck, let us know and I'll put an example together.
>>>>>
>>>>> On 26 Dec 2016 8:33 p.m., "Noel O'Boyle" <[hidden email]> wrote:
>>>>>>
>>>>>> Configs are immutable. You need to create a new config, and then use
>>>>>> setconfig or something like this.
>>>>>>
>>>>>> On 26 Dec 2016 8:09 p.m., "Sam Tonddast-Navaei" <[hidden email]>
>>>>>> wrote:
>>>>>>>
>>>>>>> Thanks Noel, I figured it out thanks to your hint. Is there a
>>>>>>> function that allows to change the refs? It seems that in python Config.ref
>>>>>>> returns a tuple. I am trying to change the old ref_id to a new one.
>>>>>>>
>>>>>>> Thanks for your help.
>>>>>>>
>>>>>>> On Sun, Nov 20, 2016 at 5:38 AM, Noel O'Boyle <[hidden email]>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Look at the docs for OBStereoFacade and related classes. Stereo is
>>>>>>>> stored in a Config object with refs to the four IDs of the atoms connected
>>>>>>>> to the atoms of the double bond.
>>>>>>>>
>>>>>>>>
>>>>>>>> On 19 Nov 2016 11:35 p.m., "Sam Tonddast-Navaei"
>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>
>>>>>>>>> Hello all,
>>>>>>>>>
>>>>>>>>>  I am trying to break a molecule into two fragments using Pybel yet
>>>>>>>>> keeping the cis/trans stereochemisty information at the cleavage point when
>>>>>>>>> I substitute it by a dummy atom. Currently I am trying to copy the bond
>>>>>>>>> property (IsUp or IsDown) and assign it to the new bonds (bonds assign tot
>>>>>>>>> he dummy atoms). However I figured out that both functions are returning
>>>>>>>>> False values.
>>>>>>>>>
>>>>>>>>> I did a loop over all bonds and printed the following:
>>>>>>>>>
>>>>>>>>>> for temp_bond in openbabel.OBMolBondIter(mol2.OBMol):
>>>>>>>>>>
>>>>>>>>>>         print temp_bond.GetIdx(), temp_bond.GetBO(),
>>>>>>>>>> temp_bond.IsDown(), temp_bond.IsUp(), temp_bond.IsCisOrTrans()
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> SMILES: OCCCC#CC#C/C=C/C(=O)OC
>>>>>>>>>> 0 1 False False False
>>>>>>>>>> 1 1 False False False
>>>>>>>>>> 2 1 False False False
>>>>>>>>>> 3 1 False False False
>>>>>>>>>> 4 3 False False False
>>>>>>>>>> 5 1 False False False
>>>>>>>>>> 6 3 False False False
>>>>>>>>>> 7 1 False False False
>>>>>>>>>> 8 2 False False False
>>>>>>>>>> 9 1 False False False
>>>>>>>>>> 10 2 False False False
>>>>>>>>>> 11 1 False False False
>>>>>>>>>> 12 1 False False False
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Can someone help me what I am missing here and whether there is a
>>>>>>>>> smarter way of doing this?
>>>>>>>>>
>>>>>>>>> Thanks for your time,
>>>>>>>>> Sam
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> OpenBabel-discuss mailing list
>>>>>>>>> [hidden email]
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>>>>>>>>>
>>>>>>>
>>>
>>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss