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 2004-2017 OpenEye Scientific Software, Inc.
 *****************************************************************************/
package openeye.examples.oeomega;

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

public class SimpleOmega {
    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("SimpleOmega <infile> <outfile>");
            System.exit(0);
        }

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

        OEOmegaOptions opts = new OEOmegaOptions();
        OEOmega omega = new OEOmega(opts);

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            String title = mol.GetTitle();
            if (title.length() != 0) System.out.println(title);
            boolean res = omega.call(mol);
            if (res && mol.IsValid()) {
                oechem.OEWriteMolecule(ofs, mol);        
            }
        }
        ifs.close();
        ofs.close();
    }
}

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

Listing 2: Generating a Single Conformer

/******************************************************************************
 * Copyright 2004-2017 OpenEye Scientific Software, Inc.
 *****************************************************************************/
package openeye.examples.oeomega;

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

public class SimpleOmicron {

    public static void 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)) {
            System.out.println(mol.GetTitle());
            omega.call(mol);
            oechem.OEWriteMolecule(ofs, mol);
        }
        ifs.close();
        ofs.close();
    }
}

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 2004-2017 OpenEye Scientific Software, Inc.
 *****************************************************************************/
package openeye.examples.oeomega;

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

public class DensOmega {
    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("SimpleOmega <infile> <outfile>");
            System.exit(0);
        }

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

        OEOmegaOptions omegaOpts = new OEOmegaOptions(OEOmegaSampling.Dense);
        OEOmega omega = new OEOmega(omegaOpts);

        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            String title = mol.GetTitle();
            if (title.length() != 0) System.out.println(title);
            boolean res = omega.call(mol);
            if (res && mol.IsValid()) {
                oechem.OEWriteMolecule(ofs, mol);        
            }
        }
        ifs.close();
        ofs.close();
    }
}

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) 2008-2017 OpenEye Scientific Software, Inc.
***********************************************************************/

package openeye.examples.oeomega;

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

public class StereoAndTorsion { 

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

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

        oemolostream ofs = new oemolostream();
        if (!ofs.open(args[1])) { 
            ifs.close();
            oechem.OEThrow.Fatal("Unable to open " +  args[2] + " for writing");
        }

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

            OEMolBaseIter stereo = oeomegalib.OEFlipper(mol.GetActive(), 12, true);
            while(stereo.hasNext()) {
                mol = new OEMol(stereo.next());
                if (omega.call(mol))
                    oechem.OEWriteMolecule(ofs, mol);
            }
        }
        ifs.close();
        ofs.close();
    }
}