OEDocking Examples

The following table lists the currently available OEDocking TK examples:

Program Description
docking docking molecules
rescoring rescore docked molecules
posing generating poses
posing_multi posing with multiple receptors
make_receptor making a receptor
contour_volume recepotr 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) 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 "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;

#include "DockMolecules.itf"

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

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

POSIT Examples

Generating Poses with POSIT

The following code example shows how to generate poses using the OEPosit object.

See also

Listing 3: Generating Poses with POSIT

/*
(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 "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)
{
  OEPositOptions positOpts;

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

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

  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");

  OEPosit poser;
  poser.AddReceptor(du);

  oemolistream imstr(opts.GetInFile());
  OEPlatform::oeofstream ostr(opts.GetOutFile());

  OEMol mcmol;
  while (OEReadMolecule(imstr, mcmol))
  {
    OESinglePoseResult result;
    unsigned int returnCode = poser.Dock(result, mcmol);
    if (returnCode == OEDockingReturnCode::Success)
    {
      OEDesignUnit posedDU(result.GetDesignUnit());
      posedDU.SetDoubleData(poser.GetName().c_str(), result.GetProbability());
      OEWriteDesignUnit(ostr, posedDU);
    }
    else
      OEThrow.Fatal("Docking Failed with error code " + OEDockingReturnCodeGetName(returnCode));
  }
  return 0;
}

POSIT with Multiple Receptors

The following code example shows how to generate poses, against multiple receptors, using the OEPosit object.

See also

Listing 4: POSIT with Multiple Receptors

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

#include "PoseMolsMultiReceptor.itf"

int main(int argc, char** argv)
{
  OEInterface itf(InterfaceData);

  if (!OEParseCommandLine(itf,argc,argv))
    return 1;

  OEPosit poser;
  for(OEIter<const string> receptor_filename = itf.GetList<string>("-receptors");
      receptor_filename;
      ++receptor_filename)
  {
    OEDesignUnit du;
    if (!OEReadDesignUnit(receptor_filename, du))
      OEThrow.Fatal("Unable to read design Unit");
    poser.AddReceptor(du);
  }

  OEMol mcmol;
  oemolistream imstr(itf.Get<string>("-in"));
  OEPlatform::oeofstream ostr(itf.Get<string>("-out"));

  while (OEReadMolecule(imstr, mcmol))
  {
    OESinglePoseResult result;
    unsigned int returnCode = poser.Dock(result, mcmol);

    if (returnCode == OEDockingReturnCode::Success)
    {
      OEDesignUnit posedDU = result.GetDesignUnit();
      posedDU.SetDoubleData(poser.GetName().c_str(), result.GetProbability());
      OEWriteDesignUnit(ostr, posedDU);
    }
    else
      OEThrow.Warning("Failed to dock molecule with error code "
        + OEDockingReturnCodeGetName(returnCode));
  }
  return 0;
}

Receptor Examples

Making Receptor

The following code example shows how to make a receptor.

See also

Listing 5: Making Receptor

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

Receptor Contour Volume

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

See also

Listing 6: Receptor Contour Volume

/*
(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 "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 7: Toggle Receptor Inner Contour

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

Set Receptor Contour Volume

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

See also

Listing 8: Set Receptor Contour Volume

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