Grapheme Examples

Depicting BFactor

/****************************************************************************
* Copyright (C) 2013-2015 OpenEye Scientific Software, Inc.
*****************************************************************************
* Depict the BFactor of a ligand and its environment
****************************************************************************/
using System;
using OpenEye.OEBio;
using OpenEye.OEChem;
using OpenEye.OEDepict;
using OpenEye.OEGrapheme;

public class BFactor2Img
{
    public static int Main(string[] args)
    {
        OEInterface itf = new OEInterface(interfaceData);

        OEDepict.OEConfigureImageWidth (itf, 600.0);
        OEDepict.OEConfigureImageHeight(itf, 600.0);
        OEDepict.OEConfigure2DMolDisplayOptions(itf, OE2DMolDisplaySetup.AromaticStyle);
        OEBio.OEConfigureSplitMolComplexOptions(itf, OESplitMolComplexSetup.LigName);

        if (!OEChem.OEParseCommandLine(itf, args, "BFactor2Img"))
        {
            OEChem.OEThrow.Fatal("Unable to interpret command line");
        }

        string iname = itf.GetString("-complex");
        string oname = itf.GetString("-out");

        oemolistream ifs = new oemolistream();
        if (!ifs.open(iname))
        {
            OEChem.OEThrow.Fatal("Cannot open input file!");
        }

        string ext = OEChem.OEGetFileExtension(oname);
        if (!OEDepict.OEIsRegisteredImageFile(ext))
        {
            OEChem.OEThrow.Fatal("Unknown image type!");
        }

        oeofstream ofs = new oeofstream();
        if (!ofs.open(oname))
        {
            OEChem.OEThrow.Fatal("Cannot open output file!");
        }

        OEGraphMol complexmol = new OEGraphMol();
        if (!OEChem.OEReadMolecule(ifs, complexmol))
        {
            OEChem.OEThrow.Fatal("Unable to read molecule from " + iname);
        }

        if (!OEChem.OEHasResidues(complexmol))
        {
            OEChem.OEPerceiveResidues(complexmol, OEPreserveResInfo.All);
        }

        // Separate ligand and protein

        OESplitMolComplexOptions sopts = new OESplitMolComplexOptions();
        OEBio.OESetupSplitMolComplexOptions(sopts, itf);

        OEGraphMol ligand = new OEGraphMol();
        OEGraphMol protein = new OEGraphMol();
        OEGraphMol water = new OEGraphMol();
        OEGraphMol other = new OEGraphMol();

        OEBio.OESplitMolComplex(ligand, protein, water, other, complexmol, sopts);

        if (ligand.NumAtoms() == 0)
        {
            OEChem.OEThrow.Fatal("Cannot separate complex!");
        }

        double maxdistance = 4.0;

        // Calculate average BFactor of the whole complex
        double avgbfactor = GetAverageBFactor(complexmol);

        //# Calculate minimum and maximum BFactor of the ligand and its environment
        SetMinAndMaxBFactor(ligand, protein, maxdistance);

        OEChem.OEThrow.Info(string.Format("Average BFactor of the complex = {0:0.00}", avgbfactor));
        OEChem.OEThrow.Info(string.Format("Minimum BFactor of the ligand and its environment = {0:0.00}", minbfactor));
        OEChem.OEThrow.Info(string.Format("Maximum BFactor of the ligand and its environment = {0:0.00}", maxbfactor));

        string stag = "avg residue bfactor";
        uint itag = OEChem.OEGetTag(stag);
        SetAverageBFactorOfNearbyProteinAtoms(ligand, protein, itag, maxdistance);

        // Create image
        double imagewidth  = OEDepict.OEGetImageWidth(itf);
        double imageheight = OEDepict.OEGetImageHeight(itf);
        OEImage image = new OEImage(imagewidth, imageheight);

        OEImageFrame mframe = new OEImageFrame(image, imagewidth, imageheight * 0.90, new OE2DPoint(0.0, 0.0));
        OEImageFrame lframe = new OEImageFrame(image, imagewidth, imageheight * 0.10, new OE2DPoint(0.0, imageheight * 0.90));

        OE2DMolDisplayOptions opts = new OE2DMolDisplayOptions(mframe.GetWidth(), mframe.GetHeight(), OEScale.AutoScale);
        OEDepict.OESetup2DMolDisplayOptions(opts, itf);
        opts.SetAtomColorStyle(OEAtomColorStyle.WhiteMonochrome);

        // Create BFactor color gradi    # Create BFactor color gradient
        OELinearColorGradient colorg = new OELinearColorGradient();
        colorg.AddStop(new OEColorStop(  0.0, OEChem.OEDarkBlue));
        colorg.AddStop(new OEColorStop( 10.0, OEChem.OELightBlue));
        colorg.AddStop(new OEColorStop( 25.0, OEChem.OEYellowTint));
        colorg.AddStop(new OEColorStop( 50.0, OEChem.OERed));
        colorg.AddStop(new OEColorStop(100.0, OEChem.OEDarkRose));

        // Prepare ligand for depiction
        OEGrapheme.OEPrepareDepictionFrom3D(ligand);
        BFactorArcFxn arcfxn = new BFactorArcFxn(colorg, itag);
        foreach (OEAtomBase ai in ligand.GetAtoms())
            OEGrapheme.OESetSurfaceArcFxn(ligand, ai, arcfxn);
        opts.SetScale(OEGrapheme.OEGetMoleculeSurfaceScale(ligand, opts));

        // Render ligand and visualize Bfactor
        OE2DMolDisplay disp = new OE2DMolDisplay(ligand, opts);
        ColorLigandAtomByBFactor colorbfactor = new ColorLigandAtomByBFactor(colorg);
        OEGrapheme.OEAddGlyph(disp, colorbfactor, new OEIsTrueAtom());
        OEGrapheme.OEDraw2DSurface(disp);
        OEDepict.OERenderMolecule(mframe, disp);

        // Draw color gradient
        OEColorGradientDisplayOptions copts = new OEColorGradientDisplayOptions();
        copts.SetColorStopPrecision(1);
        copts.AddMarkedValue(avgbfactor);
        copts.SetBoxRange(minbfactor, maxbfactor);

        OEGrapheme.OEDrawColorGradient(lframe, colorg, copts);

        OEDepict.OEWriteImage(oname, image);

        return 0;
    }

