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

//*****************************************************************************
//*  Copyright (C) 2017 OpenEye Scientific Software, Inc.
//*****************************************************************************
using System;
using OpenEye.OEChem;
using OpenEye.OEOmega;

public class SimpleOmega 
{
    static void Main(string[] args)
    {
        if (args.Length!=2) 
        {
            Console.WriteLine("SimpleOmega <infile> <outfile>");
            Environment.Exit(1);
        }

        oemolistream ifs = new oemolistream(args[0]);
        oemolostream ofs = new oemolostream(args[1]);

        OEOmegaOptions omOpts = new OEOmegaOptions();
        OEOmega om = new OEOmega(omOpts);

        OEMol mol = new OEMol();
        while (OEChem.OEReadMolecule(ifs, mol)) 
        {
            Console.WriteLine(mol.GetTitle());
            bool res = om.Call(mol);
            if (res && mol.IsValid()) 
            {
                OEChem.OEWriteMolecule(ofs, mol);        
            }
        }
    }
}

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

Listing 2: Generating a Single Conformer

/******************************************************************************
 * Copyright (C) 2011-2017 OpenEye Scientific Software, Inc.
 *****************************************************************************/
using System;

using OpenEye.OEChem;
using OpenEye.OEOmega;

public class SimpleOmicron
{
    public static int Main(String[] args)
    {
        if (args.Length!=2)
        {
            OEChem.OEThrow.Usage("SimpleOmicron <infile> <outfile>");
        }

        OEChem.OEThrow.SetLevel(OEErrorLevel.Info);

        oemolistream ifs = new oemolistream(args[0]);
        oemolostream ofs = new oemolostream(args[1]);

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

        OEMol mol = new OEMol();
        while (OEChem.OEReadMolecule(ifs, mol))
        {
            Console.WriteLine(mol.GetTitle());
            omega.Call(mol);
            OEChem.OEWriteMolecule(ofs, mol);
        }
        return 0;
    }
}

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

//*****************************************************************************
//*  Copyright (C) 2017 OpenEye Scientific Software, Inc.
//*****************************************************************************
using System;
using OpenEye.OEChem;
using OpenEye.OEOmega;

public class DensOmega 
{
    static void Main(string[] args)
    {
        if (args.Length!=2) 
        {
            Console.WriteLine("SimpleOmega <infile> <outfile>");
            Environment.Exit(1);
        }

        oemolistream ifs = new oemolistream(args[0]);
        oemolostream ofs = new oemolostream(args[1]);

        OEOmegaOptions omOpts = new OEOmegaOptions(OEOmegaSampling.Dense);
        OEOmega om = new OEOmega(omOpts);

        OEMol mol = new OEMol();
        while (OEChem.OEReadMolecule(ifs, mol)) 
        {
            Console.WriteLine(mol.GetTitle());
            bool res = om.Call(mol);
            if (res && mol.IsValid()) 
            {
                OEChem.OEWriteMolecule(ofs, mol);        
            }
        }
    }
}

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

/******************************************************************************
 * Copyright (C) 2011 OpenEye Scientific Software, Inc.
 *****************************************************************************/
using System;

using OpenEye.OEChem;
using OpenEye.OEOmega;

public class Flipper
{
    public static int Main(String[] args)
    {
        if (args.Length != 1)
        {
            OEChem.OEThrow.Usage("Flipper <infile>");
        }
        oemolistream ifs = new oemolistream(args[0]);
        OEMol mol = new OEMol();
        while (OEChem.OEReadMolecule(ifs, mol))
        {
            Console.WriteLine(mol.GetTitle());
            Console.WriteLine("  " + OEChem.OECreateCanSmiString(mol));
            foreach (OEMolBase fmol in OEOmegalib.OEFlipper(mol))
            {
                Console.WriteLine("    " + OEChem.OECreateIsoSmiString(fmol));
            }
        }
        return 0;
    }
}