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

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

#include <openeye.h>

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

int main(int argc, char *argv[])
{
  OEConfGen::OEOmegaOptions omegaOpts;
  omegaOpts.SetParameterVisibility(OESystem::OEParamVisibility::Hidden);
  omegaOpts.SetParameterVisibility("-rms", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-ewindow", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-maxconfs", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-useGPU", OESystem::OEParamVisibility::Simple);

  OEChem::OESimpleAppOptions opts(omegaOpts, "simple_omega", OEChem::OEFileStringType::Mol, OEChem::OEFileStringType::Mol3D);
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;

  omegaOpts.UpdateValues(opts);
  OEConfGen::OEOmega omega(omegaOpts);

  OEChem::oemolistream ifs;
  if (!ifs.open(opts.GetInFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());

  OEChem::oemolostream ofs;
  if (!ofs.open(opts.GetOutFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());

  OEChem::OEMol mol;
  while (OEChem::OEReadMolecule(ifs, mol))
  {
    OESystem::OEThrow.Info("Title: %s", mol.GetTitle());
    unsigned retCode = omega.Build(mol);
    if (retCode == OEConfGen::OEOmegaReturnCode::Success)
      OEChem::OEWriteMolecule(ofs, mol);
    else
      OESystem::OEThrow.Warning("%s: %s", mol.GetTitle(), OEConfGen::OEGetOmegaError(retCode).c_str());
  }

  return 0;
}

Download code

simple_omega.cpp

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

#include <openeye.h>

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

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

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

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

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

  OEConfGen::OEConformerBuilder builder;

  OEChem::OEMol mol;
  while (OEChem::OEReadMolecule(ifs, mol))
  {
    OESystem::OEThrow.Info("Title: %s", mol.GetTitle());
    unsigned retCode = builder.Build(mol);
    if (retCode == OEConfGen::OEOmegaReturnCode::Success)
      OEChem::OEWriteMolecule(ofs, mol);
    else
      OESystem::OEThrow.Warning("%s: %s", mol.GetTitle(), OEConfGen::OEGetOmegaError(retCode).c_str());
  }
 
  return 0;
}

Download code

single_conformer.cpp

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

#include <openeye.h>

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

int main(int argc, char *argv[])
{
  OEConfGen::OEOmegaOptions omegaOpts(OEConfGen::OEOmegaSampling::Dense);
  omegaOpts.SetParameterVisibility(OESystem::OEParamVisibility::Hidden);
  omegaOpts.SetParameterVisibility("-rms", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-ewindow", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-maxconfs", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-useGPU", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-searchFF", OESystem::OEParamVisibility::Simple);

  OEChem::OESimpleAppOptions opts(omegaOpts, "dense_omega", OEChem::OEFileStringType::Mol, OEChem::OEFileStringType::Mol3D);
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;

  omegaOpts.UpdateValues(opts);
  OEConfGen::OEOmega omega(omegaOpts);

  OEChem::oemolistream ifs;
  if (!ifs.open(opts.GetInFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());

  OEChem::oemolostream ofs;
  if (!ofs.open(opts.GetOutFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());

  OEChem::OEMol mol;
  while (OEChem::OEReadMolecule(ifs, mol))
  {
    OESystem::OEThrow.Info("Title: %s", mol.GetTitle());
    unsigned retCode = omega.Build(mol);
    if (retCode == OEConfGen::OEOmegaReturnCode::Success)
      OEChem::OEWriteMolecule(ofs, mol);
    else
      OESystem::OEThrow.Warning("%s: %s", mol.GetTitle(), OEConfGen::OEGetOmegaError(retCode).c_str());
  }

  return 0;
}

Download code

dense_omega.cpp

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

#include <openeye.h>

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

int main(int argc, char *argv[])
{
  OEConfGen::OEFlipperOptions flipperOpts;

  OEChem::OESimpleAppOptions opts(flipperOpts, "setereo_and_torsion", OEChem::OEFileStringType::Mol, OEChem::OEFileStringType::Mol);
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;

  flipperOpts.UpdateValues(opts);
  OEConfGen::OEOmega omega;

  OEChem::oemolistream ifs;
  if (!ifs.open(opts.GetInFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());

  OEChem::oemolostream ofs;
  if (!ofs.open(opts.GetOutFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());

  OEChem::OEMol mol;
  while (OEChem::OEReadMolecule(ifs, mol))
  {
    OESystem::OEThrow.Info("Title: %s", mol.GetTitle());

    OESystem::OEIter<OEChem::OEMolBase> stereo = OEConfGen::OEFlipper(*mol.GetActive(), flipperOpts);
    for ( ; stereo; ++stereo)
    {
      OEChem::OEMol fmol = *stereo;
      unsigned retCode = omega.Build(fmol);
      if (retCode == OEConfGen::OEOmegaReturnCode::Success)
        OEChem::OEWriteMolecule(ofs, fmol);
      else
        OESystem::OEThrow.Warning("%s: %s", fmol.GetTitle(), OEConfGen::OEGetOmegaError(retCode).c_str());
    }
  }

  return 0;
}

Download code

stereo_and_torsion.cpp

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

#include <openeye.h>

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

int main(int argc, char *argv[])
{
  OEConfGen::OETorDriveOptions torOpts;
  torOpts.SetParameterVisibility(OESystem::OEParamVisibility::Hidden);
  torOpts.SetParameterVisibility("-rms", OESystem::OEParamVisibility::Simple);
  torOpts.SetParameterVisibility("-ewindow", OESystem::OEParamVisibility::Simple);
  torOpts.SetParameterVisibility("-maxconfs", OESystem::OEParamVisibility::Simple);

  OEChem::OESimpleAppOptions opts(torOpts, "torsion_drive", OEChem::OEFileStringType::Mol, OEChem::OEFileStringType::Mol3D);
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;

  torOpts.UpdateValues(opts);
  OEConfGen::OETorDriver tordriver(torOpts);

  OEChem::oemolistream ifs;
  if (!ifs.open(opts.GetInFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());

  OEChem::oemolostream ofs;
  if (!ofs.open(opts.GetOutFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());

  OEChem::OEMol mol;
  while (OEChem::OEReadMolecule(ifs, mol))
  {
    OESystem::OEThrow.Info("Title: %s", mol.GetTitle());
    unsigned retCode = tordriver.GenerateConfs(mol);
    if (retCode == OEConfGen::OEOmegaReturnCode::Success)
      OEChem::OEWriteMolecule(ofs, mol);
    else
      OESystem::OEThrow.Warning("%s: %s", mol.GetTitle(), OEConfGen::OEGetOmegaError(retCode).c_str());
  }

  return 0;
}

Download code

torsion_drive.cpp

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

#include <openeye.h>

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

int main(int argc, char *argv[])
{
  OEConfGen::OEFragBuilderOptions libOpts;
  libOpts.SetParameterVisibility(OESystem::OEParamVisibility::Hidden);
  libOpts.SetParameterVisibility("-buildFF", OESystem::OEParamVisibility::Simple);

  OEChem::OESimpleAppOptions opts(libOpts, "make_fraglib", OEChem::OEFileStringType::Mol, OEChem::OEFileStringType::Mol3D);
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;

  libOpts.UpdateValues(opts);
  OEConfGen::OEMakeFragLib makefraglib(libOpts);

  OEChem::oemolistream ifs;
  if (!ifs.open(opts.GetInFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());

  OEChem::oemolostream ofs;
  if (!ofs.open(opts.GetOutFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());

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

  makefraglib.ClearFragLibs();
  makefraglib.GenerateMissingFrags(ifs, ofs);

  return 0;
}

Download code

make_fraglib.cpp

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

#include <openeye.h>

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

int main(int argc, char *argv[])
{
  OEConfGen::OEMacrocycleOmegaOptions omegaOpts;
  omegaOpts.SetParameterVisibility(OESystem::OEParamVisibility::Hidden);
  omegaOpts.SetParameterVisibility("-rms", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-ewindow", OESystem::OEParamVisibility::Simple);
  omegaOpts.SetParameterVisibility("-maxconfs", OESystem::OEParamVisibility::Simple);

  OEChem::OESimpleAppOptions opts(omegaOpts, "macrocycle", OEChem::OEFileStringType::Mol, OEChem::OEFileStringType::Mol3D);
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;

  omegaOpts.UpdateValues(opts);
  OEConfGen::OEMacrocycleOmega mcomega(omegaOpts);

  OEChem::oemolistream ifs;
  if (!ifs.open(opts.GetInFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());

  OEChem::oemolostream ofs;
  if (!ofs.open(opts.GetOutFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());

  OEChem::OEMol mol;
  while (OEChem::OEReadMolecule(ifs, mol))
  {
    OESystem::OEThrow.Info("Title: %s", mol.GetTitle());
    unsigned retCode = mcomega.Build(mol);
    if (retCode == OEConfGen::OEOmegaReturnCode::Success)
      OEChem::OEWriteMolecule(ofs, mol);
    else
      OESystem::OEThrow.Warning("%s: %s", mol.GetTitle(), OEConfGen::OEGetOmegaError(retCode).c_str());
  }

  return 0;
}

Download code

macrocycle.cpp

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

#include <openeye.h>

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

int main(int argc, char *argv[])
{
  OEConfGen::OEMacrocycleBuilderOptions buildOpts;
  buildOpts.SetParameterVisibility(OESystem::OEParamVisibility::Hidden);
  buildOpts.SetParameterVisibility("-seed", OESystem::OEParamVisibility::Simple);
  buildOpts.SetParameterVisibility("-dielectric_constant", OESystem::OEParamVisibility::Simple);

  OEChem::OESimpleAppOptions opts(buildOpts, "MacrocycleBuilder", OEChem::OEFileStringType::Mol, OEChem::OEFileStringType::Mol3D);
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;

  buildOpts.UpdateValues(opts);

  OEChem::oemolistream ifs;
  if (!ifs.open(opts.GetInFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());

  OEChem::oemolostream ofs;
  if (!ofs.open(opts.GetOutFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());

  OEChem::OEMol mol;
  while (OEChem::OEReadMolecule(ifs, mol))
  {
    OESystem::OEThrow.Info("Title: %s", mol.GetTitle());
    unsigned retCode = OEConfGen::OEOmegaReturnCode::Failed;
    unsigned int itlimit = 1000, itnum = 0;
    while(itnum <= itlimit)
    {
      OEConfGen::OEMacrocycleBuilder builder(buildOpts);
      retCode = builder.Build(mol);
      if(retCode == OEConfGen::OEOmegaReturnCode::Success)
      { 
        OEChem::OEWriteMolecule(ofs, mol);
        break;
      }
      else
      {
        buildOpts.SetRandomSeed(buildOpts.GetRandomSeed()+1);
      }
      ++itnum;
    }
    if(retCode != OEConfGen::OEOmegaReturnCode::Success)
      OESystem::OEThrow.Warning("%s: %s", mol.GetTitle(), OEConfGen::OEGetOmegaError(retCode).c_str());
  }
 
  return 0;
}