    static double GetAverageBFactor(OEMolBase mol)
    {

        double sumbfactor = 0.0;
        foreach (OEAtomBase atom in mol.GetAtoms())
        {
            OEResidue res = OEChem.OEAtomGetResidue(atom);
            sumbfactor += res.GetBFactor();
        }
        double avgbfactor = sumbfactor / mol.NumAtoms();
        return avgbfactor;
    }

    static bool ConsiderResidueAtom(OEAtomBase atom, OEResidue res)
    {
        if (atom.GetAtomicNum() == OEElemNo.H)
        {
            return false;
        }
        if (res.GetName().Equals("HOH"))
        {
            return false;
        }
        return true;
    }

    static double minbfactor = double.MaxValue;
    static double maxbfactor = Double.MinValue;

    static void SetMinAndMaxBFactor(OEMolBase ligand, OEMolBase protein, double maxdistance)
    {
        // Ligand atoms
        foreach (OEAtomBase latom in ligand.GetAtoms(new OEIsHeavy()))
        {
            OEResidue res = OEChem.OEAtomGetResidue(latom);
            double bfactor = res.GetBFactor();
            minbfactor = Math.Min(minbfactor, bfactor);
            maxbfactor = Math.Max(maxbfactor, bfactor);
        }

        // Protein atoms close to ligand atoms
        OENearestNbrs nn = new OENearestNbrs(protein, maxdistance);
        foreach (OEAtomBase latom in ligand.GetAtoms(new OEIsHeavy()))
        {
            foreach (OENbrs neigh in nn.GetNbrs(latom))
            {
                OEAtomBase ratom = neigh.GetBgn();
                OEResidue res = OEChem.OEAtomGetResidue(ratom);
                if (ConsiderResidueAtom(ratom, res))

                {
                    double bfactor = res.GetBFactor();
                    minbfactor = Math.Min(minbfactor, bfactor);
                    maxbfactor = Math.Max(maxbfactor, bfactor);
                }
            }
        }
    }

