OMEGA Examples

The following table lists the currently available Omega TK examples:

Program

Description

SimpleOmega

generating conformers

SingleConformer

generating a single conformer

DensOmega

generating densely sampled conformers

StereoAndTorsion

generating stereoisomers

TorsionDrive

torsion driving to generating conformer ensemble

MakeFraglib

making fragment library

Macrocycle

generating macrocycle conformers

SingleConformerMacrocycle

generating single macrocycle conformer

Note

If the input molecule has SD tag data, the data will be copied to every conformer in the results molecule.

Classic OEOmega Examples

Generating Conformers

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

See also

Listing 1: Generating Conformers

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
package openeye.examples.oeomega;

import openeye.oechem.*;
import openeye.oeomega.*;

public class SimpleOmega {
    public static void main(String[] args) {
        OEOmegaOptions omegaOpts = new OEOmegaOptions();
        omegaOpts.SetParameterVisibility(OEParamVisibility.Hidden);
        omegaOpts.SetParameterVisibility("-rms", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-ewindow", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-maxconfs", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-useGPU", OEParamVisibility.Simple);

        OESimpleAppOptions opts = new OESimpleAppOptions(omegaOpts, "SimpleOmega", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            System.exit(0);

        omegaOpts.UpdateValues(opts);
        OEOmega omega = new OEOmega(omegaOpts);

        oemolistream ifs = new oemolistream();
        if(!ifs.open(opts.GetInFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");
        oemolostream ofs = new oemolostream();
        if(!ofs.open(opts.GetOutFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing");

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            oechem.OEThrow.Info("Title: " + mol.GetTitle());
            boolean success = omega.call(mol);
            if(success)
                oechem.OEWriteMolecule(ofs, mol);
            else
                oechem.OEThrow.Warning(mol.GetTitle() + ": failed");
        }
        ifs.close();
        ofs.close();
    }
}

Download code

SimpleOmega.java

Generating a Single Conformer

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

See also

Listing 2: Generating a Single Conformer

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
package openeye.examples.oeomega;

import openeye.oechem.*;
import openeye.oeomega.*;

public class SingleConformer {

    public static void main(String[] args) {
        if (args.length!=2) {
            oechem.OEThrow.Usage("SingleConformer <infile> <outfile>");
        }

        oemolistream ifs = new oemolistream();
        if(!ifs.open(args[0]))
            oechem.OEThrow.Fatal("Unable to open " + args[0] + " for reading");
        oemolostream ofs = new oemolostream();
        if(!ofs.open(args[1]))
            oechem.OEThrow.Fatal("Unable to open " + args[1] + " for writing");

        OEConformerBuilder builder = new OEConformerBuilder();

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            oechem.OEThrow.Info("Title: " + mol.GetTitle());
            int retCode = builder.Build(mol);
            if(retCode == OEOmegaReturnCode.Success)
                oechem.OEWriteMolecule(ofs, mol);
            else
                oechem.OEThrow.Warning(mol.GetTitle() + ": failed with error " + retCode);
        }
        ifs.close();
        ofs.close();
    }
}

Download code

SingleConformer.java

Generating Densely Sampled Conformers

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

See also

Listing 3: Generating Densely Sampled Conformers

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
package openeye.examples.oeomega;

import openeye.oechem.*;
import openeye.oeomega.*;

public class DenseOmega {
    public static void main(String[] args) {
        OEOmegaOptions omegaOpts = new OEOmegaOptions(OEOmegaSampling.Dense);
        omegaOpts.SetParameterVisibility(OEParamVisibility.Hidden);
        omegaOpts.SetParameterVisibility("-rms", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-ewindow", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-maxconfs", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-useGPU", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-searchFF", OEParamVisibility.Simple);

        OESimpleAppOptions opts = new OESimpleAppOptions(omegaOpts, "DenseOmega", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            System.exit(0);

        omegaOpts.UpdateValues(opts);
        OEOmega omega = new OEOmega(omegaOpts);

        oemolistream ifs = new oemolistream();
        if(!ifs.open(opts.GetInFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");
        oemolostream ofs = new oemolostream();
        if(!ofs.open(opts.GetOutFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing");

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            oechem.OEThrow.Info("Title: " + mol.GetTitle());
            boolean success = omega.call(mol);
            if(success)
                oechem.OEWriteMolecule(ofs, mol);
            else
                oechem.OEThrow.Warning(mol.GetTitle() + ": failed");
        }
        ifs.close();
        ofs.close();
    }
}

Download code

DenseOmega.java

Flipper Examples

Generating Stereoisomers

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.

See also

Listing 4: Generating Stereoisomers

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
package openeye.examples.oeomega;

import openeye.oechem.*;
import openeye.oeomega.*;

public class StereoAndTorsion { 

    public static void main(String[] args) {
        OEFlipperOptions flipperOpts = new OEFlipperOptions();

        OESimpleAppOptions opts = new OESimpleAppOptions(flipperOpts, "StereoAndTorsion", OEFileStringType.Mol, OEFileStringType.Mol);
        if(oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            System.exit(0);

        flipperOpts.UpdateValues(opts);
        OEOmega omega = new OEOmega();

        oemolistream ifs = new oemolistream();
        if (!ifs.open(opts.GetInFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");

        oemolostream ofs = new oemolostream();
        if (!ofs.open(opts.GetOutFile()))
            oechem.OEThrow.Fatal("Unable to open " +  opts.GetOutFile() + " for writing");

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            oechem.OEThrow.Info("Title: " + mol.GetTitle());

            OEMolBaseIter stereo = oeomegalib.OEFlipper(mol.GetActive(), flipperOpts);
            while(stereo.hasNext()) {
                OEMol fmol = new OEMol(stereo.next());
                boolean success = omega.call(fmol);
                if(success)
                    oechem.OEWriteMolecule(ofs, fmol);
                else
                    oechem.OEThrow.Warning(fmol.GetTitle() + ": failed");
            }
        }
        ifs.close();
        ofs.close();
    }
}

Download code

StereoAndTorsion.java

Generating Torsion Driven Conformation Examples

Torsion Driving to Generating Conformer Ensemble

The following code example is a simple example of how to torsion drive from given 3D structure, to generate a conformer ensemble.

See also

Listing 5: Torsion Driving to Generating Conformer Ensemble

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
package openeye.examples.oeomega;

import openeye.oechem.*;
import openeye.oeomega.*;

public class TorsionDrive { 

    public static void main(String[] args) {
        OETorDriveOptions torOpts = new OETorDriveOptions();
        torOpts.SetParameterVisibility(OEParamVisibility.Hidden);
        torOpts.SetParameterVisibility("-rms", OEParamVisibility.Simple);
        torOpts.SetParameterVisibility("-ewindow", OEParamVisibility.Simple);
        torOpts.SetParameterVisibility("-maxconfs", OEParamVisibility.Simple);

        OESimpleAppOptions opts = new OESimpleAppOptions(torOpts, "TorsionDrive", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            System.exit(0);

        torOpts.UpdateValues(opts);
        OETorDriver tordriver = new OETorDriver(torOpts);

        oemolistream ifs = new oemolistream();
        if (!ifs.open(opts.GetInFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");

        oemolostream ofs = new oemolostream();
        if (!ofs.open(opts.GetOutFile()))
            oechem.OEThrow.Fatal("Unable to open " +  opts.GetOutFile() + " for writing");

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            oechem.OEThrow.Info("Title: " + mol.GetTitle());
            
            int retCode = tordriver.GenerateConfs(mol);
            if(retCode == OEOmegaReturnCode.Success)
                oechem.OEWriteMolecule(ofs, mol);
            else
                oechem.OEThrow.Warning(mol.GetTitle() + ": failed with error " + retCode);
        }
        ifs.close();
        ofs.close();
    }
}

Download code

TorsionDrive.java

Fragment Library generation Examples

Making Fragment Library

The following code example is a simple example of how to generate a fragment library.

Listing 6: Making Fragment Library

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
package openeye.examples.oeomega;

import openeye.oechem.*;
import openeye.oeomega.*;

public class MakeFraglib {
    public static void main(String[] args) {
        OEFragBuilderOptions libOpts = new OEFragBuilderOptions();
        libOpts.SetParameterVisibility(OEParamVisibility.Hidden);
        libOpts.SetParameterVisibility("-buildFF", OEParamVisibility.Simple);

        OESimpleAppOptions opts = new OESimpleAppOptions(libOpts, "MakeFraglib", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            System.exit(0);

        libOpts.UpdateValues(opts);
        OEMakeFragLib makefraglib = new OEMakeFragLib(libOpts);

        oemolistream ifs = new oemolistream();
        if(!ifs.open(opts.GetInFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");
        oemolostream ofs = new oemolostream();
        if(!ofs.open(opts.GetOutFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing");

        if(ofs.GetFormat() != OEFormat.OEB)
            oechem.OEThrow.Fatal("Output file has to have OEB format!");

        makefraglib.ClearFragLibs();
        makefraglib.GenerateMissingFrags(ifs, ofs);
        ifs.close();
        ofs.close();
    }
}

Download code

MakeFraglib.java

Macrocycle Examples

Generating Macrocycle Conformers

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

Listing 7: Generating Macrocycle Conformers

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
package openeye.examples.oeomega;

import openeye.oechem.*;
import openeye.oeomega.*;

public class Macrocycle {
    public static void main(String[] args) {
        OEMacrocycleOmegaOptions omegaOpts = new OEMacrocycleOmegaOptions();
        omegaOpts.SetParameterVisibility(OEParamVisibility.Hidden);
        omegaOpts.SetParameterVisibility("-rms", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-ewindow", OEParamVisibility.Simple);
        omegaOpts.SetParameterVisibility("-maxconfs", OEParamVisibility.Simple);

        OESimpleAppOptions opts = new OESimpleAppOptions(omegaOpts, "Macrocycle", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            System.exit(0);

        omegaOpts.UpdateValues(opts);
        OEMacrocycleOmega mcomega = new OEMacrocycleOmega(omegaOpts);

        oemolistream ifs = new oemolistream();
        if(!ifs.open(opts.GetInFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");
        oemolostream ofs = new oemolostream();
        if(!ofs.open(opts.GetOutFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing");

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            oechem.OEThrow.Info("Title: " + mol.GetTitle());
            int retCode = mcomega.Build(mol);
            if(retCode == OEOmegaReturnCode.Success)
                oechem.OEWriteMolecule(ofs, mol);
            else
                oechem.OEThrow.Warning(mol.GetTitle() + ": failed with error " + retCode);
        }
        ifs.close();
        ofs.close();
    }
}

Download code

Macrocycle.java

Generating a Single Macrocycle Conformer

The following code example is a simple example of how to generate a single macrocycle conformer using the OEMacrocycleBuilder object.

Listing 8: Generating a Single Macrocycle Conformer

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
package openeye.examples.oeomega;

import openeye.oechem.*;
import openeye.oeomega.*;

public class SingleConformerMacrocycle {
    public static void main(String[] args) {
        OEMacrocycleBuilderOptions buildOpts = new OEMacrocycleBuilderOptions();
        buildOpts.SetParameterVisibility(OEParamVisibility.Hidden);
        buildOpts.SetParameterVisibility("-seed", OEParamVisibility.Simple);
        buildOpts.SetParameterVisibility("-dielectric_constant", OEParamVisibility.Simple);

        OESimpleAppOptions opts = new OESimpleAppOptions(buildOpts, "SingleConformerMacrocycle", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            System.exit(0);

        buildOpts.UpdateValues(opts);

        oemolistream ifs = new oemolistream();
        if(!ifs.open(opts.GetInFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");
        oemolostream ofs = new oemolostream();
        if(!ofs.open(opts.GetOutFile()))
            oechem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing");

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) 
        {
            oechem.OEThrow.Info("Title: " + mol.GetTitle());
            int retCode = OEOmegaReturnCode.Failed;
            int itlimit = 1000;
            int itnum = 0;
            while(itnum <= itlimit)
            {
                OEMacrocycleBuilder builder = new OEMacrocycleBuilder(buildOpts);
                retCode = builder.Build(mol);
                if(retCode == OEOmegaReturnCode.Success)
                {
                    oechem.OEWriteMolecule(ofs, mol);
                    break;
                }
                else
                {
                    buildOpts.SetRandomSeed(buildOpts.GetRandomSeed()+1);
                }
                ++itnum;
            }
            if(retCode != OEOmegaReturnCode.Success)
                oechem.OEThrow.Warning(mol.GetTitle() + ": failed with error " + retCode);
        }
        ifs.close();
        ofs.close();
    }
}