OMEGA Examples

OEOmega Examples

The following code example is a simple example of how to generate conformers using the OEOmega object.

Listing 1: Generating Conformers

#!/usr/bin/env python
################################################################
#  Copyright (C) 2006-2017 OpenEye Scientific Software, Inc.
################################################################
import sys
from openeye.oechem import *
from openeye.oeomega import *

def main(argv=[__name__]):
    if len(argv) != 3:
        OEThrow.Usage("%s <infile> <outfile>" % argv[0])

    ifs = oemolistream()
    if not ifs.open(argv[1]):
        OEThrow.Fatal("Unable to open %s for reading" % argv[1])

    ofs = oemolostream()
    if not ofs.open(argv[2]):
        OEThrow.Fatal("Unable to open %s for writing" % argv[2])

    omegaOpts = OEOmegaOptions()
    omega = OEOmega(omegaOpts)

    for mol in ifs.GetOEMols():
        OEThrow.Info("Title: %s" % mol.GetTitle())
        if omega(mol):
            OEWriteMolecule(ofs, mol)
    
    return 0

if __name__ == "__main__":
    sys.exit(main(sys.argv))

The following code example is a simple example of how to generate a single conformer.

Listing 2: Generating a Single Conformer

#!/usr/bin/env python
################################################################
#  Copyright (C) 2006-2017 OpenEye Scientific Software, Inc.
################################################################
import sys
from openeye.oechem import *
from openeye.oeomega import *

def main(argv=[__name__]):
    if len(argv) != 3:
        OEThrow.Usage("%s <infile> <outfile>" % argv[0])

    ifs = oemolistream()
    if not ifs.open(argv[1]):
        OEThrow.Fatal("Unable to open %s for reading" % argv[1])

    ofs = oemolostream()
    if not ofs.open(argv[2]):
        OEThrow.Fatal("Unable to open %s for writing" % argv[2])

    omegaOpts = OEOmegaOptions()
    omegaOpts.SetMaxConfs(1)
    omega = OEOmega(omegaOpts)

    for mol in ifs.GetOEMols():
        OEThrow.Info("Title: %s" % mol.GetTitle())
        if omega(mol):
            OEWriteMolecule(ofs, mol)
            
    return 0

if __name__ == "__main__":
    sys.exit(main(sys.argv))

The following code example is a simple example of how to generate densely sampled conformers, as used in OEFreeFormConf calculations, using the OEOmega object.

Listing 3: Generating Densely Sampled Conformers

#!/usr/bin/env python
################################################################
#  Copyright (C) 2006-2017 OpenEye Scientific Software, Inc.
################################################################
import sys
from openeye.oechem import *
from openeye.oeomega import *

def main(argv=[__name__]):
    if len(argv) != 3:
        OEThrow.Usage("%s <infile> <outfile>" % argv[0])

    ifs = oemolistream()
    if not ifs.open(argv[1]):
        OEThrow.Fatal("Unable to open %s for reading" % argv[1])

    ofs = oemolostream()
    if not ofs.open(argv[2]):
        OEThrow.Fatal("Unable to open %s for writing" % argv[2])

    omegaOpts = OEOmegaOptions(OEOmegaSampling_Dense)
    omega = OEOmega(omegaOpts)

    for mol in ifs.GetOEMols():
        OEThrow.Info("Title: %s" % mol.GetTitle())
        if omega(mol):
            OEWriteMolecule(ofs, mol)
    
    return 0

if __name__ == "__main__":
    sys.exit(main(sys.argv))

Flipper Examples

The following code example is a simple example of how to use the OEFlipper function to generate stereoisomers. The code example also demonstrates that stereoisomers should be generated before generating conformers.

Listing 4: Generating Stereoisomers

#!/usr/bin/env python
################################################################
#  Copyright (C) 2006-2017 OpenEye Scientific Software, Inc.
################################################################
import sys
from openeye.oechem import *
from openeye.oeomega import *

def main(argv=[__name__]):
    if len(argv) != 3:
        OEThrow.Usage("%s <infile> <outfile>" % argv[0])

    ifs = oemolistream()
    if not ifs.open(argv[1]):
        OEThrow.Fatal("Unable to open %s for reading" % argv[1])

    ofs = oemolostream()
    if not ofs.open(argv[2]):
        OEThrow.Fatal("Unable to open %s for writing" % argv[2])

    omegaOpts = OEOmegaOptions()
    omega = OEOmega(omegaOpts)
    for mol in ifs.GetOEMols():
        OEThrow.Info("Title: %s" % mol.GetTitle())

        for enantiomer in OEFlipper(mol.GetActive(), 12, True):
            enantiomer = OEMol(enantiomer)
            if omega(enantiomer):
                OEWriteMolecule(ofs, enantiomer)
            
    return 0

if __name__ == "__main__":
    sys.exit(main(sys.argv))