    static void SetAverageBFactorOfNearbyProteinAtoms(OEMolBase ligand, OEMolBase protein,
            uint itag, double maxdistance)
    {

        OENearestNbrs nn = new OENearestNbrs(protein, maxdistance);
        foreach (OEAtomBase latom in ligand.GetAtoms(new OEIsHeavy()))
        {
            double sumbfactor = 0.0;
            OEAtomBaseVector neighs = new OEAtomBaseVector();
            foreach (OENbrs neigh in nn.GetNbrs(latom))
            {
                OEAtomBase ratom = neigh.GetBgn();
                OEResidue res = OEChem.OEAtomGetResidue(ratom);
                if (ConsiderResidueAtom(ratom, res))

                {
                    double bfactor = res.GetBFactor();
                    sumbfactor += bfactor;
                    neighs.Add(ratom);
                }
            }
            double avgbfactor = 0.0;
            if (neighs.Count != 0)
            {
                avgbfactor = sumbfactor / neighs.Count;
            }
            latom.SetDoubleData(itag, avgbfactor);
        }
    }

    private class ColorLigandAtomByBFactor : OEAtomGlyphBase
    {
        private OELinearColorGradient colorg;

        private ColorLigandAtomByBFactor()
        {}
        public ColorLigandAtomByBFactor(OELinearColorGradient cg)
        {
            colorg = new OELinearColorGradient(cg);
        }

        public override bool RenderGlyph(OE2DMolDisplay disp, OEAtomBase atom)
        {

            OE2DAtomDisplay adisp = disp.GetAtomDisplay(atom);
            if (adisp == null || !adisp.IsVisible())
            {
                return false;
            }

            OEResidue res = OEChem.OEAtomGetResidue(atom);
            double bfactor = res.GetBFactor();
            OEColor color = new OEColor(colorg.GetColorAt(bfactor));
            OEPen pen = new OEPen(color, color, OEFill.On, 1.0);
            double radius = disp.GetScale()/3.0;

            OEImage layer = disp.GetLayer(OELayerPosition.Below);
            OEGrapheme.OEDrawCircle(layer, OECircleStyle.Default, adisp.GetCoords(), radius, pen);

            return true;
        }

        public override OEAtomGlyphBase CreateCopy()
        {
            ColorLigandAtomByBFactor copy = new ColorLigandAtomByBFactor(colorg);
            copy.ReleaseOwnership();
            return copy;
        }
    }

    private class BFactorArcFxn : OESurfaceArcFxnBase
    {
        private OELinearColorGradient colorg;
        private uint itag;

        private BFactorArcFxn()
        {}

        public BFactorArcFxn(OELinearColorGradient cg, uint i)
        {
            colorg = new OELinearColorGradient(cg);
            itag = i;
        }

        public override bool Call(OEImageBase image, OESurfaceArc arc)
        {
            OE2DAtomDisplay adisp = arc.GetAtomDisplay();
            if (adisp == null || !adisp.IsVisible())
            {
                return false;
            }

            OEAtomBase atom = adisp.GetAtom();
            if (atom == null)
            {
                return false;
            }

            double avgresiduebfactor = atom.GetDoubleData(itag);
            if (avgresiduebfactor == 0.0)
            {
                return true;
            }

            OEColor color = new OEColor(colorg.GetColorAt(avgresiduebfactor));
            OEPen pen = new OEPen(color, color, OEFill.Off, 5.0);
            OE2DPoint center = arc.GetCenter();
            double bAngle = arc.GetBgnAngle();
            double eAngle = arc.GetEndAngle();
            double radius = arc.GetRadius();
            OEGrapheme.OEDrawDefaultSurfaceArc(image, center, bAngle, eAngle, radius, pen);

            return true;
        }

        public override OESurfaceArcFxnBase CreateCopy()
        {
            BFactorArcFxn copy = new BFactorArcFxn(colorg, itag);
            copy.ReleaseOwnership();
            return copy;
        }
    }

    private static string interfaceData = @"
!BRIEF [-complex] <input> [-out] <output image>

!CATEGORY ""input/output options :""

  !PARAMETER -complex
    !ALIAS -c
    !TYPE string
    !KEYLESS 1
    !REQUIRED true
    !VISIBILITY simple
    !BRIEF Input filename of the protein complex
  !END

  !PARAMETER -out
    !ALIAS -o
    !TYPE string
    !REQUIRED true
    !KEYLESS 2
    !VISIBILITY simple
    !BRIEF Output filename
  !END

!END
";

}

See also

Depicting Active Site Interactions

/****************************************************************************
 * Copyright 2014-2016 OpenEye Scientific Software, Inc.
 *****************************************************************************
 * Depicts the interactions of an active site
 ****************************************************************************/
using System;
using OpenEye.OEBio;
using OpenEye.OEChem;
using OpenEye.OEDocking;
using OpenEye.OEDepict;
using OpenEye.OEGrapheme;

public class Complex2Img
{
    public static int Main(string[] args)
    {
        OEInterface itf = new OEInterface(interfaceData);

        if (!OEChem.OEParseCommandLine(itf, args, "Complex2Img"))
        {
            OEChem.OEThrow.Fatal("Unable to interpret command line!");
        }

        OEDepict.OEConfigureImageWidth (itf, 900.0);
        OEDepict.OEConfigureImageHeight(itf, 600.0);
        OEDepict.OEConfigure2DMolDisplayOptions(itf, OE2DMolDisplaySetup.AromaticStyle);
        OEBio.OEConfigureSplitMolComplexOptions(itf, OESplitMolComplexSetup.LigName);

        string iname = itf.GetString("-complex");
        string oname = itf.GetString("-out");

        oemolistream ifs = new oemolistream();
        if (!ifs.open(iname))
        {
            OEChem.OEThrow.Fatal("Cannot open input file!");
        }

        string ext = OEChem.OEGetFileExtension(oname);
        if (!OEDepict.OEIsRegisteredImageFile(ext))
        {
            OEChem.OEThrow.Fatal("Unknown image type!");
        }

        oeofstream ofs = new oeofstream();
        if (!ofs.open(oname))
        {
            OEChem.OEThrow.Fatal("Cannot open output file!");
        }
        ofs.close();

        OEGraphMol complexmol = new OEGraphMol();
        if (!OEChem.OEReadMolecule(ifs, complexmol))
        {
            OEChem.OEThrow.Fatal("Unable to read molecule from " + iname);
        }
        ifs.close();

        if (!OEChem.OEHasResidues(complexmol))
        {
            OEChem.OEPerceiveResidues(complexmol, OEPreserveResInfo.All);
        }

        // Separate ligand and protein

        OESplitMolComplexOptions sopts = new OESplitMolComplexOptions();
        OEBio.OESetupSplitMolComplexOptions(sopts, itf);

        OEGraphMol ligand = new OEGraphMol();
        OEGraphMol protein = new OEGraphMol();
        OEGraphMol water = new OEGraphMol();
        OEGraphMol other = new OEGraphMol();

        OEUnaryRoleSetPred pfilter = sopts.GetProteinFilter();
        OEUnaryRoleSetPred wfilter = sopts.GetWaterFilter();
        sopts.SetProteinFilter(new OEOrRoleSet(pfilter, wfilter));
        sopts.SetWaterFilter(OEBio.OEMolComplexFilterFactory(OEMolComplexFilterCategory.Nothing));

        OEBio.OESplitMolComplex(ligand, protein, water, other, complexmol, sopts);

        if (ligand.NumAtoms() == 0)
        {
            OEChem.OEThrow.Fatal("Cannot separate complex!");
        }

        // Perceive interactions
        OEInteractionHintContainer asite = new OEInteractionHintContainer(protein, ligand);
        if (!asite.IsValid())
        {
            OEChem.OEThrow.Fatal("Cannot initialize active site!");
        }
        asite.SetTitle(ligand.GetTitle());

        OEBio.OEPerceiveInteractionHints(asite);
        OEGrapheme.OEPrepareActiveSiteDepiction(asite);

        // Depict active site with interactions
        double imagewidth = OEDepict.OEGetImageWidth(itf);
        double imageheight = OEDepict.OEGetImageHeight(itf);
        OEImage image = new OEImage(imagewidth, imageheight);

        OEImageFrame cframe = new OEImageFrame(image, imagewidth * 0.80, imageheight,
                                               new OE2DPoint(0.0, 0.0));
        OEImageFrame lframe = new OEImageFrame(image, imagewidth * 0.20, imageheight,
                                               new OE2DPoint(imagewidth * 0.80, 0.0));

        OE2DActiveSiteDisplayOptions opts = new OE2DActiveSiteDisplayOptions(
            cframe.GetWidth(), cframe.GetHeight());
        OEDepict.OESetup2DMolDisplayOptions(opts, itf);

        OE2DActiveSiteDisplay adisp = new OE2DActiveSiteDisplay(asite, opts);
        OEGrapheme.OERenderActiveSite(cframe, adisp);

        OE2DActiveSiteLegendDisplayOptions lopts = new OE2DActiveSiteLegendDisplayOptions(10, 1);
        OEGrapheme.OEDrawActiveSiteLegend(lframe, adisp, lopts);

        OEDepict.OEWriteImage(oname, image);

        return 0;
    }

