Generating all cis-trans stereoisomers

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

Generating all cis-trans stereoisomers

cgram
Hi,

I am trying to generate all cis-trans stereoisomers from a molecule that initially contains no stereo data. Currently, this is my code:

import pybel
import itertools

def copy(mol):
    m = pybel.Molecule(pybel.ob.OBMol())
    for atom in mol:
        m.OBMol.AddAtom(atom.OBAtom)
    for bond in pybel.ob.OBMolBondIter(mol.OBMol):
        m.OBMol.AddBond(bond)
    return m

def generateCisTrans(mol):
    facade = pybel.ob.OBStereoFacade(mol.OBMol)

    stereo_ids = []
    for bond in pybel.ob.OBMolBondIter(mol.OBMol):
        bond_Id = bond.GetId()
        cis_trans_stereo = facade.GetCisTransStereo(bond_Id)
        if cis_trans_stereo is not None:
            stereo_ids.append(bond_Id)

    if not stereo_ids:
        yield mol
    else:
        for shape in itertools.product([1, 2], repeat=len(stereo_ids)):
            mol_tmp = copy(mol)
            facade = pybel.ob.OBStereoFacade(mol_tmp.OBMol)
            for idx, bond_id in enumerate(stereo_ids):
                cis_trans_stereo = facade.GetCisTransStereo(bond_id)
                config = cis_trans_stereo.GetConfig()
                config.shape = shape[idx]
                config.specified = True
                cis_trans_stereo.SetConfig(config)
            yield mol_tmp

moltest = pybel.readstring('smi', 'BrC=C(Cl)C(Cl)=CCl')
moltest.addh()
for mol in generateCisTrans(moltest):
    print mol

For the example molecule (as specified by the SMILES string), the code yields 4 molecules, but two of them are identical. I also tried using [1, 2, 3] in the itertools product instead of [1, 2], which yields all possible combinations, but includes a lot of extraneous ones. Overall, I am having a very hard time finding functions that make it easy to generate all stereoisomers, which I think would be a nice feature to have. Any help would be appreciated.

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Generating all cis-trans stereoisomers

Noel O'Boyle
Administrator
Looking the bits of a binary number will generate all possible
combinations of 0 and 1. E.g. the bits of 0->7 are 000, 001, 010, 011,
100, 101, 110, 111 which will allow you to handle 3 stereocenters. See
bitwise OR and bitwise SHIFT operator in Python.

- Noel

On 15 July 2016 at 00:59, cgram <[hidden email]> wrote:

> Hi,
>
> I am trying to generate all cis-trans stereoisomers from a molecule that
> initially contains no stereo data. Currently, this is my code:
>
>
>
> For the example molecule (as specified by the SMILES string), the code
> yields 4 molecules, but two of them are identical. I also tried using [1, 2,
> 3] in the itertools product instead of [1, 2], which yields all possible
> combinations, but includes a lot of extraneous ones. Overall, I am having a
> very hard time finding functions that make it easy to generate all
> stereoisomers, which I think would be a nice feature to have. Any help would
> be appreciated.
>
> Thanks!
>
>
>
> --
> View this message in context: http://forums.openbabel.org/Generating-all-cis-trans-stereoisomers-tp4659390.html
> Sent from the General discussion mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Generating all cis-trans stereoisomers

cgram
Thank you for the answer, I will look into it.

I have a more general question regarding double bonds. When generating 3D geometries, is it possible to assign which side of a double bond the substituents are on? I would like to do this even for double bonds that are not marked as stereocenters (e.g., if there are two identical substituents on one side). Perhaps this would be possible by marking bonds as stereocenters even if they are not and then using some function to assign which side of the bond the atoms are on (is there a function that enables a simple assignment like this?)
Reply | Threaded
Open this post in threaded view
|

Re: Generating all cis-trans stereoisomers

Noel O'Boyle
Administrator
(Please cc to the list)

I think that in these instances you will have to break the symmetry by
setting one of the atoms to Xe or so.

- Noel

On 15 July 2016 at 20:29, Colin Grambow <[hidden email]> wrote:

> I am attempting to generate all possible structures (under the constraints
> of breaking and forming a certain number of bonds) from a single starting
> structure without considering the underlying chemistry (at least initially).
> This means that if I form a double bond during that generation, then I will
> want to include both the cis and the trans structures, and if a double bond
> is not involved in going from the starting structure to a product structure,
> then I want to ensure that the cis/trans orientation is retained.
>
>
>
> I already have code for generating structures based on a list of bonds and
> valences, which I then use to construct pybel molecules. The next step is to
> generate the 3D geometries of the structures, which is a simple task with
> Open Babel, but I want to ensure that the correct ones are generated based
> on the stereochemical constraints I mentioned before.
>
>
>
> When asking my initial question, I was thinking that I could just generate
> all possible stereoisomers and subsequently only select the ones that match
> the starting structure based on which bonds were broken/formed, but such a
> naïve approach would result in a lot of unnecessary calculations, which I
> could avoid if I had the ability to directly create the structure with the
> desired stereochemistry.
>
>
>
>
>
> From: Noel O'Boyle [mailto:[hidden email]]
> Sent: Friday, July 15, 2016 2:56 PM
> To: cgram <[hidden email]>
> Subject: Re: [Open Babel] Generating all cis-trans stereoisomers
>
>
>
> By way of background what is the underlying problem you are trying to solve
> here?
>
>
>
> On 15 Jul 2016 6:22 p.m., "cgram" <[hidden email]> wrote:
>
> Thank you for the answer, I will look into it.
>
> I have a more general question regarding double bonds. When generating 3D
> geometries, is it possible to assign which side of a double bond the
> substituents are on? I would like to do this even for double bonds that are
> not marked as stereocenters (e.g., if there are two identical substituents
> on one side). Perhaps this would be possible by marking bonds as
> stereocenters even if they are not and then using some function to assign
> which side of the bond the atoms are on (is there a function that enables a
> simple assignment like this?)
>
>
>
> --
> View this message in context:
> http://forums.openbabel.org/Generating-all-cis-trans-stereoisomers-tp4659390p4659393.html
> Sent from the General discussion mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning
> reports.http://sdm.link/zohodev2dev
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss