OEBio Examples

Extracting the backbone of a protein

/*******************************************************************************
 * Copyright 2004-2015 OpenEye Scientific Software, Inc.
 ******************************************************************************/
package openeye.examples.oebio;

import openeye.oechem.*;
import openeye.oebio.*;

public class Backbone {

    private void displayUsage() {
        System.err.println("usage: Backbone <inmol> <outmol>");
        System.exit(1);
    }

    public void makeBackbone(String infile, String outfile) {
        oemolistream ifs = new oemolistream();
        if (!ifs.open(infile)) {
            System.err.println("Unable to open infile: " + infile);
            return;
        }
        oemolostream ofs = new oemolostream();
        if (!ofs.open(outfile)) {
            System.err.println("Unable to open outfile: " + outfile);
            return;
        }

        OEGraphMol mol = new OEGraphMol();
        boolean adjustHCount = true;

        while (oechem.OEReadMolecule(ifs, mol)) {
            if (! oechem.OEHasResidues(mol))
                oechem.OEPerceiveResidues(mol, OEPreserveResInfo.All);
            OEAtomBaseIter atomiter = mol.GetAtoms(new OEIsBackboneAtom());
            OEIsAtomMember member = new OEIsAtomMember(atomiter);

            OEGraphMol backboneMol = new OEGraphMol();
            oechem.OESubsetMol(backboneMol, mol, member, adjustHCount);
            oechem.OEWriteMolecule(ofs, backboneMol);
        }
        ifs.close();
        ofs.close();
    }

    public static void main(String argv[]) {
        Backbone app = new Backbone();
        if (argv.length != 2) {
            app.displayUsage();
        }
        app.makeBackbone(argv[0], argv[1]);
    }
}

See also

Splitting a Macro-molecular Complex

//**********************************************************************
//  Copyright (C) 2015 by OpenEye Scientific Software, Inc.
//***********************************************************************
// split a mol complex (a PDB structure, for example) into basic categories

package openeye.examples.oebio;

import java.io.IOException;
import java.net.URL;

import openeye.oebio.*;
import openeye.oechem.*;

public class SplitMolComplex {

    public static void main(String[] argv) {
        URL fileURL = SplitMolComplex.class.getResource("SplitMolComplex.txt");
        OEInterface itf = null;
        try {
            itf = new OEInterface();
            oechem.OEConfigureFromURL(itf, fileURL);
        } catch (IOException e) {
            oechem.OEThrow.Fatal("Unable to open interface file");
        }

        oebio.OEConfigureSplitMolComplexOptions(itf);

        if (!oechem.OEParseCommandLine(itf, argv, "SplitMolComplex"))
            oechem.OEThrow.Fatal("Unable to interpret command line!");

        String iname = itf.GetString("-in");
        String oname = itf.GetString("-out");

        oemolistream ims = new oemolistream();
        if (itf.GetUnsignedInt("-modelnum") != 1)
            ims.SetFlavor(OEFormat.PDB,
                          oechem.OEGetDefaultIFlavor(OEFormat.PDB)
                                            & ~OEIFlavor.PDB.ENDM);
        if (!ims.open(iname))
            oechem.OEThrow.Fatal("Cannot open input file!");

        oemolostream oms = new oemolostream();
        if (!oms.open(oname))
            oechem.OEThrow.Fatal("Cannot open output file!");

        OEGraphMol inmol = new OEGraphMol();
        if (!oechem.OEReadMolecule(ims, inmol))
            oechem.OEThrow.Fatal("Unable to read molecule from " + iname);
        ims.close();

        OESplitMolComplexOptions opts = new OESplitMolComplexOptions();
        oebio.OESetupSplitMolComplexOptions(opts, itf);

        if (itf.GetBool("-verbose")) {
            // don't bother counting sites unless we're going to print them
            int numSites = oebio.OECountMolComplexSites(inmol, opts);
            oechem.OEThrow.SetLevel(OEErrorLevel.Verbose);
            oechem.OEThrow.Verbose("sites " + numSites);
        }

        OEGraphMol lig   = new OEGraphMol();
        OEGraphMol prot  = new OEGraphMol();
        OEGraphMol wat   = new OEGraphMol();
        OEGraphMol other = new OEGraphMol();

        if (! oebio.OESplitMolComplex(lig, prot, wat, other, inmol, opts))
            oechem.OEThrow.Fatal("Unable to split mol complex from " + iname);

        if (! (lig.NumAtoms() == 0)) {
          oechem.OEThrow.Verbose("  lig " + lig.GetTitle());
          oechem.OEWriteMolecule(oms, lig);
        }

        if (! (prot.NumAtoms() == 0)) {
          oechem.OEThrow.Verbose(" prot " + prot.GetTitle());
          oechem.OEWriteMolecule(oms, prot);
        }

        if (! (wat.NumAtoms() == 0)) {
          oechem.OEThrow.Verbose("  wat " + wat.GetTitle());
          oechem.OEWriteMolecule(oms, wat);
        }

        if (! (other.NumAtoms() == 0)) {
          oechem.OEThrow.Verbose("other " + other.GetTitle());
          oechem.OEWriteMolecule(oms, other);
        }

        oms.close();
    }
}

Splitting a Macro-molecular Complex Efficiently and Flexibly

//**********************************************************************
//  Copyright (C) 2016 by OpenEye Scientific Software, Inc.
//***********************************************************************
// split a mol complex (a PDB structure, for example) using low-level api

package openeye.examples.oebio;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.net.URL;

import openeye.oebio.*;
import openeye.oechem.*;

public class SplitMolComplexLowLevel {

    public static void main(String[] argv) {
        URL fileURL = SplitMolComplexLowLevel.class.getResource("SplitMolComplexLowLevel.txt");
        OEInterface itf = null;
        try {
            itf = new OEInterface();
            oechem.OEConfigureFromURL(itf, fileURL);
        } catch (IOException e) {
            oechem.OEThrow.Fatal("Unable to open interface file");
        }

        oebio.OEConfigureSplitMolComplexOptions(itf);

        if (!oechem.OEParseCommandLine(itf, argv, "SplitMolComplexLowLevel"))
            oechem.OEThrow.Fatal("Unable to interpret command line!");

        String iname = itf.GetString("-in");
        String oname = itf.GetString("-out");

        oemolistream ims = new oemolistream();
        if (itf.GetUnsignedInt("-modelnum") != 1)
            ims.SetFlavor(OEFormat.PDB,
                          oechem.OEGetDefaultIFlavor(OEFormat.PDB)
                                            & ~OEIFlavor.PDB.ENDM);
        if (!ims.open(iname))
            oechem.OEThrow.Fatal("Cannot open input file!");

        oemolostream oms = new oemolostream();
        if (!oms.open(oname))
            oechem.OEThrow.Fatal("Cannot open output file!");

        OEGraphMol inmol = new OEGraphMol();
        if (!oechem.OEReadMolecule(ims, inmol))
            oechem.OEThrow.Fatal("Unable to read molecule from " + iname);
        ims.close();

        OESplitMolComplexOptions opts = new OESplitMolComplexOptions();
        oebio.OESetupSplitMolComplexOptions(opts, itf);

        OEAtomBondSetVector frags = new OEAtomBondSetVector();

        if (! oebio.OEGetMolComplexFragments(frags, inmol, opts))
            oechem.OEThrow.Fatal("Unable to split mol complex from " + iname);

        int numSites = oebio.OECountMolComplexSites(frags);

        if (itf.GetBool("-verbose")) {
            oechem.OEThrow.SetLevel(OEErrorLevel.Verbose);
            oechem.OEThrow.Verbose("sites " + numSites);
        }

        OEGraphMol lig   = new OEGraphMol();
        OEGraphMol prot  = new OEGraphMol();
        OEGraphMol wat   = new OEGraphMol();
        OEGraphMol other = new OEGraphMol();

        if (! oebio.OECombineMolComplexFragments(lig, frags, opts, opts.GetLigandFilter()))
            oechem.OEThrow.Fatal("Unable to split ligand from " + iname);

        if (! oebio.OECombineMolComplexFragments(lig, frags, opts, opts.GetProteinFilter()))
            oechem.OEThrow.Fatal("Unable to split protein complex from " + iname);

        if (! oebio.OECombineMolComplexFragments(lig, frags, opts, opts.GetWaterFilter()))
            oechem.OEThrow.Fatal("Unable to split waters from " + iname);

        if (! oebio.OECombineMolComplexFragments(lig, frags, opts, opts.GetOtherFilter()))
            oechem.OEThrow.Fatal("Unable to split other mols from " + iname);

        if (! (lig.NumAtoms() == 0)) {
          oechem.OEThrow.Verbose("  lig " + lig.GetTitle());
          oechem.OEWriteMolecule(oms, lig);
        }

        if (! (prot.NumAtoms() == 0)) {
          oechem.OEThrow.Verbose(" prot " + prot.GetTitle());
          oechem.OEWriteMolecule(oms, prot);
        }

        if (! (wat.NumAtoms() == 0)) {
          oechem.OEThrow.Verbose("  wat " + wat.GetTitle());
          oechem.OEWriteMolecule(oms, wat);
        }

        if (! (other.NumAtoms() == 0)) {
          oechem.OEThrow.Verbose("other " + other.GetTitle());
          oechem.OEWriteMolecule(oms, other);
        }

        oms.close();
    }
}

Splitting a Macro-molecular Complex Into Fragments

//**********************************************************************
//  Copyright (C) 2015 by OpenEye Scientific Software, Inc.
//***********************************************************************
// split a mol complex (a PDB structure, for example) into fragments

package openeye.examples.oebio;

import java.io.IOException;
import java.net.URL;

import openeye.oebio.*;
import openeye.oechem.*;

public class SplitMolComplexFrags {

    public static void main(String[] argv) {
        URL fileURL = SplitMolComplexFrags.class.getResource("SplitMolComplexFrags.txt");
        OEInterface itf = null;
        try {
            itf = new OEInterface();
            oechem.OEConfigureFromURL(itf, fileURL);
        } catch (IOException e) {
            oechem.OEThrow.Fatal("Unable to open interface file");
        }

        oebio.OEConfigureSplitMolComplexOptions(itf);

        if (!oechem.OEParseCommandLine(itf, argv, "SplitMolComplexFrags"))
            oechem.OEThrow.Fatal("Unable to interpret command line!");

        String iname = itf.GetString("-in");
        String oname = itf.GetString("-out");

        oemolistream ims = new oemolistream();
        if (itf.GetUnsignedInt("-modelnum") != 1)
            ims.SetFlavor(OEFormat.PDB,
                          oechem.OEGetDefaultIFlavor(OEFormat.PDB)
                                            & ~OEIFlavor.PDB.ENDM);
        if (!ims.open(iname))
            oechem.OEThrow.Fatal("Cannot open input file!");

        oemolostream oms = new oemolostream();
        if (!oms.open(oname))
            oechem.OEThrow.Fatal("Cannot open output file!");

        OEGraphMol inmol = new OEGraphMol();
        if (!oechem.OEReadMolecule(ims, inmol))
            oechem.OEThrow.Fatal("Unable to read molecule from " + iname);
        ims.close();

        OESplitMolComplexOptions opts = new OESplitMolComplexOptions();
        oebio.OESetupSplitMolComplexOptions(opts, itf);

        if (itf.GetBool("-verbose")) {
            // don't bother counting sites unless we're going to print them
            int numSites = oebio.OECountMolComplexSites(inmol, opts);
            oechem.OEThrow.SetLevel(OEErrorLevel.Verbose);
            oechem.OEThrow.Verbose("sites " + numSites);
        }

        for (OEMolBase frag : oebio.OEGetMolComplexComponents(inmol, opts)) {
          oechem.OEThrow.Verbose("frag " + frag.GetTitle());
          oechem.OEWriteMolecule(oms, frag);
        }

        oms.close();
    }
}

Preparing a Protein

//**********************************************************************
//  Copyright (C) 2016 by OpenEye Scientific Software, Inc.
//***********************************************************************
// prepare a molecule: alts, hydrogens, split ligand

package openeye.examples.oebio;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.net.URL;

import openeye.oebio.*;
import openeye.oechem.*;

public class ProteinPrep {

    static int WaterProcess(String processName) {
        if (processName.equals("fullsearch"))
            return OEPlaceHydrogensWaterProcessing.FullSearch;
        else if (processName.equals("focused"))
            return OEPlaceHydrogensWaterProcessing.Focused;
        return OEPlaceHydrogensWaterProcessing.Ignore;
    }

    public static void main(String[] argv) {
        URL fileURL = ProteinPrep.class.getResource("ProteinPrep.txt");
        OEInterface itf = null;
        try {
            itf = new OEInterface();
            oechem.OEConfigureFromURL(itf, fileURL);
        } catch (IOException e) {
            oechem.OEThrow.Fatal("Unable to open interface file");
        }

        oebio.OEConfigureSplitMolComplexOptions(itf,
                                       OESplitMolComplexSetup.All              &
                                   ~ ( OESplitMolComplexSetup.CovBondTreatment |
                                       OESplitMolComplexSetup.CovCofactor ) );

        if (! oechem.OEParseCommandLine(itf, argv, "ProteinPrep"))
            oechem.OEThrow.Fatal("Unable to interpret command line!");

        boolean verbose = itf.GetBool("-verbose");
        if (verbose)
            oechem.OEThrow.SetLevel(OEErrorLevel.Verbose);

        String  altProcess  = itf.GetString("-alts");
        boolean keepAlts    = ! altProcess.equals("a");
        boolean highestOcc  =  (altProcess.equals("occupancy"));
        boolean compareAlts =  (altProcess.equals("compare"));

        int siteNum        = itf.GetUnsignedInt("-bindingsitenum");
        boolean allSites   = (siteNum == 0);
        boolean otherModel = (itf.GetUnsignedInt("-modelnum") != 1);

        boolean placeHyd = itf.GetBool("-placehydrogens");
        boolean splitlig = itf.HasString("-ligout");

        String watProcessName = itf.GetString("-waterprocessing");
        int waterProcess = WaterProcess(watProcessName);

        boolean standardize = itf.GetBool("-standardizehyd");
        double badclash     = itf.GetDouble("-clashcutoff");
        double flipbias     = itf.GetDouble("-flipbias");
        double maxStates    = itf.GetDouble("-maxsubstates");

        int flavor = OEIFlavor.PDB.Default | OEIFlavor.PDB.DATA;
        if (keepAlts)
          flavor |= OEIFlavor.PDB.ALTLOC;
        if (otherModel)
          flavor &= ~ OEIFlavor.PDB.ENDM;

        oemolistream ims = new oemolistream();
        ims.SetFlavor(OEFormat.PDB, flavor);

        String inputFile = itf.GetString("-in");
        if (! ims.open(inputFile))
            oechem.OEThrow.Fatal("Unable to open " +
                                  inputFile + " for reading.");

        if (! oechem.OEIs3DFormat(ims.GetFormat()))
            oechem.OEThrow.Fatal(inputFile + " is not in a 3D format.");

        int inftype=oechem.OEGetFileType(oechem.OEGetFileExtension(inputFile));
        if ((inftype == OEFormat.PDB) && (! keepAlts))
            oechem.OEThrow.Verbose("Default processing of alt locations " +
                                    "(keep just 'A' and ' ').");

        OESplitMolComplexOptions sopt = new OESplitMolComplexOptions();
        oebio.OESetupSplitMolComplexOptions(sopt, itf);

        OEGraphMol inmol = new OEGraphMol();
        if (! oechem.OEReadMolecule(ims, inmol))
            oechem.OEThrow.Fatal("Unable to read " + inputFile + ".");

        ims.close();

        if (inmol.NumAtoms() == 0)
            oechem.OEThrow.Fatal("Input molecule " + inputFile + " contains no atoms.");

        if (inmol.GetTitle().equals(""))
            inmol.SetTitle("input mol");

        oechem.OEThrow.Verbose("Processing " + inmol.GetTitle() + ".");

        if (! oechem.OEHasResidues(inmol))
            oechem.OEPerceiveResidues(inmol, OEPreserveResInfo.All);

        if (highestOcc || compareAlts) {
            OEAltLocationFactory alf = new OEAltLocationFactory(inmol);
            if (alf.GetGroupCount() != 0) {
                if (highestOcc) {
                    oechem.OEThrow.Verbose("Dropping alternate locations " +
                                           "from input.");
                    alf.MakePrimaryAltMol(inmol);
                }
                else if (compareAlts) {
                    oechem.OEThrow.Verbose("Fixing alternate location issues.");
                    inmol = new OEGraphMol(alf.GetSourceMol());
                }
            }
        }

        OEGraphMol outmol = new OEGraphMol();
        if (allSites)
            outmol = inmol;
        else {
          oechem.OEThrow.Verbose("Splitting out selected complex.");

          OESplitMolComplexOptions soptSiteSel =
                                             new OESplitMolComplexOptions(sopt);
          soptSiteSel.SetSplitCovalent(false); // do any cov lig splitting later

          OEAtomBondSetVector frags = new OEAtomBondSetVector();
          if (! oebio.OEGetMolComplexFragments(frags, inmol, soptSiteSel))
              oechem.OEThrow.Fatal("Unable to fragment " +
                                    inmol.GetTitle() + ".");

          int howManySites = oebio.OECountMolComplexSites(frags);
          if (howManySites < siteNum) {
            oechem.OEThrow.Warning("Binding site count (" + howManySites +
                                   ") less than requested site (" + siteNum +
                                   ") in " + inmol.GetTitle() + ".");
            return;
          }

          if (! oebio.OECombineMolComplexFragments(outmol, frags, soptSiteSel))
              oechem.OEThrow.Fatal("Unable to collect fragments from " +
                                    inmol.GetTitle() + ".");

          if (outmol.NumAtoms() == 0)
              oechem.OEThrow.Fatal("No fragments selected from " +
                                    inmol.GetTitle() + ".");
        }

        if (placeHyd) {
            oechem.OEThrow.Verbose("Adding hydrogens to complex.");

            OEPlaceHydrogensOptions hopt = new OEPlaceHydrogensOptions();
            hopt.SetAltsMustBeCompatible(compareAlts);
            hopt.SetStandardizeBondLen(standardize);
            hopt.SetWaterProcessing(waterProcess);
            hopt.SetBadClashOverlapDistance(badclash);
            hopt.SetFlipBiasScale(flipbias);
            hopt.SetMaxSubstateCutoff(maxStates);

            if (verbose) {
                OEPlaceHydrogensDetails details = new OEPlaceHydrogensDetails();
                if (! oebio.OEPlaceHydrogens(outmol, details, hopt))
                    oechem.OEThrow.Fatal("Unable to place hydrogens and get details on " +
                                          inmol.GetTitle() + ".");
                oechem.OEThrow.Verbose(details.Describe());
            }
            else {
                if (! oebio.OEPlaceHydrogens(outmol, hopt))
                    oechem.OEThrow.Fatal("Unable to place hydrogens on " +
                                          inmol.GetTitle() + ".");
            }
        }

        oemolostream oms1 = new oemolostream();
        String cplxFile = itf.GetString("-cplxout");
        if (! oms1.open(cplxFile))
            oechem.OEThrow.Fatal("Unable to open " +
                                  cplxFile + " for writing.");

        if (splitlig) {
            oechem.OEThrow.Verbose("Splitting ligand from complex.");

            OEAtomBondSetVector frags = new OEAtomBondSetVector();
            if (! oebio.OEGetMolComplexFragments(frags, outmol, sopt))
                oechem.OEThrow.Fatal("Unable to fragment complex from " +
                                      inmol.GetTitle() + ".");

            OEUnaryRoleSetPred lfilter = sopt.GetLigandFilter();

            OEGraphMol protComplex = new OEGraphMol();

            if (! oebio.OECombineMolComplexFragments(protComplex,
                                                     frags,
                                                     sopt,
                                                     new OENotRoleSet(lfilter)))
                oechem.OEThrow.Fatal("Unable to collect complex from " +
                                      inmol.GetTitle() + ".");

            if (protComplex.NumAtoms() == 0)
                oechem.OEThrow.Warning("No complex identified in " +
                                        inmol.GetTitle() + ".");
            else
                oechem.OEWriteMolecule(oms1, protComplex);

            OEGraphMol lig = new OEGraphMol();

            if (! oebio.OECombineMolComplexFragments(lig, frags, sopt, lfilter))
                oechem.OEThrow.Fatal("Unable to collect ligand from " +
                                      inmol.GetTitle() + ".");

            if (lig.NumAtoms() == 0)
                oechem.OEThrow.Warning("No ligand identified in " +
                                        inmol.GetTitle() + ".");
            else {
                oemolostream oms2 = new oemolostream();
                if (splitlig) {
                    String ligFile = itf.GetString("-ligout");
                    if (! oms2.open(ligFile))
                        oechem.OEThrow.Fatal("Unable to open " +
                                              ligFile + " for writing.");
                }
                oechem.OEThrow.Verbose("Ligand: " + lig.GetTitle());
                oechem.OEWriteMolecule(oms2, lig);
                oms2.close();
            }
        }
        else
            oechem.OEWriteMolecule(oms1, outmol);

        oms1.close();
    }
}

Perceive and Print Protein-Ligand Interactions

/****************************************************************************
 * Copyright 2015-2016 OpenEye Scientific Software, Inc.
 *****************************************************************************
 * Print protein-ligand interactions
 ****************************************************************************/

package openeye.examples.oebio;

import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.io.IOException;
import java.net.URL;

import openeye.oechem.*;
import openeye.oebio.*;

public class PrintInteractions {

    private static OEInteractionHintComponentTypeBase ligtype = new OELigandInteractionHintComponent();
    private static OEInteractionHintComponentTypeBase protype = new OEProteinInteractionHintComponent();

    public static void main(String argv[]) {
        URL fileURL = PrintInteractions.class.getResource("PrintInteractions.txt");
        OEInterface itf = null;
        try {
            itf = new OEInterface();
            oechem.OEConfigureFromURL(itf, fileURL);
        } catch (IOException e) {
            oechem.OEThrow.Fatal("Unable to open interface file");
        }

        oebio.OEConfigureSplitMolComplexOptions(itf, OESplitMolComplexSetup.LigName);

        if (!oechem.OEParseCommandLine(itf, argv, "PrintInteractions"))
            oechem.OEThrow.Fatal("Unable to interpret command line!");

        String iname = itf.GetString("-complex");

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

        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 lig   = new OEGraphMol();
        OEGraphMol prot  = 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(lig, prot, water, other, complexmol, sopts);

        if (lig.NumAtoms() == 0)
            oechem.OEThrow.Fatal("Cannot separate complex!");

        // Perceive interactions

        OEInteractionHintContainer asite = new OEInteractionHintContainer(prot, lig);
        if (!oebio.OEIsValidActiveSite(asite))
            oechem.OEThrow.Fatal("Cannot initialize active site!");

        oebio.OEPerceiveInteractionHints(asite);

        System.out.println("Number of interactions:" + asite.NumInteractions());

        for (OEInteractionHintTypeBase itype : oebio.OEGetActiveSiteInteractionHintTypes()) {
            System.out.println(itype.GetName() + " :");
            for (OEInteractionHint inter : asite.GetInteractions(new OEHasInteractionHintType(itype))) {
                printInteraction(inter);
            }
        }
        System.out.println("\nResidue interactions:");
        OEMolBase protein = asite.GetMolecule(new OEProteinInteractionHintComponent());
        for (OEResidue residue : oebio.OEGetResidues(protein)) {
            printResidueInteraction(asite, residue);
        }
        System.out.println("\nLigand atom interactions:");
        OEMolBase ligand = asite.GetMolecule(new OELigandInteractionHintComponent());
        for (OEAtomBase atom : ligand.GetAtoms()) {
            printLigandAtomInteractions(asite, atom);
        }
    }

