Calculating Overlap

Overlap calculation is the simplest functionality offered through the Shape TK. These set of examples show how to calculate static overlap between two objects (molecules, grids or shape query). Note that static means that the two input species (ref and fit) are not moved at all. These examples simply calculate the overlap and/or other related quantities, given the input positions. Examples for performing calculations that actually optimize the alignment/overlap are considered in a separate section.

Simple Overlap

This example reads in a reference molecule and a few fit molecules and prints out the Exact overlap calculated.

Listing 1: Simple overlap using Exact Overlap

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class SimpleOverlap {

    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("SimpleOverlap <reffile> <fitfile>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);

        OEGraphMol refmol = new OEGraphMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        // Prepare reference molecule for calculation
        // With default options this will remove any explicit hydrogens present
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.Prep(refmol);

        // Get appropriate function to calculate exact shape
        OEExactShapeFunc shapeFunc = new OEExactShapeFunc();
        shapeFunc.SetupRef(refmol);

        OEOverlapResults res = new OEOverlapResults();
        OEGraphMol fitmol = new OEGraphMol();
        while (oechem.OEReadMolecule(fitfs, fitmol)) {
            prep.Prep(fitmol);
            shapeFunc.Overlap(fitmol, res);
            System.out.print(fitmol.GetTitle());
            System.out.println(" exact tanimoto = "+res.GetTanimoto());
        }
    }
}

Adding overlap to molecules

This next example program uses the Analytic overlap method and also uses a little extra OEChem to attach the overlap scores to each molecule as SD data. This can be used to rescore a set of ROCS hits or to measure the overlap of ROCS alignments against an exclusion region in the binding site.