    static void SeparateLigandAndReceptor(OEMolBase receptor, OEMolBase ligand,
                                          OEMolBase complexmol, String residuename)
    {

        OEChem.OEPerceiveResidues(complexmol, OEPreserveResInfo.All);
        OEHierView hview = new OEHierView(complexmol);

        foreach (OEHierResidue res in hview.GetResidues())
        {
            if (res.GetOEResidue().GetName().Equals(residuename))
            {
                char chainid = res.GetOEResidue().GetChainID();
                int resnum = res.GetOEResidue().GetResidueNumber();
                OEChem.OEThrow.Info("Locating residue " + chainid + residuename
                                    + resnum.ToString());
                OEHierResidue ligandres = hview.GetResidue(chainid,
                                          residuename, resnum);
                if (ligandres.GetOEResidue().GetName().Length == 0)
                {
                    OEChem.OEThrow.Fatal("Failed to find residue!");
                }

                OEIsAtomMember ligandatoms = new OEIsAtomMember(
                    ligandres.GetAtoms());
                OEChem.OESubsetMol(ligand, complexmol, ligandatoms, true);
                OEChem.OESubsetMol(receptor, complexmol, new OENotAtom(
                                       ligandatoms), true);
                break;
            }
        }
    }

    private static string interfaceData = @"
!BRIEF [-complex] <input> [-out] <output image>

!CATEGORY ""input/output options :""

  !PARAMETER -complex
    !ALIAS -c
    !TYPE string
    !KEYLESS 1
    !REQUIRED true
    !VISIBILITY simple
    !BRIEF Input filename of the protein complex
  !END

  !PARAMETER -out
    !ALIAS -o
    !TYPE string
    !REQUIRED true
    !KEYLESS 2
    !VISIBILITY simple
    !BRIEF Output filename
  !END

!END
";
}

Depicting Shape and Color Atom Overlaps

Note

OEShape TK license is not required to run this example.

/****************************************************************************
 * Copyright 2013-2015 OpenEye Scientific Software, Inc.
 *****************************************************************************
 * Depicts shape and color overlap between a 3D reference structure and
 * a sets of 3D fit molecules. The molecules have to be pre-aligned.
* The first molecule is expected be the reference.
 ****************************************************************************/
using System;
using OpenEye.OEChem;
using OpenEye.OEDepict;
using OpenEye.OEGrapheme;
using OpenEye.OEShape;

