OMEGA Examples

The following table lists the currently available Omega TK examples:

Program Description
simple_omega generating conformers
single_conformer generating a single conformer
dens_omega generating densely sampled conformers
stereo_and_torsion generating stereoisomers
torsion_drive torsion driving to generating conformer ensemble
make_fraglib making fragment library
macrocycle generating macrocycle conformers
single_conf_macrocycle generating single macrocycle conformer

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) 2017 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.
*/

#include <openeye.h>

#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oeomega2.h>

using namespace std;
using namespace OEPlatform;
using namespace OESystem;
using namespace OEChem;
using namespace OEConfGen;

int main(int argc, char *argv[])
{
  if (argc != 3)
    OEThrow.Usage("simple_omega <infile> <outfile>");

  oemolistream ifs;
  if (!ifs.open(argv[1]))
    OEThrow.Fatal("Unable to open %s for reading", argv[1]);

  oemolostream ofs;
  if (!ofs.open(argv[2]))
    OEThrow.Fatal("Unable to open %s for writing", argv[2]);

  if (!OEIs3DFormat(ofs.GetFormat()))
    OEThrow.Fatal("Invalid output file format for 3D coordinates!");

  OEOmegaOptions omegaOpts;
  OEOmega omega(omegaOpts);

  OEMol mol;
  while (OEReadMolecule(ifs, mol))
  {
    OEThrow.Info("Title: %s", mol.GetTitle());
    if (omega(mol))
      OEWriteMolecule(ofs, mol);
  }
  
  return 0;
}

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) 2017 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.
*/

#include <openeye.h>

#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oeomega2.h>

using namespace std;
using namespace OEPlatform;
using namespace OESystem;
using namespace OEChem;
using namespace OEConfGen;

int main(int argc, char *argv[])
{
  if (argc != 3)
    OEThrow.Usage("%s <infile> <outfile>", argv[0]);

  oemolistream ifs;
  if (!ifs.open(argv[1]))
    OEThrow.Fatal("Unable to open %s for reading", argv[1]);

  oemolostream ofs;
  if (!ofs.open(argv[2]))
    OEThrow.Fatal("Unable to open %s for writing", argv[2]);

  if (!OEIs3DFormat(ofs.GetFormat()))
    OEThrow.Fatal("Invalid output file format for 3D coordinates!");

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

  OEMol mol;
  while (OEReadMolecule(ifs, mol))
  {
    OEThrow.Info("Title: %s", mol.GetTitle());
    if (omega(mol))
      OEWriteMolecule(ofs, mol);
  }
  
  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) 2017 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.
*/

#include <openeye.h>

#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oeomega2.h>

using namespace std;
using namespace OEPlatform;
using namespace OESystem;
using namespace OEChem;
using namespace OEConfGen;

int main(int argc, char *argv[])
{
  if (argc != 3)
    OEThrow.Usage("dens_omega <infile> <outfile>");

  oemolistream ifs;
  if (!ifs.open(argv[1]))
    OEThrow.Fatal("Unable to open %s for reading", argv[1]);

  oemolostream ofs;
  if (!ofs.open(argv[2]))
    OEThrow.Fatal("Unable to open %s for writing", argv[2]);

  if (!OEIs3DFormat(ofs.GetFormat()))
    OEThrow.Fatal("Invalid output file format for 3D coordinates!");

  OEOmegaOptions omegaOpts(OEOmegaSampling::Dense);
  OEOmega omega(omegaOpts);

  OEMol mol;
  while (OEReadMolecule(ifs, mol))
  {
    OEThrow.Info("Title: %s", mol.GetTitle());
    if (omega(mol))
      OEWriteMolecule(ofs, mol);
  }
  
  return 0;
}

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) 2017 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.
*/

#include <openeye.h>

#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oeomega2.h>

using namespace std;
using namespace OEPlatform;
using namespace OESystem;
using namespace OEChem;
using namespace OEConfGen;

int main(int argc, char *argv[])
{
  if (argc != 3)
    OEThrow.Usage("stereo_and_torsion <infile> <outfile>");

  oemolistream ifs;
  if (!ifs.open(argv[1]))
    OEThrow.Fatal("Unable to open %s for reading", argv[1]);

  oemolostream ofs;
  if (!ofs.open(argv[2]))
    OEThrow.Fatal("Unable to open %s for writing", argv[2]);

  if (!OEIs3DFormat(ofs.GetFormat()))
    OEThrow.Fatal("Invalid output file format for 3D coordinates!");

  OEOmegaOptions omegaOpts;
  OEOmega omega(omegaOpts);
  OEMol mol;
  while (OEReadMolecule(ifs, mol))
  {
    OEThrow.Info("Title: %s", mol.GetTitle());

    OEIter<OEMolBase> stereo = OEFlipper(*mol.GetActive(), 12, true);
    for ( ; stereo; ++stereo)
    {
      mol = *stereo;
      if (omega(mol))
        OEWriteMolecule(ofs, mol);
    }
  }
  
  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) 2017 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.
*/

#include <openeye.h>

#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oeomega2.h>

using namespace std;
using namespace OEPlatform;
using namespace OESystem;
using namespace OEChem;
using namespace OEConfGen;

int main(int argc, char *argv[])
{
  if (argc != 3)
    OEThrow.Usage("%s <infile> <outfile>", argv[0]);

  oemolistream ifs;
  if (!ifs.open(argv[1]))
    OEThrow.Fatal("Unable to open %s for reading", argv[1]);

  oemolostream ofs;
  if (!ofs.open(argv[2]))
    OEThrow.Fatal("Unable to open %s for writing", argv[2]);

  if (!OEIs3DFormat(ofs.GetFormat()))
    OEThrow.Fatal("Invalid output file format for 3D coordinates!");

  OETorDriveOptions opts;
  OETorDriver tordriver (opts);

  OEMol mol;
  while (OEReadMolecule(ifs, mol))
  {
    OEThrow.Info("Title: %s", mol.GetTitle());
    if (tordriver.GenerateConfs(mol))
      OEWriteMolecule(ofs, mol);
  }
  
  return 0;
}

Fragment Library generation Examples

Making Fragment Library

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

See also

Listing 6: Making Fragment Library

/*
(C) 2017 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.
*/

#include <openeye.h>

#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oeomega2.h>

using namespace std;
using namespace OEPlatform;
using namespace OESystem;
using namespace OEChem;
using namespace OEConfGen;

int main(int argc, char *argv[])
{
  if (argc != 3)
    OEThrow.Usage("make_fraglib <infile> <outfile>");

  oemolistream ifs;
  if (!ifs.open(argv[1]))
    OEThrow.Fatal("Unable to open %s for reading", argv[1]);

  oemolostream ofs;
  if (!ofs.open(argv[2]))
    OEThrow.Fatal("Unable to open %s for writing", argv[2]);

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

  OEFragBuilderOptions opts;
  OEMakeFragLib makefraglib(opts);
  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) 2017 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.
*/

#include <openeye.h>

#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oeomega2.h>

using namespace std;
using namespace OEPlatform;
using namespace OESystem;
using namespace OEChem;
using namespace OEConfGen;

int main(int argc, char *argv[])
{
  if (argc != 3)
    OEThrow.Usage("macrocycle <infile> <outfile>");

  oemolistream ifs;
  if (!ifs.open(argv[1]))
    OEThrow.Fatal("Unable to open %s for reading", argv[1]);

  oemolostream ofs;
  if (!ofs.open(argv[2]))
    OEThrow.Fatal("Unable to open %s for writing", argv[2]);

  if (!OEIs3DFormat(ofs.GetFormat()))
    OEThrow.Fatal("Invalid output file format for 3D coordinates!");

  OEMacrocycleOmegaOptions omegaOpts;
  OEMacrocycleOmega mcomega(omegaOpts);

  OEMol mol;
  while (OEReadMolecule(ifs, mol))
  {
    OEThrow.Info("Title: %s", mol.GetTitle());
    if (mcomega.Build(mol))
      OEWriteMolecule(ofs, mol);
  }
  
  return 0;
}

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) 2017 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.
*/

#include <openeye.h>

#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oeomega2.h>

using namespace OEPlatform;
using namespace OESystem;
using namespace OEChem;
using namespace OEConfGen;
using namespace std;

int main(int argc, char *argv[])
{
  if (argc != 3)
    OEThrow.Usage("%s <infile> <outfile>", argv[0]);

  oemolistream ifs;
  if (!ifs.open(argv[1]))
    OEThrow.Fatal("Unable to open %s for reading", argv[1]);

  oemolostream ofs;
  if (!ofs.open(argv[2]))
    OEThrow.Fatal("Unable to open %s for writing", argv[2]);

  if (!OEIs3DFormat(ofs.GetFormat()))
    OEThrow.Fatal("Invalid output file format for 3D coordinates!");

  OEMacrocycleBuilderOptions opts;
  OEMacrocycleBuilder builder(opts);

  OEMol mol;
  while (OEReadMolecule(ifs, mol))
  {
    OEThrow.Info("Title: %s", mol.GetTitle());
    if (builder.Build(mol, 0))
      OEWriteMolecule(ofs, mol);
  }
  
  return 0;
}