OEDocking Examples

The following table lists the currently available OEDocking TK examples:

Program

Description

docking

docking molecules

rescoring

rescore docked molecules

shapefit

flexible fitting with OEShapeFit

posing

generating poses

posing_multi

posing with multiple receptors

make_receptor

making a receptor

contour_volume

receptor contour volume

inner_contour

toggle inner contour

outer_contour

set outer contour

Docking and Scoring Examples

Docking Molecules

The following code example shows how to perform docking using the OEDock object.

See also

Listing 1: Docking Molecules

/* 
(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 "oesystem.h"
#include "oechem.h"
#include "oebio.h"
#include "oedocking.h"

using namespace OESystem;
using namespace OEChem;
using namespace OEBio;
using namespace OEDocking;
using namespace std;

int main(int argc, char** argv)
{

  OEDockOptions dockOpts;
  OERefInputAppOptions opts(dockOpts, "DockMolecules", OEFileStringType::Mol3D,
      OEFileStringType::Mol3D, OEFileStringType::DU, "-receptor");

  if (OEConfigureOpts(opts, argc, argv, false) == OEOptsConfigureStatus::Help)
    return 1;

  dockOpts.UpdateValues(opts);

  oemolistream imstr(opts.GetInFile());
  oemolostream omstr(opts.GetOutFile());

  OEDesignUnit du;
  if (!OEReadDesignUnit(opts.GetRefFile(), du))
    OEThrow.Fatal("Unable to read du");

  if (!du.HasReceptor())
      OEThrow.Fatal("Design Unit " + du.GetTitle() + " does not contain a receptor");

  OEDock dock(dockOpts);
  dock.Initialize(du);

  OEMol mcmol;
  while (OEReadMolecule(imstr, mcmol))
  {
    OEGraphMol dockedMol;
    unsigned int retCode = dock.DockMultiConformerMolecule(dockedMol, mcmol);
    if (retCode != OEDockingReturnCode::Success)
      OEThrow.Fatal("Docking Failed with error code " + OEDockingReturnCodeGetName(retCode));
    string sdtag = OEDockMethodGetName(dockOpts.GetScoreMethod());
    OESetSDScore(dockedMol, dock, sdtag);
    dock.AnnotatePose(dockedMol);
    OEWriteMolecule(omstr, dockedMol);
  }
  return 0;
}

Download code

DockMolecules.cpp

Rescoring Docked Molecules

The following code example shows how to rescore previously docked molecules, using the OEScore object.

See also

Listing 2: Rescoring Docked Molecules

/* 
(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 "oesystem.h"
#include "oechem.h"
#include "oebio.h"
#include "oedocking.h"
#include <string>

using namespace OESystem;
using namespace OEChem;
using namespace OEBio;
using namespace OEDocking;
using namespace std;

#include "RescorePoses.itf"

int main(int argc, char** argv)
{
  OEInterface itf(InterfaceData);
  OEScoreTypeConfigure(itf, "-score");
  if (!OEParseCommandLine(itf,argc,argv))
    return 1;

  oemolistream imstr(itf.Get<string>("-in"));
  oemolostream omstr(itf.Get<string>("-out"));

  OEDesignUnit receptor;
  if (!OEReadDesignUnit(itf.Get<string>("-receptor"), receptor))
    OEThrow.Fatal("Unable to read receptor file");

  unsigned int scoreType = OEScoreTypeGetValue(itf, "-score");
  OEScore score(scoreType);
  score.Initialize(receptor);

  OEMol ligand;
  bool optimize = itf.Get<bool>("-optimize");
  while (OEReadMolecule(imstr, ligand))
  {
    if (optimize)
      score.SystematicSolidBodyOptimize(ligand);
    score.AnnotatePose(ligand);
    string sdtag = score.GetName();
    OESetSDScore(ligand, score, sdtag);
    OESortConfsBySDTag(ligand, sdtag, score.GetHighScoresAreBetter());
    OEWriteMolecule(omstr, ligand);
  }
  return 0;
}

Download code

RescorePoses.cpp

OEShapeFit Examples

Flexible Overlay Optimization with OEShapeFit API

The following code example shows how to flexibly fit input multi conformer molecules in the design unit that contains bound ligand and get the score using the OEShapeFit and OEShapeFitResults objects.

Listing 3: Flexible fitting with OEShapeFit

/* 
(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 "oeshape.h"
#include "oedocking.h"

int main(int argc,char *argv[])
{
  OEDocking::OEShapeFitOptions overlayOpts;
  OEChem::OERefInputAppOptions opts(overlayOpts, "ShapeFit", OEChem::OEFileStringType::Mol3D,
                                    OEChem::OEFileStringType::Mol3D, OEChem::OEFileStringType::DU, "-receptor");
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;
  overlayOpts.UpdateValues(opts);

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

  OEPlatform::oeifstream rfs;
  if (!rfs.open(opts.GetRefFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetRefFile().c_str());

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

  OEBio::OEDesignUnit receptor;
  OEBio::OEReadDesignUnit(rfs, receptor);
  OESystem::OEThrow.Info("Ref. Title: %s", receptor.GetTitle().c_str());

  OEDocking::OEShapeFit shapefit(overlayOpts);
  shapefit.SetupRef(receptor);

  OEChem::OEMol fitmol;
  while (OEChem::OEReadMolecule(ifs, fitmol))
  {
    OESystem::OEIter<OEDocking::OEShapeFitResults> res = shapefit.Fit(fitmol);
    OESystem::OEIter<OEChem::OEConfBase> conf = fitmol.GetConfs();
    for(; res && conf; ++res, ++conf)
    {
      OESystem::OEThrow.Info("Fit. Title: %s Score: %0.2f", 
        fitmol.GetTitle(), res->GetScore());
      OEChem::OESetSDData(conf, "Score", OESystem::OENumberToString(res->GetScore(), 'f', 2));
    }
    OEChem::OEWriteMolecule(ofs, fitmol);
  }

  return 0;
}

Download code

ShapeFit.cpp

POSIT Examples

Generating Poses with POSIT

The following code example shows how to generate a single pose for each input ligand using the OEPosit object.

See also

Listing 4: Generating Poses with POSIT

/* 
(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 "oebio.h"
#include "oechem.h"
#include "oedocking.h"
#include "oesystem.h"
#include "openeye.h"

int main(int argc, char** argv)
{
  OEDocking::OEPositOptions positOpts;
  OEChem::OERefInputAppOptions opts(positOpts, "PoseMolecules", OEChem::OEFileStringType::Mol3D,
                                    OEChem::OEFileStringType::DU, OEChem::OEFileStringType::DU, "-receptor");
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;
  positOpts.UpdateValues(opts);

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

  OEPlatform::oeifstream rfs;
  if (!rfs.open(opts.GetRefFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetRefFile().c_str());

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

  OEDocking::OEPosit poser(positOpts);

  OEBio::OEDesignUnit du;
  unsigned int count = 0;
  while (OEBio::OEReadDesignUnit(rfs, du))
  {
    if (!du.HasReceptor())
      OESystem::OEThrow.Fatal("Design Unit " + du.GetTitle() + " does not contain a receptor");
    poser.AddReceptor(du);
    count++;
  }
  if (count == 0)
    OESystem::OEThrow.Fatal("Input design unit does not contain any receptor");

  OEChem::OEMol mcmol;
  while (OEChem::OEReadMolecule(ifs, mcmol))
  {
    OESystem::OEThrow.Info("posing %s", mcmol.GetTitle());
    OEDocking::OESinglePoseResult result;
    unsigned int returnCode = poser.Dock(result, mcmol);

    if (returnCode == OEDocking::OEDockingReturnCode::Success)
    {
      OEBio::OEDesignUnit posedDU(result.GetDesignUnit());
      posedDU.SetDoubleData(poser.GetName().c_str(), result.GetProbability());
      OESystem::OEThrow.Info("Receptor used: %s pose probability: %f", posedDU.GetTitle().c_str(),
                             result.GetProbability());
      OEBio::OEWriteDesignUnit(ofs, posedDU);
    }
    else
    {
      std::string errMsg = OEDocking::OEDockingReturnCodeGetName(returnCode);
      OESystem::OEThrow.Warning("%s: %s", mcmol.GetTitle(), errMsg.c_str());
    }
  }
  return 0;
}

Download code

PoseMolecules.cpp

Generating Multiple Poses with POSIT

The following code example shows how to generate multiple poses for each input ligand, using the OEPosit object.

See also

Listing 5: Posit for Generating Multiple Poses for each Ligand

/* 
(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 "oebio.h"
#include "oechem.h"
#include "oedocking.h"
#include "oesystem.h"
#include "openeye.h"

class MyOptions : public OEDocking::OEPositOptions
{
public:
  MyOptions() : OEDocking::OEPositOptions()
  {
    OESystem::OEUIntParameter param1("-numPoses", 1);
    param1.AddLegalRange("1", "20");
    param1.SetBrief("Number of poses to generate");
    m_param1 = AddParameter(param1);
  }

  unsigned int GetNumPoses() const
  {
    unsigned int numConfs = 1;
    if (m_param1->GetHasValue())
      OESystem::OEStringToNumber(m_param1->GetStringValue(), numConfs);
    else
      OESystem::OEStringToNumber(m_param1->GetStringDefault(), numConfs);
    return numConfs;
  }

private:
  OESystem::OEParameter *m_param1;
};

int main(int argc, char **argv)
{
  MyOptions positOpts;
  OEChem::OERefInputAppOptions opts(positOpts, "PoseMolecules", OEChem::OEFileStringType::Mol3D,
                                    OEChem::OEFileStringType::DU, OEChem::OEFileStringType::DU, "-receptor");
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;
  positOpts.UpdateValues(opts);

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

  OEPlatform::oeifstream rfs;
  if (!rfs.open(opts.GetRefFile()))
    OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetRefFile().c_str());

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

  OEDocking::OEPosit poser(positOpts);

  OEBio::OEDesignUnit du;
  unsigned int count = 0;
  while (OEBio::OEReadDesignUnit(rfs, du))
  {
    if (!du.HasReceptor())
      OESystem::OEThrow.Fatal("Design Unit " + du.GetTitle() + " does not contain a receptor");
    poser.AddReceptor(du);
    count++;
  }
  if (count == 0)
    OESystem::OEThrow.Fatal("Receptor input does not contain any design unit");

  OESystem::OEThrow.Info("Number of conformers: %d", positOpts.GetNumPoses());
  OESystem::OEThrow.Info("Best receptor pose flag: %s", positOpts.GetBestReceptorPoseOnly() ? "true" : "false");

  OEChem::OEMol mcmol;
  while (OEChem::OEReadMolecule(ifs, mcmol))
  {
    OESystem::OEThrow.Info("posing %s", mcmol.GetTitle());
    OEDocking::OEPositResults results;
    unsigned int returnCode = poser.Dock(results, mcmol, positOpts.GetNumPoses());

    if (returnCode == OEDocking::OEDockingReturnCode::Success)
    {
      for (OESystem::OEIter<OEDocking::OESinglePoseResult> result = results.GetSinglePoseResults(); result; ++result)
      {
        OEBio::OEDesignUnit posedDU = result->GetDesignUnit();
        posedDU.SetDoubleData(poser.GetName().c_str(), result->GetProbability());
        OESystem::OEThrow.Info("Receptor used: %s pose probability: %f", posedDU.GetTitle().c_str(),
                               result->GetProbability());
        OEBio::OEWriteDesignUnit(ofs, posedDU);
      }
    }
    else
    {
      std::string errMsg = OEDocking::OEDockingReturnCodeGetName(returnCode);
      OESystem::OEThrow.Warning("%s: %s", mcmol.GetTitle(), errMsg.c_str());
    }
  }

  return 0;
}

Download code

GenerateMultiplePose.cpp

Receptor Examples

Making Receptor

The following code example shows how to make a receptor.

See also

Listing 6: Making Receptor

/* 
(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 "oesystem.h"
#include "oechem.h"
#include "oebio.h"
#include "oedocking.h"

using namespace OESystem;
using namespace OEChem;
using namespace OEBio;
using namespace OEDocking;

int main(int argc, char** argv)
{
  OEMakeReceptorOptions recOpts;
  OESimpleAppOptions opts(recOpts, "MakeReceptoor", OEChem::OEFileStringType::DU, OEChem::OEFileStringType::DU);
  if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
    return 0;

  OEPlatform::oeifstream ifs(opts.GetInFile());
  OEPlatform::oeofstream ofs(opts.GetOutFile());


  OEDesignUnit du;
  while (OEReadDesignUnit(ifs, du))
    if (OEMakeReceptor(du, recOpts))
      OEWriteDesignUnit(ofs, du);
    else
      OEThrow.Fatal(du.GetTitle() + " Failed to make a receptor");

  return 0;
}

Download code

MakeReceptor.cpp

Receptor Contour Volume

The following code example shows how to estimate a receptor outer contour volume.

See also

Listing 7: Receptor Contour Volume

/* 
(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 "oesystem.h"
#include "oechem.h"
#include "oebio.h"
#include "oegrid.h"
#include "oedocking.h"

using namespace OESystem;
using namespace OEChem;
using namespace OEBio;
using namespace OEDocking;
using namespace std;

int main(int argc, char** argv)
{
  if (argc != 2)
    OEThrow.Usage("ReceptorOuterContourVolume <receptor>");

  OEDesignUnit du;

  if (!OEReadDesignUnit(argv[1], du))
    OEThrow.Fatal("%s is not a valid design unit",argv[1]);
  if (!du.HasReceptor())
        OEThrow.Fatal("Design unit " + du.GetTitle() + " does not have a receptor");

  OEReceptor receptor = du.GetReceptor();
  OEScalarGrid negativeImagePotential = receptor.GetNegativeImageGrid();
  float outerContourLevel = receptor.GetOuterContourLevel();

  unsigned int outerCount = 0;
  for (unsigned int i=0 ; i<negativeImagePotential.GetSize() ; ++i)
    if (negativeImagePotential[i] >= outerContourLevel)
      ++outerCount;

  float countToVolume = powf(negativeImagePotential.GetSpacing(), 3.0f);

  cout << (float)outerCount * countToVolume << " cubic angstroms" << endl;

  return 0;
}

Toggle Receptor Inner Contour

The following code example shows how to toggle receptor contour volume.

See also

Listing 8: Toggle Receptor Inner Contour

/* 
(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 "oesystem.h"
#include "oechem.h"
#include "oebio.h"
#include "oedocking.h"

using namespace OESystem;
using namespace OEChem;
using namespace OEBio;
using namespace OEDocking;

int main(int argc, char** argv)
{
  if (argc != 2)
    OEThrow.Usage("ToggleInterContour <receptor>");

  OEDesignUnit du;

  if (!OEReadDesignUnit(argv[1], du))
    OEThrow.Fatal("Unable to open design unit file");
  if (!du.HasReceptor())
    OEThrow.Fatal("Design unit " + du.GetTitle() + " does not have a receptor");

  OEReceptor receptor = du.GetReceptor();
  float innerContourLevel = receptor.GetInnerContourLevel();
  receptor.SetInnerContourLevel(-innerContourLevel);

  if (innerContourLevel > 1.0f)
    OEThrow.Info("Toggling inner contour off");
  else
    OEThrow.Info("Toggling inner contour on");

  if (!OEWriteDesignUnit(argv[1], du))
    OEThrow.Fatal("Unable to write receptor");

  return 0;
}

Download code

ToggleInnerContour.cpp

Set Receptor Contour Volume

The following code example shows how to change the receptor outer contour volume.

See also

Listing 9: Set Receptor Contour Volume

/* 
(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 "oesystem.h"
#include "oechem.h"
#include "oebio.h"
#include "oegrid.h"
#include "oedocking.h"
#include <vector>
#include <algorithm>

using namespace OESystem;
using namespace OEChem;
using namespace OEBio;
using namespace OEDocking;
using namespace std;

int main(int argc, char** argv)
{
  if (argc != 3)
    OEThrow.Usage("SetOuterContourVolume <receptor> <volume>");

  OEDesignUnit du;

  if (!OEReadDesignUnit(argv[1], du))
    OEThrow.Fatal("Unable to open design unit file");
  if (!du.HasReceptor())
    OEThrow.Fatal("Design unit " + du.GetTitle() + " does not have a receptor");

  OEReceptor receptor = du.GetReceptor();

  float outerContourVolume;
  if (!OEStringToNumber(argv[2], outerContourVolume))
    OEThrow.Fatal("could not convert %s to a number",argv[2]);

  OEScalarGrid negativeImagePotential = receptor.GetNegativeImageGrid();

  vector<float> gridElement;
  for (unsigned int i=0 ; i<negativeImagePotential.GetSize() ; ++i)
    gridElement.push_back(negativeImagePotential[i]);
  sort(gridElement.begin(), gridElement.end(), greater<float>());

  float outerContourLevel = gridElement[gridElement.size()-1];
  float countToVolume = powf(negativeImagePotential.GetSpacing(), 3.0f);
  unsigned int ilevel = (unsigned int) (outerContourVolume/countToVolume + 0.5f);
  if (ilevel < gridElement.size())
    outerContourLevel = gridElement[ilevel];

  receptor.SetOuterContourLevel(outerContourLevel);

  if (!OEWriteDesignUnit(argv[1], du))
    OEThrow.Fatal("Unable to write updated receptor");

  return 0;
}