public class ShapeOverlap2PDF
{
    public static int Main(string[] args)
    {
        OEInterface itf = new OEInterface(interfaceData);

        if (!OEChem.OEParseCommandLine(itf, args, "ShapeOverlap2PDF"))
        {
            OEChem.OEThrow.Fatal("Unable to interpret command line");
        }

        string iname = itf.GetString("-in");
        string oname = itf.GetString("-out");
        int maxhits  = itf.GetInt("-maxhits");

        string ext = OEChem.OEGetFileExtension(oname);
        if (!OEDepict.OEIsRegisteredMultiPageImageFile(ext))
        {
            OEChem.OEThrow.Fatal("Unknown multipage image type!");
        }

        oemolistream ifs = new  oemolistream();
        if (!ifs.open(iname))
        {
            OEChem.OEThrow.Fatal("Cannot open fit molecule file!");
        }

        OEGraphMol refmol = new OEGraphMol();
        if (!OEChem.OEReadMolecule(ifs, refmol))
        {
            OEChem.OEThrow.Fatal("Cannot read reference molecule!");
        }

        OEReportOptions ropts = new OEReportOptions(3, 1);
        ropts.SetHeaderHeight(40.0);
        ropts.SetFooterHeight(20.0);
        OEReport report = new OEReport(ropts);

        OEColorForceField cff = new OEColorForceField();
        cff.Init(OEColorFFType.ImplicitMillsDean);
        OEColorForceFieldDisplay cffdisplay = new OEColorForceFieldDisplay(cff);


        OEShapeQueryDisplayOptions   qopts = getShapeQueryDisplayOptions();
        OEShapeOverlapDisplayOptions sopts = getShapeOverlapDisplayOptions();
        OEColorOverlapDisplayOptions copts = getColorOverlapDisplayOptions();

        OEShapeQueryDisplay refdisp = new OEShapeQueryDisplay(refmol, cff, qopts);

        OEDots dots = new OEDots(100, 10, "shape overlaps");

        OEGraphMol fitmol = new OEGraphMol();
        while (OEChem.OEReadMolecule(ifs, fitmol))
        {
            dots.Update();
            if (maxhits > 0 && dots.GetCounts() >= maxhits)
            {
                break;
            }
            OEImageBase maincell = report.NewCell();
            OEImageGrid grid = new OEImageGrid(maincell, 1, 3);
            grid.SetMargins(5.0);
            grid.SetCellGap(5.0);

            // SD DATA + SCORE GRAPH + QUERY
            OEImageBase cell = grid.GetCell(1, 1);
            double cellw = cell.GetWidth();
            double cellh = cell.GetHeight();

            OEFont tfont = new OEFont(OEFontFamily.Default, OEFontStyle.Bold, 10,
                                      OEAlignment.Left, OEChem.OEBlack);
            OE2DPoint tpos = new OE2DPoint(10.0, 10.0);
            cell.DrawText(tpos, fitmol.GetTitle(), tfont, cell.GetWidth());

            OEImageFrame rframe = new OEImageFrame(cell, cellw, cellh * 0.35, new OE2DPoint(0.0, cellh * 0.10));
            OEImageFrame mframe = new OEImageFrame(cell, cellw, cellh * 0.50, new OE2DPoint(0.0, cellh * 0.50));

            renderScoreRadial(rframe, fitmol);
            OEGrapheme.OERenderShapeQuery(mframe, refdisp);

            OEFont font = new OEFont(OEFontFamily.Default, OEFontStyle.Bold, 8,
                                     OEAlignment.Center, OEChem.OEGrey);
            OE2DPoint pos = new OE2DPoint(20.0, 10.0);
            mframe.DrawText(pos, "query", font);
            OEDepict.OEDrawCurvedBorder(mframe, OEDepict.OELightGreyPen, 10.0);

            OEShapeOverlapDisplay odisp = new OEShapeOverlapDisplay(refdisp, fitmol, sopts, copts);

            // SHAPE OVERLAP
            cell = grid.GetCell(1, 2);
            OEGrapheme.OERenderShapeOverlap(cell, odisp);
            renderScore(cell, fitmol, "ROCS_ShapeTanimoto", "Shape Tanimoto");

            // COLOR OVERLAP
            cell = grid.GetCell(1, 3);
            OEGrapheme.OERenderColorOverlap(cell, odisp);
            renderScore(cell, fitmol, "ROCS_ColorTanimoto", "Color Tanimoto");

            OEDepict.OEDrawCurvedBorder(maincell, OEDepict.OELightGreyPen, 10.0);
        }
        dots.Total();

        OEColorForceFieldLegendDisplayOptions cffopts = new OEColorForceFieldLegendDisplayOptions(1, 6);
        foreach (OEImageBase header in report.GetHeaders())
        {
            OEGrapheme.OEDrawColorForceFieldLegend(header, cffdisplay, cffopts);
            OEDepict.OEDrawCurvedBorder(header, OEDepict.OELightGreyPen, 10.0);
        }

        OEFont pfont = new OEFont(OEFontFamily.Default, OEFontStyle.Default, 12,
                                  OEAlignment.Center, OEChem.OEBlack);
        int idx = 0;
        foreach (OEImageBase footer in report.GetFooters())
        {
            idx = idx + 1;
            string text = "-" + idx.ToString() + "-";
            OEDepict.OEDrawTextToCenter(footer, text, pfont);
        }

        OEDepict.OEWriteReport(oname, report);

        return 0;
    }

    static OEShapeQueryDisplayOptions getShapeQueryDisplayOptions()
    {
        OEShapeQueryDisplayOptions qopts = new OEShapeQueryDisplayOptions();
        qopts.SetTitleLocation(OETitleLocation.Hidden);
        qopts.SetAtomLabelFontScale(1.5);
        OEPen pen = new OEPen(OEChem.OEBlack, OEChem.OEBlack, OEFill.Off, 1.5);
        qopts.SetDefaultBondPen(pen);
        qopts.SetSurfaceArcFxn(new OEDefaultArcFxn(OEDepict.OELightGreyPen));
        return qopts;
    }

