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

/*
(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("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

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

  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

/*
(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("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

/*
(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("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;
}