OMEGA Examples¶
The following table lists the currently available Omega TK examples:
Program |
Description |
---|---|
generating conformers |
|
generating a single conformer |
|
generating densely sampled conformers |
|
generating stereoisomers |
|
torsion driving to generating conformer ensemble |
|
making fragment library |
|
generating macrocycle conformers |
|
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
OEOmegaOptions class
OEOmega class
OESimpleAppOptions class
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
Generating a Single Conformer¶
The following code example is a simple example of how to generate a single conformer.
See also
OEConformerBuilder class
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
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
OEOmegaOptions class
OEOmega class
OEOmegaSampling
namespaceOESimpleAppOptions class
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
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
OEOmegaOptions class
OEOmega class
OEFlipper function
OESimpleAppOptions class
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
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
OETorDriveOptions class
OETorDriver class
OESimpleAppOptions class
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
Fragment Library generation Examples¶
Making Fragment Library¶
The following code example is a simple example of how to generate a fragment library.
See also
OEFragBuilderOptions class
OEMakeFragLib class
OESimpleAppOptions class
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
Macrocycle Examples¶
Generating Macrocycle Conformers¶
The following code example is a simple example of how to generate conformers using the OEMacrocycleOmega object.
See also
OEMacrocycleOmegaOptions class
OEMacrocycleOmega class
OESimpleAppOptions class
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
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.
See also
OEMacrocycleBuilder class
OESimpleAppOptions class
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();
}
}
Download code