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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class SimpleOverlap 
{
    public static void Main(string [] args) 
    {
        if (args.Length != 2)
            OEChem.OEThrow.Usage("UserColor <reffile> <fitfile>");

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

        OEGraphMol refmol = new OEGraphMol();
        OEChem.OEReadMolecule(reffs, refmol);

        // 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();
        foreach (OEGraphMol fitmol in fitfs.GetOEGraphMols())
        {
            prep.Prep(fitmol);
            shapeFunc.Overlap(fitmol, res);
            Console.WriteLine("{0} exact tanimoto = {1}",
                            fitmol.GetTitle(), 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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class Rescore 
{
    public static void Main(string [] args) 
    {
        if (args.Length != 4) 
            OEChem.OEThrow.Usage("Rescore <reffile> <rocs_hits> <output.sdf>");

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

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

        OEOverlapResults res = new OEOverlapResults();
        foreach (OEGraphMol fitmol in fitfs.GetOEGraphMols()) 
        {
            shapeFunc.Overlap(fitmol, res);
            OEChem.OESetSDData(fitmol, "AnalyticTanimoto", Convert.ToString(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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class ColorOverlap
{
    public static void Main(string [] args)
    {
        if (args.Length != 3)
            OEChem.OEThrow.Usage("UserColor <reffile> <overlayfile>");

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

        OEGraphMol refmol = new OEGraphMol();
        OEChem.OEReadMolecule(reffs, refmol);

        // 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();
        foreach (OEGraphMol fitmol in fitfs.GetOEGraphMols())
        {
            prep.Prep(fitmol);
            colorFunc.Overlap(fitmol, res);
            Console.WriteLine("{0} color score = {1}",
                              fitmol.GetTitle(), res.colorscore);
        }
    }
}

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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class ColorScore 
{
    public static void Main(string [] args) 
    {
        if (args.Length != 3)
            OEChem.OEThrow.Usage("ColorScore <reffile> <rocs_hits_file> <output.sdf>");

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

        // 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();
        foreach (OEGraphMol fitmol in fitfs.GetOEGraphMols())
        {
            prep.Prep(fitmol);
            colorFunc.Overlap(fitmol, res);
            OEChem.OESetSDData(fitmol, "MyColorTanimoto", Convert.ToString(res.GetColorTanimoto()));
            OEChem.OESetSDData(fitmol, "MyColorScore", Convert.ToString(res.GetColorScore()));
            OEChem.OEWriteMolecule(outfs, fitmol);

            Console.WriteLine("Fit Title: {0} ColorTanimoto: {1} Color score: {2}",
                              fitmol.GetTitle(), res.GetColorTanimoto(), 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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class UserColor 
{
    public static void Main(string [] args) 
    {
        if (args.Length != 2) 
             OEChem.OEThrow.Usage("UserColor <reffile> <overlayfile>");

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

        OEGraphMol refmol = new OEGraphMol();
        OEChem.OEReadMolecule(reffs, refmol);

        // Modify ImplicitMillsDean color force field by
        // adding user defined color interactions
        OEColorForceField cff = new OEColorForceField();
        cff.Init(OEColorFFType.ImplicitMillsDean);
        cff.ClearInteractions();
        uint donorType = cff.GetType("donor");
        uint 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();
        foreach (OEGraphMol fitmol in fitfs.GetOEGraphMols()) 
        {
            prep.Prep(fitmol);
            colorFunc.Overlap(fitmol, res);
            Console.WriteLine("Fit Title: {0} ColorTanimoto: {1}",
                              fitmol.GetTitle(),
                              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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class OverlapColor 
{
    public static void Main(string [] args) 
    {
        if (args.Length != 2)
            OEChem.OEThrow.Usage("OverlapColor <reffile> <fitfile>");

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

        OEGraphMol refmol = new OEGraphMol();
        OEChem.OEReadMolecule(reffs, refmol);

        // 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();
        foreach (OEGraphMol fitmol in fitfs.GetOEGraphMols())
        {
            prep.Prep(fitmol);
            func.Overlap(fitmol, res);
            Console.WriteLine("{0} tanimoto combo = {1} shape tanimoto = {2} color tanimoto = {3}",
                            fitmol.GetTitle(), res.GetTanimotoCombo(), res.GetTanimoto(), 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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class BestHit 
{
	public static void Main(string [] args) 
	{
		if (args.Length != 3) 
			OEChem.OEThrow.Usage("BestHit <reffile> <fitfile> <outfile>");
	
		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);

        OEMol fitmol = new OEMol();
        OEChem.OEReadMolecule(fitfs, fitmol);

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

        OEChem.OEWriteMolecule(outfs, outmol);
        Console.WriteLine("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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class TopHits 
{
	public static void Main(string [] args) 
	{
		if (args.Length != 4) 
			OEChem.OEThrow.Usage("TopHits <reffile> <fitfile> <outfile> <nhits>");
	
		oemolistream reffs = new oemolistream(args[0]);
		oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);
        uint nhits = Convert.ToUInt32(args[3]);
		
		OEMol refmol = new OEMol();
		OEChem.OEReadMolecule(reffs, refmol);

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

    	foreach (OEROCSResult res in rocs.Overlay(refmol))
    	{
    		OEMolBase outmol = res.GetOverlayConf();
        	OEChem.OEWriteMolecule(outfs, outmol);
        	Console.WriteLine("title: {0}  tanimoto combo = {1}",
                              outmol.GetTitle(), res.GetTanimotoCombo());
    	}
	}
}

Top Hits with Multiple Conformers

This example repeats the Top Hits example above but fixes the number of hits to 3 and asks 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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class TopHitsConf
{
	public static void Main(string [] args) 
	{
		if (args.Length != 4) 
			OEChem.OEThrow.Usage("TopHitsConf <reffile> <fitfile> <outfile> <confsperhit>");
	
		oemolistream reffs = new oemolistream(args[0]);
		oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);
        uint nconfs = Convert.ToUInt32(args[3]);
		
		OEMol refmol = new OEMol();
		OEChem.OEReadMolecule(reffs, refmol);

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

    	foreach (OEROCSResult res in rocs.Overlay(refmol))
    	{
    		OEMCMolBase outmol = res.GetOverlayConfs();
        	OEChem.OEWriteMolecule(outfs, outmol);
        	Console.WriteLine("title: {0}  tanimoto combo = {1}",
                              outmol.GetTitle(), res.GetTanimotoCombo());
    	}
	}
}

Overlay Optimization

The OEOverlay and OEMultiRefOverlay, compared to OEROCS, allows setting up a reference system and process overlay optimization of multiple fit molecules. Another difference is that both OEOverlay and OEMultiRefOverlay, in addition to providing the best overlay score, also gives access to all the results obtained during a overlay optimization. Methods Overlay and Overlay, that provides all results should only be used when such rigorous amount of resulting data is desired.

Best Optimization Result

This example reads in a reference molecule and a few fit molecules, performs overlay optimization, and returns only the best result per reference to fit molecule overlay optimization.

Listing 10: Getting the best scores from OEMultiRefOverlay.

/*
(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 single best result.
// With the default options, OEOverlay optimizes both shape and color.

using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class OverlayBestRes
{
    public static void Main(string[] args)
    {
        if (args.Length != 2)
            OEChem.OEThrow.Usage("OverlayBestRes <reffile> <fitfile>");

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

        OEMol refmol = new OEMol();
        OEChem.OEReadMolecule(reffs, refmol);
        Console.WriteLine("Ref. title: {0} Num Confs: {0}\n",
                          refmol.GetTitle(), 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);

        OEMultiRefOverlay overlay = new OEMultiRefOverlay();
        overlay.SetupRef(refmol);

        foreach (OEMol fitmol in fitfs.GetOEMols())
        {
            prep.Prep(fitmol);
            OEBestOverlayScore score = new OEBestOverlayScore();
            overlay.BestOverlay(score, fitmol, new OEHighestTanimoto());
            Console.WriteLine("Fit. title: {0} FitConfIdx: {0}  RefConfIdx: {1}  Tanimoto Combo: {2}",
                                fitmol.GetTitle(), score.GetFitConfIdx(), score.GetRefConfIdx(), score.GetTanimotoCombo());          
        }
    }
}

All Optimization Results

This example repeats the above, but uses Overlay to obtain all the results.

A single Overlay 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.

This example uses 2 iterators to show all the results.

Listing 11: Getting all the scores from OEMultiRefOverlay.

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

using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class OverlayAllRes 
{
	public static void Main(string [] args) 
	{
		if (args.Length != 2) 
			OEChem.OEThrow.Usage("OverlayAllRes <reffile> <fitfile>");
	
		oemolistream reffs = new oemolistream(args[0]);
		oemolistream fitfs = new oemolistream(args[1]);
		
		OEMol refmol = new OEMol();
		OEChem.OEReadMolecule(reffs, refmol);
        Console.WriteLine("Ref. title: {0} Num Confs: {0}\n",
                          refmol.GetTitle(), 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);

        OEMultiRefOverlay overlay = new OEMultiRefOverlay();
        overlay.SetupRef(refmol);

        foreach (OEMol fitmol in fitfs.GetOEMols())
		{			
			Console.WriteLine("Fit. title: {0}  Num Confs: {1}", 
			             fitmol.GetTitle(), fitmol.NumConfs());

            int resCount = 0;

            // double loop over results and scores to obtain all scores
            foreach (OEBestOverlayResults res in overlay.Overlay(fitmol))
            {
                foreach (OEBestOverlayScore score in res.GetScores())
                {
                    Console.WriteLine("FitConfIdx: {0}  RefConfIdx: {1}  Tanimoto Combo: {2}",
                                        score.GetFitConfIdx(), score.GetRefConfIdx(), score.GetTanimotoCombo());
                    ++resCount;
                }
            }
            Console.WriteLine(resCount+" results returned.");      			  
		}
	}
}

Manipulating all results

This example repeats the above to access all overlay results, and shows how to navigate through the results to extract a specific set. 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.

OEOverlay or OEMultiRefOverlay 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 also 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 example 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 few aligned structures from OEMultiRefOverlay.

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

using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class OverlayStruct
{
    public static void Main(string[] args)
    {
        if (args.Length != 4)
            OEChem.OEThrow.Usage("OverlayStruct <reffile> <fitfile> <outsdf> <keepsize>");

        oemolistream reffs = new oemolistream(args[0]);
        oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);
        uint keepSize = Convert.ToUInt32(args[3]);

        OEMol refmol = new OEMol();
        OEChem.OEReadMolecule(reffs, refmol);
        Console.WriteLine("Ref. title: {0} Num Confs: {0}\n",
                          refmol.GetTitle(), 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);

        OEMultiRefOverlay overlay = new OEMultiRefOverlay();
        overlay.SetupRef(refmol);

        foreach (OEMol fitmol in fitfs.GetOEMols())
        {
            Console.WriteLine("Fit. title: {0}  Num Confs: {1}",
                        fitmol.GetTitle(), fitmol.NumConfs());

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

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

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

                OEChem.OESetSDData(outmol, "RefConfIdx", Convert.ToString(score.GetRefConfIdx()));
                OEChem.OESetSDData(outmol, "Tanimoto Combo", Convert.ToString(score.GetTanimotoCombo()));

                OEChem.OEWriteConstMolecule(outfs, outmol);

                ++resCount;

                // Break at the user specified size
                if (resCount == keepSize) 
                    break;
            }
            Console.WriteLine(resCount + " results returned.");            
        }
    }
}

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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class CreateQuery 
{
	public static void Main(string [] args) 
	{
		if (args.Length != 2) 
			OEChem.OEThrow.Usage("CreateQuery <molfile> <outfile>");
	
		oemolistream molfs = new oemolistream(args[0]);
		OEGraphMol mol = new OEGraphMol();
		OEChem.OEReadMolecule(molfs, mol);

		// 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();
    	foreach (OEAtomBase atom in OEShape.OEGetColorAtoms(mol))
    	{
    		float[] coords = new float[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);
	    Console.WriteLine("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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class OverlapQuery
{
    public static void Main(string [] args) 
    {
        if (args.Length != 2)
            OEChem.OEThrow.Usage("OverlapQuery <queryfile> <fitfile>");

        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();       
        foreach (OEGraphMol fitmol in fitfs.GetOEGraphMols())
        {
            prep.Prep(fitmol);
            func.Overlap(fitmol, res);
            Console.WriteLine("{0} tanimoto combo = {1} shape tanimoto = {2} color tanimoto = {3}",
                            fitmol.GetTitle(), res.GetTanimotoCombo(), res.GetTanimoto(), 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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class TopHitsQuery
{
	public static void Main(string [] args) 
	{
		if (args.Length != 4) 
			OEChem.OEThrow.Usage("TopHitsQuery <reffile> <fitfile> <outfile> <nhits>");
	
		oemolistream fitfs = new oemolistream(args[1]);
        oemolostream outfs = new oemolostream(args[2]);
        uint nhits = Convert.ToUInt32(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);
    	foreach (OEROCSResult res in rocs.Overlay(query))
    	{
    		OEMolBase outmol = res.GetOverlayConf();
        	OEChem.OEWriteMolecule(outfs, outmol);
        	Console.WriteLine("title: {0}  tanimoto combo = {1}",
                              outmol.GetTitle(), 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 coefficient. First molecule in the reference input file is used versus all molecules in the fit input file. Results are attached as SD data to the moved fit molecule, as dictated by Hermite overlay, and sent to 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 pairwise 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 pairwise 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.
*/
using System;
using System.IO;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class NxNShape 
{
    private static StreamWriter csv;

    private void OneConf(OEConfBase conf, OEOverlapPrep prep, String filename) 
    {
        csv.Write("{0}_{1}", 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);
        foreach (OEMol fitmol in bfs.GetOEMols()) 
        {
            prep.Prep(fitmol);
            OEBestOverlayResultsIter resiter = overlay.Overlay(fitmol);
            OEBestOverlayScoreIter scoreiter = new OEBestOverlayScoreIter();
            OEShape.OESortOverlayScores(scoreiter, resiter, new OEHighestTanimoto(), 1, true);
            foreach (OEBestOverlayScore score in scoreiter) 
                csv.Write(",{0:0.00}", score.GetTanimoto());
        }
        
        bfs.close();
        csv.WriteLine();
    }

    private void GenHeader(String filename) 
    {
        csv.Write("name");
        oemolistream ifs = new oemolistream(filename);
        foreach (OEMol mol in ifs.GetOEMols())
        {
            Console.WriteLine(mol.GetTitle());
            foreach (OEConfBase conf in mol.GetConfs()) 
            {
                csv.Write(",{0}_{1}", conf.GetTitle(), conf.GetIdx());
            }
        }
        ifs.close();
        csv.WriteLine();
    }

    private void OpenCSV(String csvfilename) {
        try 
        {
            csv = File.CreateText(csvfilename);
        } 
        catch (Exception) 
        {
            Console.WriteLine("Unable to open output file {0}", csvfilename);
        }
    }

    public void NxN(String filename, String csvfilename) 
    {
        OpenCSV(csvfilename);
        GenHeader(filename);
        oemolistream afs = new oemolistream(filename);
        OEOverlapPrep prep = new OEOverlapPrep();
        prep.SetAssignColor(false);
        foreach (OEMol molA in afs.GetOEMols()) 
        {
            prep.Prep(molA);
            foreach (OEConfBase conf in molA.GetConfs()) 
            {
                OneConf(conf, prep, filename);
            }
        }
        csv.Close();
    }

    public static void Main(string [] args) 
    {
        if (args.Length != 2) 
        {
            OEChem.OEThrow.Usage("NxNShape <infile> <csvfile>");
        }
        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.
*/
using System;
using OpenEye.OEChem;
using OpenEye.OEGrid;
using OpenEye.OEShape;

public class ShapeProps 
{
    public static void Main(string [] args) 
    {
        if (args.Length != 1) 
        {
         OEChem.OEThrow.Usage("ShapeProps <infile>");
        }

        oemolistream ifs = new oemolistream(args[0]);
        foreach (OEGraphMol mol in ifs.GetOEGraphMols()) 
        {
            Console.WriteLine("              Title: "+mol.GetTitle());
            Console.WriteLine("             Volume: "+OEShape.OECalcVolume(mol));
            Console.WriteLine("Volume: (without H): "+
                             OEShape.OECalcVolume(mol, false));

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

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

            Console.WriteLine("");
        }
    }
}

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 penalized 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> 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.cs