    public static String getResidueName(OEResidue residue) {
        String name = String.format("%3s %4d %s", residue.GetName(),
                                                  residue.GetResidueNumber(),
                                                  residue.GetChainID());
        return name;
    }

    public static String getAtomName(OEAtomBase atom) {
        String name = String.format("%2d %s", atom.GetIdx(),
                                              oechem.OEGetAtomicSymbol(atom.GetAtomicNum()));
        return name;
    }

    public static void printFragment(OEInteractionHintFragment frag) {
        OEInteractionHintComponentTypeBase fragtype = frag.GetComponentType();
        if (fragtype.equals(ligtype)) {
            System.out.print("ligand: ");
	      }
	      else if (fragtype.equals(protype)) {
            System.out.print("protein: ");
	      }
        for (OEAtomBase atom : frag.GetAtoms()) {
            System.out.print(getAtomName(atom) + " ");
        }
    }

    public static void printInteraction(OEInteractionHint inter) {
        OEInteractionHintFragment bgnfrag = inter.GetBgnFragment();
        if (bgnfrag != null) {
            printFragment(bgnfrag);
        }
        OEInteractionHintFragment endfrag = inter.GetEndFragment();
        if (endfrag != null) {
            printFragment(endfrag);
        }
        System.out.println("");
    }

