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 <s.tondd...@gmail.com>
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 <s.tondd...@gmail.com
> > 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 <baoille...@gmail.com>
>> wrote:
>>
>>> Sorry - I did mean stuck. Maintaining stereo is tricky.
>>>
>>> On 26 Dec 2016 8:34 p.m., "Noel O'Boyle" <baoille...@gmail.com> 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" <baoille...@gmail.com> 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" <s.tondd...@gmail.com>
>>>>> 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 <baoille...@gmail.com>
>>>>>> 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" <
>>>>>>> s.tondd...@gmail.com> 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
>>>>>>>> OpenBabel-discuss@lists.sourceforge.net
>>>>>>>> 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
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss