OEDocking Examples¶
The following table lists the currently available OEDocking TK examples:
Program |
Description |
---|---|
docking molecules |
|
rescore docked molecules |
|
generating poses |
|
posing with multiple receptors |
|
making a receptor |
|
receptor contour volume |
|
toggle inner 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
OEDockOptions class
OEDock class
OEHybrid class
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.
*/
package openeye.examples.oedocking;
import java.net.URL;
import openeye.oechem.*;
import openeye.oebio.*;
import openeye.oedocking.*;
public class DockMolecules {
public static void main(String[] args) {
OEDockOptions dockOpts = new OEDockOptions();
OERefInputAppOptions opts = new OERefInputAppOptions(dockOpts, "DockMolecules", OEFileStringType.Mol3D,
OEFileStringType.Mol3D, OEFileStringType.DU, "-receptor");
if (oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
System.exit(0);
dockOpts.UpdateValues(opts);
oemolistream ifs = new oemolistream();
if(!ifs.open(opts.GetInFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");
oemolostream ofs = new oemolostream();
if(!ofs.open(opts.GetOutFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing");
oeifstream rfs = new oeifstream();
if (!rfs.open(opts.GetRefFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetRefFile() + " for reading");
OEDesignUnit du = new OEDesignUnit();
if (! oebio.OEReadDesignUnit(opts.GetRefFile(), du))
oechem.OEThrow.Fatal("Failed to read design unit ");
if (!du.HasReceptor())
oechem.OEThrow.Fatal("Design unit " + du.GetTitle() + " does not contain a receptor");
OEDock dock = new OEDock(dockOpts);
dock.Initialize(du);
OEMol mol = new OEMol();
while (oechem.OEReadMolecule(ifs, mol)) {
System.err.format("docking %s\n", mol.GetTitle());
OEGraphMol dockedMol = new OEGraphMol();
int retCode = dock.DockMultiConformerMolecule(dockedMol, mol);
if (retCode != OEDockingReturnCode.Success) {
oechem.OEThrow.Error("Docking failed with error code " + oedocking.OEDockingReturnCodeGetName(retCode));
}
String sdtag = oedocking.OEDockMethodGetName(dockOpts.GetScoreMethod());
oedocking.OESetSDScore(dockedMol, dock, sdtag);
dock.AnnotatePose(dockedMol);
oechem.OEWriteMolecule(ofs, dockedMol);
}
ofs.close();
ifs.close();
}
}
Download code
Rescoring Docked Molecules¶
The following code example shows how to rescore previously docked molecules, using the OEScore object.
See also
OEScore class
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.
*/
package openeye.examples.oedocking;
import java.net.URL;
import openeye.oechem.*;
import openeye.oebio.*;
import openeye.oedocking.*;
public class RescorePoses {
private void rescore(OEInterface itf) {
OEDesignUnit receptor = new OEDesignUnit();
if (!oebio.OEReadDesignUnit(itf.GetString("-receptor"), receptor)) {
oechem.OEThrow.Fatal("Unable to read receptor");
}
oemolistream imstr = new oemolistream();
if (!imstr.open(itf.GetString("-in"))) {
oechem.OEThrow.Fatal("Unable to open input file of ligands");
}
oemolostream omstr = new oemolostream();
if (!omstr.open(itf.GetString("-out"))) {
oechem.OEThrow.Fatal("Unable to open out file for rescored ligands");
}
int scoreType = oedocking.OEScoreTypeGetValue(itf, "-score");
OEScore score = new OEScore(scoreType);
score.Initialize(receptor);
OEMol ligand = new OEMol();
boolean optimize = itf.GetBool("-optimize");
while (oechem.OEReadMolecule(imstr, ligand)) {
if (optimize) {
score.SystematicSolidBodyOptimize(ligand);
}
score.AnnotatePose(ligand);
String sdtag = score.GetName();
oedocking.OESetSDScore(ligand, score, sdtag);
oechem.OESortConfsBySDTag(ligand, sdtag, score.GetHighScoresAreBetter());
oechem.OEWriteMolecule(omstr, ligand);
}
omstr.close();
imstr.close();
}
public static void main(String argv[]) {
RescorePoses app = new RescorePoses();
URL fileURL = app.getClass().getResource("RescorePoses.txt");
try {
OEInterface itf = new OEInterface();
oechem.OEConfigureFromURL(itf, fileURL);
oedocking.OEScoreTypeConfigure(itf, "-score");
if (oechem.OEParseCommandLine(itf, argv)) {
app.rescore(itf);
}
} catch (java.io.IOException e) {
System.err.println("Unable to open interface file");
}
}
}
Download code
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.
See also
OEFlexiOverlapFunc
classOEFlexiOverlayOptions
class
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
OEPositOptions class
OEPosit class
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.
*/
package openeye.examples.oedocking;
import java.net.URL;
import openeye.oechem.*;
import openeye.oebio.*;
import openeye.oedocking.*;
public class PoseMolecules {
public static void main(String[] args) {
OEPositOptions positOpts = new OEPositOptions();
OERefInputAppOptions opts = new OERefInputAppOptions(positOpts, "PoseMolecules", OEFileStringType.Mol3D,
OEFileStringType.DU, OEFileStringType.DU, "-receptor");
if (oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
System.exit(0);
positOpts.UpdateValues(opts);
oemolistream ifs = new oemolistream();
if (!ifs.open(opts.GetInFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");
oeifstream rfs = new oeifstream();
if (!rfs.open(opts.GetRefFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetRefFile() + " for reading");
oeofstream ofs = new oeofstream();
if (!ofs.open(opts.GetOutFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing");
OEPosit poser = new OEPosit(positOpts);
OEDesignUnit du = new OEDesignUnit();
int count = 0;
while (oebio.OEReadDesignUnit(rfs, du)) {
if (!du.HasReceptor())
oechem.OEThrow.Fatal("Design unit " + du.GetTitle() + " does not contain a receptor");
poser.AddReceptor(du);
count++;
}
if (count == 0)
oechem.OEThrow.Fatal("Input design unit does not contain any receptor");
OEMol mcmol = new OEMol();
while (oechem.OEReadMolecule(ifs, mcmol)) {
oechem.OEThrow.Info("posing " + mcmol.GetTitle());
OESinglePoseResult result = new OESinglePoseResult();
int returnCode = poser.Dock(result, mcmol);
if (returnCode == OEDockingReturnCode.Success) {
OEDesignUnit posedDU = new OEDesignUnit(result.GetDesignUnit());
posedDU.SetDoubleData(poser.GetName(), result.GetProbability());
oechem.OEThrow
.Info("Receptor used: " + posedDU.GetTitle() + " pose probability: " + result.GetProbability());
oebio.OEWriteDesignUnit(ofs, posedDU);
} else {
String errMsg = oedocking.OEDockingReturnCodeGetName(returnCode);
oechem.OEThrow.Warning(mcmol.GetTitle() + " : " + errMsg);
}
}
ofs.close();
ifs.close();
rfs.close();
}
}
Download code
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
OEPositOptions class
OEPosit class
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.
*/
package openeye.examples.oedocking;
import java.net.URL;
import java.util.Iterator;
import openeye.oechem.*;
import openeye.oebio.*;
import openeye.oedocking.*;
public class GenerateMultiplePose {
public static class MyOptions extends OEPositOptions {
private OEParameter _param1;
public MyOptions() {
super();
OEIntParameter param1 = new OEIntParameter("-numPoses", 1);
param1.AddLegalRange("1", "20");
param1.SetBrief("Number of poses to generate");
_param1 = AddParameter(param1);
}
public int GetNumPoses() {
if (_param1.GetHasValue())
return (Integer.parseInt(_param1.GetStringValue()));
return (Integer.parseInt(_param1.GetStringDefault()));
}
}
public static void main(String[] args) {
MyOptions positOpts = new MyOptions();
OERefInputAppOptions opts = new OERefInputAppOptions(positOpts, "PoseMolecules", OEFileStringType.Mol3D,
OEFileStringType.DU, OEFileStringType.DU, "-receptor");
if (oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
System.exit(0);
positOpts.UpdateValues(opts);
oemolistream ifs = new oemolistream();
if (!ifs.open(opts.GetInFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading");
oeifstream rfs = new oeifstream();
if (!rfs.open(opts.GetRefFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetRefFile() + " for reading");
oeofstream ofs = new oeofstream();
if (!ofs.open(opts.GetOutFile()))
oechem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing");
OEPosit poser = new OEPosit(positOpts);
OEDesignUnit du = new OEDesignUnit();
int count = 0;
while (oebio.OEReadDesignUnit(rfs, du)) {
if (!du.HasReceptor())
oechem.OEThrow.Fatal("Design unit " + du.GetTitle() + " does not contain a receptor");
poser.AddReceptor(du);
count++;
}
if (count == 0)
oechem.OEThrow.Fatal("Input design unit does not contain any receptor");
oechem.OEThrow.Info("Number of conformers: " + positOpts.GetNumPoses());
oechem.OEThrow.Info("Best receptor pose flag: " + positOpts.GetBestReceptorPoseOnly());
OEMol mcmol = new OEMol();
while (oechem.OEReadMolecule(ifs, mcmol)) {
oechem.OEThrow.Info("posing " + mcmol.GetTitle());
OEPositResults results = new OEPositResults();
int returnCode = poser.Dock(results, mcmol, positOpts.GetNumPoses());
if (returnCode == OEDockingReturnCode.Success) {
for (OESinglePoseResult result : results.GetSinglePoseResults()) {
OEDesignUnit posedDU = new OEDesignUnit(result.GetDesignUnit());
posedDU.SetDoubleData(poser.GetName(), result.GetProbability());
oechem.OEThrow.Info(
"Receptor used: " + posedDU.GetTitle() + " pose probability: " + result.GetProbability());
oebio.OEWriteDesignUnit(ofs, posedDU);
}
} else {
String errMsg = oedocking.OEDockingReturnCodeGetName(returnCode);
oechem.OEThrow.Warning(mcmol.GetTitle() + " : " + errMsg);
}
}
ofs.close();
ifs.close();
rfs.close();
}
}
Download code
Receptor Examples¶
Making a Receptor¶
The following code example shows how to make a receptor.
See also
OEMakeReceptorOptions class
OEMakeReceptor
method
Listing 6: Making a 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.
*/
package openeye.examples.oedocking;
import openeye.oechem.*;
import openeye.oedocking.*;
import openeye.oebio.*;
public class MakeReceptor {
public static void main(String[] args) {
OEMakeReceptorOptions recOpts = new OEMakeReceptorOptions();
OESimpleAppOptions opts = new OESimpleAppOptions(recOpts, "MakeReceptor", OEFileStringType.DU, OEFileStringType.DU);
if (oechem.OEConfigureOpts(opts, args, false) == OEOptsConfigureStatus.Help)
System.exit(0);
recOpts.UpdateValues(opts);
oeifstream ifs = new oeifstream(opts.GetInFile());
oeofstream ofs = new oeofstream(opts.GetOutFile());
OEDesignUnit du = new OEDesignUnit();
while (oebio.OEReadDesignUnit(ifs, du))
if (oedocking.OEMakeReceptor(du, recOpts))
oebio.OEWriteDesignUnit(ofs, du);
else
oechem.OEThrow.Fatal(du.GetTitle() + " failed to make a receptor");
ofs.close();
ifs.close();
}
}
Download code
Receptor Contour Volume¶
The following code example shows how to estimate a receptor outer contour volume.
See also
OEReceptor class
OEDesignUnit class
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.
*/
package openeye.examples.oedocking;
import openeye.oechem.*;
import openeye.oebio.*;
import openeye.oedocking.*;
public class ReceptorOuterContourVolume {
public static void main(String argv[]) {
if (argv.length != 1) {
oechem.OEThrow.Usage("ReceptorOuterContourVolume <receptor>");
}
OEDesignUnit du = new OEDesignUnit();
if (!oebio.OEReadDesignUnit(argv[0], du))
oechem.OEThrow.Fatal(argv[0]+" is not a valid receptor.");
if (!du.HasReceptor())
oechem.OEThrow.Fatal("Design unit " + du.GetTitle() + " does not contain a receptor");
OEReceptor receptor = du.GetReceptor();
OEFloatGrid negativeImagePotential = receptor.GetNegativeImageGrid();
float outerContourLevel = receptor.GetOuterContourLevel();
int outerCount = 0;
for (int i=0; i<negativeImagePotential.GetSize();++i) {
if (negativeImagePotential.GetValue(i) >= outerContourLevel) {
outerCount += 1;
}
}
double countToVolume = Math.pow(negativeImagePotential.GetSpacing(),3);
System.err.format("%.2f cubic Angstroms\n", outerCount * countToVolume);
}
}
Download code
Toggle Receptor Inner Contour¶
The following code example shows how to toggle receptor contour volume.
See also
OEReceptor class
OEDesignUnit class
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.
*/
package openeye.examples.oedocking;
import openeye.oechem.*;
import openeye.oebio.*;
import openeye.oedocking.*;
public class ToggleInnerContour {
static {
oechem.OEThrow.SetStrict(true);
}
public static void main(String argv[]) {
if (argv.length != 1) {
oechem.OEThrow.Usage("ToggleInnerContour <receptor>");
}
OEDesignUnit du = new OEDesignUnit();
if (!oebio.OEReadDesignUnit(argv[0], du))
oechem.OEThrow.Fatal("Unable to open receptor du file");
if (!du.HasReceptor())
oechem.OEThrow.Fatal("Design unit " + du.GetTitle() + " does not contain a receptor");
OEReceptor receptor = du.GetReceptor();
float innerContourLevel = receptor.GetInnerContourLevel();
receptor.SetInnerContourLevel(-innerContourLevel);
if (innerContourLevel > 0.0) {
oechem.OEThrow.Info("Toggling inner contour off");
} else {
oechem.OEThrow.Info("Toggling inner contour on");
}
if (!oebio.OEWriteDesignUnit(argv[0], du)) {
oechem.OEThrow.Fatal("Unable to write updated receptor");
}
}
}
Download code
Set Receptor Contour Volume¶
The following code example shows how to change the receptor outer contour volume.
See also
OEReceptor class
OEDesignUnit class
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.
*/
package openeye.examples.oedocking;
import java.util.ArrayList;
import java.util.Collections;
import openeye.oechem.*;
import openeye.oebio.*;
import openeye.oedocking.*;
public class SetOuterContourVolume {
public static void main(String argv[]) {
if (argv.length != 2) {
oechem.OEThrow.Usage("SetOuterContourVolume <receptor> <volume>");
}
OEDesignUnit du = new OEDesignUnit();
if (!oebio.OEReadDesignUnit(argv[0], du))
oechem.OEThrow.Fatal("Unable to open receptor file");
if (!du.HasReceptor())
oechem.OEThrow.Fatal("Design unit " + du.GetTitle() + " does not contain a receptor");
OEReceptor receptor = du.GetReceptor();
float outerContourVolume = Float.valueOf(argv[1].trim()).floatValue();
OEFloatGrid negativeImagePotential = receptor.GetNegativeImageGrid();
ArrayList<Float> gridElement = new ArrayList<Float>();
for (int i=0;i < negativeImagePotential.GetSize(); i++) {
gridElement.add(negativeImagePotential.GetValue(i));
}
Collections.sort(gridElement, Collections.reverseOrder());
float outerContourLevel = gridElement.get(gridElement.size()-1);
float countToVolume = (float)Math.pow(negativeImagePotential.GetSpacing(),3);
int ilevel = Math.round(outerContourVolume / countToVolume);
if (ilevel < gridElement.size()) {
outerContourLevel = gridElement.get(ilevel);
}
receptor.SetOuterContourLevel(outerContourLevel);
if (!oebio.OEWriteDesignUnit(argv[0], du)) {
oechem.OEThrow.Fatal("Unable to write updated receptor");
}
}
}
Download code