Listing 2: Rescoring pre-aligned structures

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class Rescore {

    public static void main(String[] args) {
        if (args.length!=3) {
            System.out.println("Rescore <reffile> <rocs_hits> <output.sdf>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);

        OEGraphMol refmol = new OEGraphMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        // Get appropriate function to calculate analytic shape
        OEAnalyticShapeFunc shapeFunc = new OEAnalyticShapeFunc();
        shapeFunc.SetupRef(refmol);

        OEOverlapResults res = new OEOverlapResults();
        OEGraphMol fitmol = new OEGraphMol();
        while (oechem.OEReadMolecule(fitfs, fitmol)) {
            shapeFunc.Overlap(fitmol, res);
            oechem.OESetSDData(fitmol, "AnalyticTanimoto", 
                    String.valueOf(res.GetTanimoto()));
            oechem.OEWriteMolecule(outfs, fitmol);
        }
    }
}

Color Overlap

This example reads in a reference molecule and a few fit molecules and prints out the Exact color score calculated. By default all color calculations are performed using the ImplicitMillsDean force field.

Listing 3: Calculating color score

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class ColorOverlap {

    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("ColorOverlap <reffile> <overlayfile>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);

        OEGraphMol refmol = new OEGraphMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        // Prepare reference molecule for calculation
        // With default options this will remove any explicit 
        // hydrogens present, and add required color atoms
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.Prep(refmol);

        // Get appropriate function to calculate exact color
        OEExactColorFunc colorFunc = new OEExactColorFunc();
        colorFunc.SetupRef(refmol);

        OEOverlapResults res = new OEOverlapResults();
        OEGraphMol fitmol = new OEGraphMol();
        while (oechem.OEReadMolecule(fitfs, fitmol)) {
            prep.Prep(fitmol);
            colorFunc.Overlap(fitmol, res);
            System.out.print("Fit. Title: "+fitmol.GetTitle()+" ");
            System.out.print("Color Score: "+res.GetColorScore()+" ");
        } 
    }
}

Adding color score to molecules

This next example uses the ImplicitMillsDean force field and the Analytic color to rescore a set of ROCS hits and add the color scores to SD tags.

Listing 4: Using color to add scores to pre-aligned 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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class ColorScore {

    public static void main(String[] args) {
        if (args.length!=3) {
            System.out.println("ColorScore <reffile> <overlayfile> <outfile>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);

        OEGraphMol refmol = new OEGraphMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        // Prepare reference molecule for calculation
        // With default options this will add required color atoms
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.Prep(refmol);

        // Get appropriate function to calculate analytic color
        OEAnalyticColorFunc colorFunc = new OEAnalyticColorFunc();
        colorFunc.SetupRef(refmol);

        OEOverlapResults res = new OEOverlapResults();
        OEGraphMol fitmol = new OEGraphMol();
        while (oechem.OEReadMolecule(fitfs, fitmol)) {
            prep.Prep(fitmol);
            colorFunc.Overlap(fitmol, res);
            oechem.OESetSDData(fitmol, "MyColorTanimoto", String.valueOf(res.GetColorTanimoto()));
            oechem.OESetSDData(fitmol, "MyColorScore",  String.valueOf(res.GetColorScore()));
            oechem.OEWriteMolecule(outfs, fitmol);

            System.out.print("Fit. Title: "+fitmol.GetTitle()+" ");
            System.out.print("Color Tanimoto: "+res.GetColorTanimoto()+" ");
            System.out.print("Color Score: "+res.GetColorScore()+" ");
        } 
    }
}

User Defined Color

As a step toward writing a complete color force field, it is possible to combine built-in rules for color atom assignment with user defined interactions. A new OEColorForceField object can be created using one of the built-in types, then the interactions can be cleared using OEColorForceField.ClearInteractions and subsequent user interactions added with OEColorForceField.AddInteraction.

For example, to use the ImplicitMillsDean atom typing rules, but to only consider donor-donor and acceptor-acceptor interactions, one can use the following:

Listing 5: Using ImplicitMillsDean with user interactions.

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class UserColor {

    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("UserColor <reffile> <overlayfile>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);

        OEGraphMol refmol = new OEGraphMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        // Modify ImplicitMillsDean color force field by
        // adding user defined color interactions
        OEColorForceField cff = new OEColorForceField();
        cff.Init(OEColorFFType.ImplicitMillsDean);
        cff.ClearInteractions();
        int donorType = cff.GetType("donor");
        int accepType = cff.GetType("acceptor");
        cff.AddInteraction(donorType, donorType, "gaussian", -1.0f, 1.0f);
        cff.AddInteraction(accepType, accepType, "gaussian", -1.0f, 1.0f);

        // Prepare reference molecule for calculation
        // With default options this will add required color atoms
        // Set the modified color force field for addignment
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.SetColorForceField(cff);
        prep.Prep(refmol);

        // Get appropriate function to calculate exact color
        // Set appropriate options to use the user defined color
        OEColorOptions options = new OEColorOptions();
        options.SetColorForceField(cff);
        OEExactColorFunc colorFunc = new OEExactColorFunc(options);
        colorFunc.SetupRef(refmol);

        OEOverlapResults res = new OEOverlapResults();
        OEGraphMol fitmol = new OEGraphMol();
        while (oechem.OEReadMolecule(fitfs, fitmol)) {
            prep.Prep(fitmol);
            colorFunc.Overlap(fitmol, res);
            System.out.print("Fit. Title: "+fitmol.GetTitle()+" ");
            System.out.println("Color TAnimoto: "+res.GetColorTanimoto());
        } 
    }
}

Shape and Color Overlap

This example reads in a reference molecule and a few fit molecules and prints out both the shape overlap and the color score calculated. By default the OEOverlapFunc uses the Grid shape and Exact color.

Listing 6: Calculating both shape and color overlap

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class OverlapColor {

    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("OverlapColor <reffile> <fitfile>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);

        OEGraphMol refmol = new OEGraphMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        // Prepare reference molecule for calculation
        // With default options this will remove any explicit hydrogens present
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.Prep(refmol);

        // Get appropriate function to calculate both shape and color
        // By default the OEOverlapFunc contains OEGridShapeFunc for shape 
        // and OEExactColorFunc for color
        OEOverlapFunc func = new OEOverlapFunc();
        func.SetupRef(refmol);

        OEOverlapResults res = new OEOverlapResults();
        OEGraphMol fitmol = new OEGraphMol();
        while (oechem.OEReadMolecule(fitfs, fitmol)) {
            prep.Prep(fitmol);
            func.Overlap(fitmol, res);
            System.out.print(fitmol.GetTitle());
            System.out.println(" tanimoto combo = "+res.GetTanimotoCombo());
            System.out.println(" shape tanimoto = "+res.GetTanimoto());
            System.out.println(" color tanimoto = "+res.GetColorTanimoto());
        }
    }
}

ROCS

The high-level OEROCS provides the simplest way to maximize shape and/or color between two objects. OEROCS uses the same shape and color functions as used for static overlap calculation, but optimizes the overlap between the reference and the fit objects. By default both shape and color optimization is performed, with shape estimated the Grid method and color estimated with the Exact method.

The fit object is not moved during the optimization. Part of the results returned from the calculation are the transform required to move the fit object into the final orientation. The results also contain a copy of the fit molecule conformer(s) in its final orientation.

A helper function OEROCSOverlay is created for the most simple usage of the functionality that performs optimizations between a set of conformers and returns the best hit.

Best Hit

This example reads in a reference molecule and a fit molecule, performs overlay optimization, finds the best hit conformer and prints it out in final orientation.

Listing 7: Finding best hit conformer pair

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class BestHit {

    public static void main(String[] args) {
        if (args.length!=3) {
            System.out.println("BestHit <reffile> <fitfile> <outfile>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);

        OEMol refmol = new OEMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        OEMol fitmol = new OEMol();
        oechem.OEReadMolecule(fitfs, fitmol);
        fitfs.close();

        OEROCSResult res = new OEROCSResult();
        oeshape.OEROCSOverlay(res, refmol, fitmol);
        OEMolBase outmol = res.GetOverlayConf();

        oechem.OEWriteMolecule(outfs, outmol);
        System.out.println("Tanimoto combo = "+res.GetTanimotoCombo());
    }
}

Top Hits

This example reads in a reference molecule and a few fit molecules, performs overlay optimization, finds the few top hits, and prints them out in final orientation.

Listing 8: Finding top ROCS hits

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class TopHits {

    public static void main(String[] args) {
        if (args.length!=4) {
            System.out.println("TopHits <reffile> <fitfile> <outfile> <nhits>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);
        int nhits = Integer.parseInt(args[3]);

        OEMol refmol = new OEMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        // Setup OEROCS with specified number of best hits
        OEROCSOptions options = new OEROCSOptions();
        options.SetNumBestHits(nhits);
        OEROCS rocs = new OEROCS(options);
        rocs.SetDatabase(fitfs);

        for (OEROCSResult res : rocs.Overlay(refmol))
        {
            OEGraphMol outmol = new OEGraphMol(res.GetOverlayConf());
            oechem.OEWriteMolecule(outfs, outmol);
            System.out.println(" title = "+outmol.GetTitle());
            System.out.println(" tanimoto combo = "+res.GetTanimotoCombo());
        }
    }
}

Top Hits with Multiple Conformers

This example repeats the Top Hits example above but fixes the number of hits to 3 and askes for multiple best conformers for each hit reported.

Listing 9: Finding top ROCS hits with multiple 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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class TopHitsConf {

    public static void main(String[] args) {
        if (args.length!=4) {
            System.out.println("TopHitsConf <reffile> <fitfile> <outfile> <confsperhit>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);
        int nconfs = Integer.parseInt(args[3]);

        OEMol refmol = new OEMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();

        // Setup OEROCS with specified number of best hits
        OEROCSOptions options = new OEROCSOptions();
        options.SetNumBestHits(3);
        options.SetConfsPerHit(nconfs);
        OEROCS rocs = new OEROCS(options);
        rocs.SetDatabase(fitfs);

        for (OEROCSResult res : rocs.Overlay(refmol))
        {
            OEGraphMol outmol = new OEGraphMol(res.GetOverlayConf());
            oechem.OEWriteMolecule(outfs, outmol);
            System.out.println(" title = "+outmol.GetTitle());
            System.out.println(" tanimoto combo = "+res.GetTanimotoCombo());
        }
    }
}

Overlay Optimization

The OEOverlay provides more sets of results compared to OEROCS, and should be used only when such regorous aoumnt of resulting data is desired. Another difference between the two is that in OEOverlay only a single conformer can be used as reference, designed such for efficiency.

A single OEOverlay calculation will return N results, where N is the number of ref conformers times the number of fit conformers times the number of starting positions for each pair. So comparing 2 molecules with 10 conformers each could return 400 or more results.

There are two helper classes designed solely to contain these results and to make it easy to extract all or just the desired subset. OEBestOverlayResults holds the results of a single pair of conformers. It contains a set of OEBestOverlayScore objects, one for each starting position.

All Optimization Results

This example reads in a reference molecule and a few fit molecules, performs overlay optimization, and uses 2 iterators to show all the results.

Listing 10: Getting all the scores from OEOverlay.

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

// This example reads in a reference molecule and a few fit
// molecules, performs overlay optimization, and uses 2 iterators to
// show all the results.
// With the default options, OEOverlay optimizes both shape and color.

package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class OverlayAllRes {

    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("OverlayAllRes <reffile> <fitfile>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);

        OEMol refmol = new OEMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();
        System.out.print("Ref. title: "+refmol.GetTitle()+" ");
        System.out.println("Num Confs: "+refmol.NumConfs());

        // Prepare reference molecule for calculation
        // With default options this will remove any explicit 
        // hydrogens present and add color atoms
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.Prep(refmol);          

        OEOverlay overlay = new OEOverlay();      
        for (OEConfBase refconf : refmol.GetConfs()){
            int refidx = refconf.GetIdx();
            overlay.SetupRef(new OEGraphMol(refconf));

            OEMol fitmol = new OEMol();
            while (oechem.OEReadMolecule(fitfs, fitmol)) {
                System.out.print("Fit. title: "+fitmol.GetTitle()+" ");
                System.out.println("Num Confs: "+fitmol.NumConfs());

                prep.Prep(fitmol);
                int resCount=0;

                // double loop over results and scores to obtain all scores
                for (OEBestOverlayResults res : overlay.Overlay(fitmol)) {
                    for (OEBestOverlayScore score : res.GetScores()) {
                        System.out.print("FitConfIdx: "+score.GetFitConfIdx()+" ");
                        System.out.print("RefConfIdx: "+refidx+" ");
                        System.out.println("Tanimoto Combo: "+score.GetTanimotoCombo());
                        ++resCount;
                    }
                }
                System.out.println(resCount+" results returned.");
            } 
            fitfs.rewind();          
        }
        fitfs.close();  
    }
}

Best Optimization Results

This example repeats the above, but shows only the single best overlap for each conformer-conformer pair. Here, the OESortOverlayScores function is used to turn the double iterator as shown in the example above into a single iterator of OEBestOverlayScore. Note that the third argument is a functor used to sort the list, such that in this next example, we get one OEBestOverlayScore for each pair of conformers and they are returned in Tanimoto order.

Listing 11: Getting all the best scores from OEOverlay.

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

// This example reads in a reference molecule and a few fit
// molecules, performs overlay optimization, sorts the results
// in tanimoto order, and shows the best results.
// With the default options, OEOverlay optimizes both shape and color.

package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class OverlayBestRes {

    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("OverlayBestRes <reffile> <fitfile>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);

        OEMol refmol = new OEMol();
        oechem.OEReadMolecule(reffs, refmol);
        reffs.close();
        System.out.print("Ref. title: "+refmol.GetTitle()+" ");
        System.out.println("Num Confs: "+refmol.NumConfs());

        // Prepare reference molecule for calculation
        // With default options this will remove any explicit 
        // hydrogens present and add color atoms
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.Prep(refmol);

        OEOverlay overlay = new OEOverlay(); 
        for (OEConfBase refconf : refmol.GetConfs()){
            int refidx = refconf.GetIdx();
            overlay.SetupRef(new OEGraphMol(refconf));

            OEMol fitmol = new OEMol();
            while (oechem.OEReadMolecule(fitfs, fitmol)) {
                System.out.print("Fit. title: "+fitmol.GetTitle()+" ");
                System.out.println("Num Confs: "+fitmol.NumConfs());

                prep.Prep(fitmol);
                int resCount=0;
            
                OEBestOverlayResultsIter resiter = overlay.Overlay(fitmol);

                // Sort all scores according to highest tanimoto
                OEBestOverlayScoreIter scoreiter = new OEBestOverlayScoreIter();
                oeshape.OESortOverlayScores(scoreiter, resiter, new OEHighestTanimoto());

                // Single loop over sorted scores
                for (OEBestOverlayScore score : scoreiter) {
                    System.out.print("FitConfIdx: "+score.GetFitConfIdx()+" ");
                    System.out.print("RefConfIdx: "+refidx+" ");
                    System.out.println("Tanimoto Combo: "+score.GetTanimotoCombo());
                    ++resCount;
                }
                System.out.println(resCount+" results returned.");
            } 
            fitfs.rewind();         
        }
        fitfs.close();
    }
}

Saving aligned structures

OEOverlay does not actually move the fit molecule. Part of OEBestOverlayScore is the rotation matrix and translation matrix necessary to move the fit molecule into the final overlap position. (N.B. the rotation matrix is left-multiplied so can be regarded as left-handed.) This example shows how to apply these transformations. The OpenEye standard is rotation then translation, but as a convenience, OEBestOverlayScore has OEBestOverlayScore.Transform method that will apply the transforms in the proper order.

This next example expands from the previous, keeps the user specified number of scores, aligns each fit conformer to the ref conformer it was overlaid on, and then write the pair to an output file. If SD or OEB is used as the output file type, then scores will also be stored in SD tags.

Listing 12: Writing aligned structures from OEOverlay.

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

// This example reads in a reference molecule and a few fit
// molecules, performs overlay optimization, sorts the results
// in tanimoto order, shows the user specified number of 
// results, and saves the overlayed structures.
// With the default options, OEOverlay optimizes both shape and color.

package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class OverlayStruct {

    public static void main(String[] args) {
        if (args.length!=4) {
            System.out.println("OverlayStruct <reffile> <fitfile> <out.sdf> <keepsize>");
            System.exit(0);
        }

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);
        int keepsize = Integer.parseInt(args[3]);

        OEMol refmol = new OEMol();
        oechem.OEReadMolecule(reffs, refmol);
        System.out.print("Ref. title: "+refmol.GetTitle()+" ");
        System.out.println("Num Confs: "+refmol.NumConfs());
        reffs.close();

        // Prepare reference molecule for calculation
        // With default options this will remove any explicit 
        // hydrogens present and add color atoms
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.Prep(refmol);

        OEOverlay overlay = new OEOverlay();
        for (OEConfBase refconf : refmol.GetConfs()){
            int refidx = refconf.GetIdx();
            overlay.SetupRef(new OEGraphMol(refconf));

            OEMol fitmol = new OEMol();
            while (oechem.OEReadMolecule(fitfs, fitmol)) {
                System.out.print("Fit. title: "+fitmol.GetTitle()+" ");
                System.out.println("Num Confs: "+fitmol.NumConfs());
                OEBestOverlayResultsIter resiter = overlay.Overlay(fitmol);

                prep.Prep(fitmol);
                int resCount=0;

                // Sort all scores according to highest tanimoto 
                OEBestOverlayScoreIter scoreiter = new OEBestOverlayScoreIter();
                oeshape.OESortOverlayScores(scoreiter, overlay.Overlay(fitmol), new OEHighestTanimoto());

                for (OEBestOverlayScore score : scoreiter) {
                    OEGraphMol outmol = new OEGraphMol(fitmol.GetConf(new OEHasConfIdx(score.GetFitConfIdx())));
                    score.Transform(outmol);

                    oechem.OESetSDData(outmol, "RefConfIdx", String.valueOf(refidx));
                    oechem.OESetSDData(outmol, "Tanimoto Combo", String.valueOf(score.GetTanimotoCombo()));

                    oechem.OEWriteConstMolecule(outfs, refmol.GetConf(new OEHasConfIdx(refidx)));
                    oechem.OEWriteConstMolecule(outfs, outmol);

                    ++resCount;

                    // Break at the user specified size
                    if (resCount==keepsize)
                        break;
                }
                System.out.println(resCount+" results returned.");
            } 
            fitfs.rewind();   
        }
        fitfs.close();
        outfs.close();   
    }
}

Working with Shape Query

This section of examples shows the use of a OEShapeQuery, and performs calculations where a shape query is used a the reference system instead of a molecule as the reference.

Creating a shape query

This examples shows how to create a simple shape query that combines a molecule with gaussians. In this example, the molecule is added in the query to define shape, and color is added separately in terms to gaussians. The created query is then saved in a file.

Listing 13: Creating a shape query.

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oegrid.*;
import openeye.oeshape.*;

public class CreateQuery {

    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("CreateQuery <molfile> <outfile>");
            System.exit(0);
        }

        oemolistream molfs = new oemolistream(args[0]);
        OEGraphMol mol = new OEGraphMol();
        oechem.OEReadMolecule(molfs, mol);
        molfs.close();

        // Use OEOverlapPrep to remove hydrogens and add 
        // color atoms to the molecule
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.Prep(mol);

        // Get the color atoms, create gaussians and add them
        // to the shape query
        OEShapeQuery query = new OEShapeQuery();
        for (OEAtomBase atom : oeshape.OEGetColorAtoms(mol)){
            OEFloatArray coords = new OEFloatArray(3);
            mol.GetCoords(atom, coords);
            OEGaussian gauss = new OEGaussian(1.0f, 1.0f, coords, oeshape.OEGetColorType(atom));
            query.AddColorGaussian(gauss);
        }

        // Remove color atoms from the molecule and add to the query
        oeshape.OERemoveColorAtoms(mol);
        query.SetMolecule(mol);

        oeshape.OEWriteShapeQuery(args[1], query);
        System.out.println("shape query created");
    }
}

Overlap with shape query

This example reads in a reference shape query and a few fit molecules and prints out both the shape overlap and the color score calculated. By default the OEOverlapFunc uses the Grid shape and Exact color.

Listing 14: Overlap with a shape query

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class OverlapQuery {

    public static void main(String[] args) {
        if (args.length!=2) {
            System.out.println("OverlapQuery <queryfile> <fitfile>");
            System.exit(0);
        }

        OEShapeQuery query = new OEShapeQuery();
        oeshape.OEReadShapeQuery(args[0], query);

        // Get appropriate function to calculate both shape and color
        // By default the OEOverlapFunc contains OEGridShapeFunc for shape 
        // and OEExactColorFunc for color
        OEOverlapFunc func = new OEOverlapFunc();
        func.SetupRef(query);

        OEOverlapResults res = new OEOverlapResults();
        oemolistream fitfs = new oemolistream(args[1]);
        OEOverlapPrep prep = new OEOverlapPrep(); 
        OEGraphMol fitmol = new OEGraphMol();
        while (oechem.OEReadMolecule(fitfs, fitmol)) {
            prep.Prep(fitmol);
            func.Overlap(fitmol, res);
            System.out.print(fitmol.GetTitle());
            System.out.println(" tanimoto combo = "+res.GetTanimotoCombo());
            System.out.println(" shape tanimoto = "+res.GetTanimoto());
            System.out.println(" color tanimoto = "+res.GetColorTanimoto());
        }
    }
}

Top hit against shape query

This example reads in a reference query and a few fit molecules, performs overlay optimization, finds the few top hits, and prints them out in final orientation.

Listing 15: Finding top ROCS hits against a query

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class TopHitsQuery {

    public static void main(String[] args) {
        if (args.length!=4) {
            System.out.println("TopHitsQuery <reffile> <fitfile> <outfile> <nhits>");
            System.exit(0);
        }

        oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);
        int nhits = Integer.parseInt(args[3]);

        OEShapeQuery query = new OEShapeQuery();
        oeshape.OEReadShapeQuery(args[0], query);

        // Setup OEROCS with specified number of best hits
        OEROCSOptions options = new OEROCSOptions();
        options.SetNumBestHits(nhits);
        OEROCS rocs = new OEROCS(options);
        rocs.SetDatabase(fitfs);

        for (OEROCSResult res : rocs.Overlay(query))
        {
            OEGraphMol outmol = new OEGraphMol(res.GetOverlayConf());
            oechem.OEWriteMolecule(outfs, outmol);
            System.out.println(" title = "+outmol.GetTitle());
            System.out.println(" tanimoto combo = "+res.GetTanimotoCombo());
        }
    }
}

Shape from Hermite expansion

Using Hermite expansion we can obtain two functionalities: expand a molecule into Hermite representation and compare two molecules that are in the Hermite representation by computing their shape-Tanimoto coefficient. We illustrate both functionalities below with two examples.

Hermite expansion

In this example we input a molecule, set the level of Hermite expansion using NPolyMax variable, determine the optimal parameters for \(\lambda_x, \lambda_y, \lambda_z\), and perform the computation of the Hermite expansion. At the end we output the resulting Hermite representation of the molecule as a grid, using CreateGrid method of the OEHermite class. The user can vary NPolyMax from low numbers, like 4 or 5, to higher numbers like 10-30 and observe convergence of the shape. Which value to use in practice depends on the size of the input molecule. Input molecule can be drug-like as well as a protein.

Hermite Tanimoto comparison of shape

In the second example below we setup two molecules and compute the Tanimoto-shape similarity coefficient, using Hermite expansion. The Hermite prep parameter NPolyMax_MAX is used to vary NPolyMax parameter and compute the shape-Tanimoto each time for the first molecule in the reference input file versus all molecules in the fit input file. All results are attached as SD data in the output file. One can observe convergence of the Hermite Tanimoto coefficients as the level of expansion becomes more accurate.

Advanced Examples

Calculating NxN scores

There are times when you want to have all the pair-wise scores among a set of molecules. Maintaining this 2D matrix of scores is more complicated than the single set of scores from the ref vs. set of fit molecules examples shown above.

This example takes a set of molecules and performs all the pair-wise shape optimizations with OEBestOverlay. It outputs a spreadsheet of the scores.

Listing 18: Calculating NxN scores.

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;
import java.io.*;
import java.text.DecimalFormat;

public class NxNShape {
    static { 
        oechem.OEThrow.SetStrict(true);
    }

    private static FileOutputStream csv;
    private static PrintWriter csvfile;
    private static DecimalFormat df = new DecimalFormat("#.##");

    private String roundOff(float score) {
        return df.format(score);
    }

    private void oneConf(OEConfBase conf, OEOverlapPrep prep, String filename) {
        csvfile.print(conf.GetTitle() + "_" + conf.GetIdx());
        OEMol refmol = new OEMol(conf);

        OEOverlayOptions options = new OEOverlayOptions();
        options.SetOverlapFunc(new OEGridShapeFunc());
        OEOverlay overlay = new OEOverlay();
        overlay.SetupRef(refmol);

        oemolistream bfs = new oemolistream(filename);
        OEMol fitmol = new OEMol();
        while (oechem.OEReadMolecule(bfs, fitmol)) {
            prep.Prep(fitmol);
            OEBestOverlayResultsIter resiter = overlay.Overlay(fitmol);
            OEBestOverlayScoreIter scoreiter = new OEBestOverlayScoreIter();
            oeshape.OESortOverlayScores(scoreiter, resiter, new OEHighestTanimoto(), 1, true);
            for (OEBestOverlayScore score : scoreiter) {
                csvfile.print("," + roundOff(score.GetTanimoto()));
            }
        }
    }

    private void genHeader(String filename) {
        csvfile.print("name");
        oemolistream ifs = new oemolistream(filename);
        OEMol mol = new OEMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            System.out.println(mol.GetTitle());
            for (OEConfBase conf : mol.GetConfs()) {
                csvfile.print("," + conf.GetTitle() + "_" + conf.GetIdx());
            }
        }
        ifs.close();
        csvfile.println();
    }

    private void openCSV(String csvfilename) {
        try {
            csv = new FileOutputStream(csvfilename);
            csvfile = new PrintWriter(csv);
        } catch (FileNotFoundException e) {
            System.err.println("Unable to open output file " + csvfilename);
        }
    }

    public void nxn(String filename, String csvfilename) {
        openCSV(csvfilename);
        genHeader(filename);
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.SetAssignColor(false);
        oemolistream afs = new oemolistream(filename);
        OEMol molA = new OEMol();
        while (oechem.OEReadMolecule(afs, molA)) {
            prep.Prep(molA);
            for (OEConfBase conf : molA.GetConfs()) {
                oneConf(conf, prep, filename);
            }
        }
        csvfile.close();
        afs.close();
    }

    public static void main(String[] args) {
        if (args.length != 2) {
            System.out.println("NxNShape <infile> <csvfile>");
            System.exit(0);
        }
        NxNShape app = new NxNShape();
        app.nxn(args[0], args[1]);
    }
}

Calculating shape characteristics

While most functionality in the Shape Toolkit involves comparison of pairs of molecules, there are a few fundamental properties that can be calculated for a single molecule. All of these calculations are done using the same basic Gaussian description of a molecule as described above.

The simplest property to calculate is volume, using OECalcVolume.

In addition to simple volume calculations, the steric multipoles of a molecule can also be calculated. See section OECalcShapeMultipoles.

This next example demonstrates the calculation of volume and shape multipoles.

Listing 19: Calculating shape properties.

/*
(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.
*/
package openeye.examples.oeshape;

import openeye.oechem.*;
import openeye.oeshape.*;

public class ShapeProps {

    public static void main(String[] args) {
        if (args.length!=1) {
            System.out.println("ShapeProps <infile>");
            System.exit(0);
        }

        oemolistream ifs = new oemolistream(args[0]);

        OEGraphMol mol = new OEGraphMol();

        while (oechem.OEReadMolecule(ifs,mol)) {
            System.out.println("              Title: "+mol.GetTitle());
            System.out.println("             Volume: "+oeshape.OECalcVolume(mol));
            System.out.println("Volume: (without H): "+
                    oeshape.OECalcVolume(mol, false));

            float [] smult = new float[14];
            oeshape.OECalcShapeMultipoles(mol, smult);

            System.out.println("  Steric multipoles:");
            System.out.println("           monopole: "+smult[0]);
            System.out.println("        quadrupoles: "+ 
                    smult[1]+" "+smult[2]+" "+smult[3]);
            System.out.println("          octopoles:");
            System.out.println("                xxx: "+smult[4]+
                    " yyy: "+smult[5]+" zzz: "+smult[6]);
            System.out.println("                xxy: "+smult[7]+
                    " xxz: "+smult[8]+" yyx: "+smult[9]);
            System.out.println("                yyz: "+smult[10]+
                    " zzx: "+smult[11]+" zzy: "+smult[12]);
            System.out.println("                xyz: "+smult[13]);

            System.out.println("");
        }
        ifs.close();
    }
}

Calculating excluded volume

This code demonstrates how to use the shape toolkit to do an overlay to a crystallographic ligand, then calculate the overlap of the database molecule to the cognate protein. The output includes a new score Rescore which is the ShapeTanimotoCombo penalised by the fraction overlap.

Command Line Interface

A description of the command line interface can be obtained by executing the program with the –help argument.

prompt> java ExcludeVolume --help

will generate the following output:

-q : Query file name
-e : Protein to use as exclusion volume
-d : Database file name
-o : Output file name

Code

Download code

ExcludeVolume.java and ExcludeVolume.txt interface file