    static OEShapeOverlapDisplayOptions getShapeOverlapDisplayOptions()
    {
        OEShapeOverlapDisplayOptions sopts = new OEShapeOverlapDisplayOptions();
        sopts.SetTitleLocation(OETitleLocation.Hidden);
        sopts.SetAtomLabelFontScale(1.5);
        OEPen pen = new OEPen(OEChem.OEBlack, OEChem.OEBlack, OEFill.Off, 1.5);
        sopts.SetDefaultBondPen(pen);
        OEPen arcpen = new OEPen(OEChem.OEGrey, OEChem.OEGrey, OEFill.Off, 1.0, 0x1111);
        sopts.SetQuerySurfaceArcFxn(new OEDefaultArcFxn(arcpen));
        sopts.SetOverlapColor(new OEColor(110, 110, 190));
        return sopts;
    }

    static OEColorOverlapDisplayOptions getColorOverlapDisplayOptions()
    {
        OEColorOverlapDisplayOptions copts = new OEColorOverlapDisplayOptions();
        copts.SetTitleLocation(OETitleLocation.Hidden);
        copts.SetAtomLabelFontScale(1.5);
        OEPen pen = new OEPen(OEChem.OEBlack, OEChem.OEBlack, OEFill.Off, 1.5);
        copts.SetDefaultBondPen(pen);
        OEPen arcpen = new OEPen(OEChem.OEGrey, OEChem.OEGrey, OEFill.Off, 1.0, 0x1111);
        copts.SetQuerySurfaceArcFxn(new OEDefaultArcFxn(arcpen));
        return copts;
    }

    static double getScore(OEMolBase mol, string sdtag)
    {
        if (OEChem.OEHasSDData(mol, sdtag))
        {
            string scorestr = OEChem.OEGetSDData(mol, sdtag);
            double score = System.Convert.ToDouble(scorestr);
            return score;
        }
        return 0.0;
    }

    static void renderScoreRadial(OEImageBase image, OEMolBase mol)
    {
        double sscore = Math.Max(Math.Min(getScore(mol, "ROCS_ShapeTanimoto"), 1.0), 0.00);
        double cscore = Math.Max(Math.Min(getScore(mol, "ROCS_ColorTanimoto"), 1.0), 0.00);

        if (sscore > 0.0 || cscore > 0.0)
        {
            OEDoubleVector scores = new OEDoubleVector();
            scores.Add(sscore);
            scores.Add(cscore);
            OEGrapheme.OEDrawROCSScores(image, scores);
        }
    }
    static void renderScore(OEImageBase image, OEMolBase mol,
                            string sdtag, string label)
    {
        double score = getScore(mol, sdtag);
        if (score == 0.0)
        {
            return;
        }

        double w = image.GetWidth();
        double h = image.GetHeight();
        OEImageFrame frame = new OEImageFrame(image, w, h * 0.10, new OE2DPoint(0.0, h * 0.90));
        OEFont font = new OEFont(OEFontFamily.Default, OEFontStyle.Default, 9,
                                 OEAlignment.Center, OEChem.OEBlack);

        string text = label +  " = " + System.Convert.ToString(score);
        OEDepict.OEDrawTextToCenter(frame, text, font);
    }


    private static string interfaceData = @"
# ShapeOverlap2PDF interface file
!BRIEF [-in] <input> [-out] <output pdf>

!CATEGORY ""input/output options:"" 0

  !PARAMETER -in
    !ALIAS -i
    !TYPE string
    !REQUIRED true
    !KEYLESS 1
    !VISIBILITY simple
    !BRIEF Input molecule filename
    !DETAIL
         The first molecule in the file is expected to be the reference
         molecule
  !END

  !PARAMETER -out
    !ALIAS -o
    !TYPE string
    !REQUIRED true
    !KEYLESS 2
    !VISIBILITY simple
    !BRIEF Output image filename
  !END

!END

!CATEGORY ""general options:"" 1

  !PARAMETER -maxhits
    !ALIAS -mhits
    !TYPE int
    !REQUIRED false
    !DEFAULT 0
    !LEGAL_RANGE 0 500
    !VISIBILITY simple
    !BRIEF Maximum number of hits depicted
    !DETAIL
            The default of 0 means there is no limit.
  !END

!END
";
}