    public static void printResidueInteraction(OEInteractionHintContainer asite, OEResidue residue)
    {
        Set<OEAtomBase> ligatoms = new HashSet<OEAtomBase>();
        OEHasResidueInteractionHint ipred = new OEHasResidueInteractionHint(residue);
        for (OEInteractionHint inter : asite.GetInteractions(ipred)) {
            OEInteractionHintFragment ligfrag = inter.GetFragment(new OELigandInteractionHintComponent());
            if (ligfrag != null) {
                for (OEAtomBase atom : ligfrag.GetAtoms()) {
                    ligatoms.add(atom);
                }
            }
        }
        if (!ligatoms.isEmpty()) {
            System.out.print(getResidueName(residue) + " :");
            for (OEAtomBase atom : ligatoms) {
                System.out.print(getAtomName(atom) + " ");
            }
            System.out.println("");
        }
    }

    public static void printLigandAtomInteractions(OEInteractionHintContainer asite, OEAtomBase atom) {
          Set<String> resnames = new HashSet<String>();
          OEHasInteractionHint ipred = new OEHasInteractionHint(atom);
          for (OEInteractionHint inter : asite.GetInteractions(ipred)) {
                OEInteractionHintFragment profrag = inter.GetFragment(new OEProteinInteractionHintComponent());
                if (profrag != null) {
                    for (OEAtomBase patom : profrag.GetAtoms()) {
                        OEResidue res = oechem.OEAtomGetResidue(patom);
                        resnames.add(getResidueName(res));
                    }
                }
          }
          if (!resnames.isEmpty()) {
            System.out.print(getAtomName(atom) + " :");
            for (String resname : resnames) {
                System.out.print(resname + " ");
            }
            System.out.println("");
          }
    }
}