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
Flipper 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) 2020 OpenEye Scientific Software Inc. All rights reserved.

TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of OpenEye products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. OpenEye 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 OpenEye 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 OpenEye be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEOmega;

public class SimpleOmega 
{
    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);

        OESimpleAppOptions opts = new OESimpleAppOptions(omegaOpts, "SimpleOmega", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(OEChem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            Environment.Exit(1);

        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(mol.GetTitle());
            bool success = omega.Call(mol);
            if (success) 
                OEChem.OEWriteMolecule(ofs, mol);        
            else
                OEChem.OEThrow.Warning(mol.GetTitle() + ": failed");
        }
    }
}

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) 2020 OpenEye Scientific Software Inc. All rights reserved.

TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of OpenEye products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. OpenEye 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 OpenEye 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 OpenEye be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
using System;

using OpenEye.OEChem;
using OpenEye.OEOmega;

public class SingleConformer
{
    public static int 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());
            uint retCode = builder.Build(mol);
            if(retCode == OEOmegaReturnCode.Success)
                OEChem.OEWriteMolecule(ofs, mol);
            else
                OEChem.OEThrow.Warning(mol.GetTitle() + ": failed with error " + retCode);
        }
        return 0;
    }
}

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) 2020 OpenEye Scientific Software Inc. All rights reserved.

TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of OpenEye products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. OpenEye 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 OpenEye 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 OpenEye be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEOmega;

public class DenseOmega 
{
    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);

        OESimpleAppOptions opts = new OESimpleAppOptions(omegaOpts, "DenseOmega", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(OEChem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            Environment.Exit(1);

        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(mol.GetTitle());
            bool success = omega.Call(mol);
            if (success) 
                OEChem.OEWriteMolecule(ofs, mol);        
            else
                OEChem.OEThrow.Warning(mol.GetTitle() + ": failed");
        }
    }
}

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) 2020 OpenEye Scientific Software Inc. All rights reserved.

TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of OpenEye products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. OpenEye 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 OpenEye 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 OpenEye be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
using System;

using OpenEye.OEChem;
using OpenEye.OEOmega;

public class StereoAndTorsion
{
    public static int 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);

        OESimpleAppOptions opts = new OESimpleAppOptions(omegaOpts, "StereoAndTorsion", OEFileStringType.Mol, OEFileStringType.Mol3D);
        if(OEChem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
            Environment.Exit(1);

        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(mol.GetTitle());
            foreach (OEMolBase fmol in OEOmegalib.OEFlipper(mol.GetActive(), 12, true))
            {
                bool success = omega.Call(mol);
                if(success)
                    OEChem.OEWriteMolecule(ofs, mol);
                else
                    OEChem.OEThrow.Warning(mol.GetTitle() + ": failed");
            }
        }
        return 0;
    }
}

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) 2020 OpenEye Scientific Software Inc. All rights reserved.

TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of OpenEye products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. OpenEye 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 OpenEye 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 OpenEye be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEOmega;

public class TorsionDrive 
{
    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)
            Environment.Exit(1);

        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(mol.GetTitle());
            uint retCode = tordriver.GenerateConfs(mol);
            if(retCode == OEOmegaReturnCode.Success)
                OEChem.OEWriteMolecule(ofs, mol);
            else
                OEChem.OEThrow.Warning(mol.GetTitle() + ": failed with error " + retCode);
        }
    }
}

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) 2020 OpenEye Scientific Software Inc. All rights reserved.

TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of OpenEye products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. OpenEye 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 OpenEye 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 OpenEye be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
using System;

using OpenEye.OEChem;
using OpenEye.OEOmega;

public class MakeFraglib
{
    public static int 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)
           Environment.Exit(1);

        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);
        return 0;
    }
}

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) 2020 OpenEye Scientific Software Inc. All rights reserved.

TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of OpenEye products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. OpenEye 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 OpenEye 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 OpenEye be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEOmega;

public class Macrocycle 
{
    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)
            Environment.Exit(1);

        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(mol.GetTitle());
            uint retCode = mcomega.Build(mol);
            if(retCode == OEOmegaReturnCode.Success)
                OEChem.OEWriteMolecule(ofs, mol);
            else
                OEChem.OEThrow.Warning(mol.GetTitle() + ": failed with error " + retCode);
        }
    }
}

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) 2020 OpenEye Scientific Software Inc. All rights reserved.

TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of OpenEye products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. OpenEye 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 OpenEye 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 OpenEye be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEOmega;

public class SingleConformerMacrocycle 
{
    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)
            Environment.Exit(1);

        buildOpts.UpdateValues(opts);
        OEMacrocycleBuilder builder = new OEMacrocycleBuilder(buildOpts);

        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(mol.GetTitle());
            uint retCode = builder.Build(mol);
            if(retCode == OEOmegaReturnCode.Success)
                OEChem.OEWriteMolecule(ofs, mol);
            else
                OEChem.OEThrow.Warning(mol.GetTitle() + ": failed with error " + retCode);
        }
    }
}