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) 2006-2017 OpenEye Scientific Software, Inc.
***********************************************************************/
#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("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]);

  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;
}

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

Listing 2: Generating a Single Conformer

/**********************************************************************
Copyright (C) 2006-2017 OpenEye Scientific Software, Inc.
***********************************************************************/
#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]);

  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;
}

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.
***********************************************************************/
#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("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]);

  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

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.
***********************************************************************/
#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("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]);

  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;
}