OEBio Examples

Extracting the backbone of a protein

/**********************************************************************
  Copyright (C) 2010-2015 OpenEye Scientific Software, Inc.
***********************************************************************/
using System;
using OpenEye.OEChem;
using OpenEye.OEBio;

public class Backbone
{
    public void MakeBackbone(string infile, string outfile)
    {
        oemolistream ifs = new oemolistream();
        if(!ifs.open(infile))
        {
            Console.WriteLine("Unable to open infile: " + infile);
            return;
        }
        oemolostream ofs = new oemolostream();
        if(!ofs.open(outfile))
        {
            Console.WriteLine("Unable to open outfile: " + outfile);
            return;
        }

        bool adjustHCount = true;
        foreach(OEGraphMol mol in ifs.GetOEGraphMols())
        {
            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);
        }
        ofs.close();
    }

    public static void Main(string [] argv)
    {
        Backbone app = new Backbone();
        if(argv.Length != 2)
        {
            OEChem.OEThrow.Usage("Backbone <inmol> <outmol>");
        }
        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

using System;
using OpenEye.OEChem;
using OpenEye.OEBio;

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

        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
            uint 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();
        return 0;
    }

    private static string interfaceData = @"
!BRIEF <inmol> [<outmol>]

!CATEGORY ""input/output options :""
   !PARAMETER -in
      !ALIAS -i
      !TYPE string
      !BRIEF Input molecule (usually a pdb file)
      !VISIBILITY simple
      !REQUIRED true
      !KEYLESS 1
   !END

   !PARAMETER -out
      !ALIAS -o
      !TYPE string
      !DEFAULT splitmolcomplex.oeb.gz
      !BRIEF Output molecule (usually an oeb)
      !VISIBILITY simple
      !REQUIRED false
      !KEYLESS 2
   !END
!END

!CATEGORY ""Display options :""
   !PARAMETER -verbose
      !ALIAS -v
      !TYPE bool
      !DEFAULT false
      !BRIEF If true, return show molecule titles and number of binding sites
      !VISIBILITY simple
      !REQUIRED false
   !END
!END
";

}

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 the low-level api

using System;
using OpenEye.OEChem;
using OpenEye.OEBio;

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

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

        uint 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(prot, frags, opts, opts.GetProteinFilter()))
            OEChem.OEThrow.Fatal("Unable to split protein complex from " + iname);

        if (! OEBio.OECombineMolComplexFragments(wat, frags, opts, opts.GetWaterFilter()))
            OEChem.OEThrow.Fatal("Unable to split waters from " + iname);

        if (! OEBio.OECombineMolComplexFragments(other, 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();
        return 0;
    }

    private static string interfaceData = @"
!BRIEF <inmol> [<outmol>]

!CATEGORY ""input/output options :""
   !PARAMETER -in
      !ALIAS -i
      !TYPE string
      !BRIEF Input molecule (usually a pdb file)
      !VISIBILITY simple
      !REQUIRED true
      !KEYLESS 1
   !END

   !PARAMETER -out
      !ALIAS -o
      !TYPE string
      !DEFAULT splitmolcomplex.oeb.gz
      !BRIEF Output molecule (usually an oeb)
      !VISIBILITY simple
      !REQUIRED false
      !KEYLESS 2
   !END
!END

!CATEGORY ""Display options :""
   !PARAMETER -verbose
      !ALIAS -v
      !TYPE bool
      !DEFAULT false
      !BRIEF If true, return show molecule titles and number of binding sites
      !VISIBILITY simple
      !REQUIRED false
   !END
!END
";

}

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

using System;
using OpenEye.OEChem;
using OpenEye.OEBio;

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

        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
            uint numSites = OEBio.OECountMolComplexSites(inmol, opts);
            OEChem.OEThrow.SetLevel(OEErrorLevel.Verbose);
            OEChem.OEThrow.Verbose("sites " + numSites);
        }

        foreach (OEMolBase frag in OEBio.OEGetMolComplexComponents(inmol, opts))
        {
          OEChem.OEThrow.Verbose("frag " + frag.GetTitle());
          OEChem.OEWriteMolecule(oms, frag);
        }

        oms.close();
        return 0;
    }

    private static string interfaceData = @"
!BRIEF <inmol> [<outmol>]

!CATEGORY ""input/output options :""
   !PARAMETER -in
      !ALIAS -i
      !TYPE string
      !BRIEF Input molecule (usually a pdb file)
      !VISIBILITY simple
      !REQUIRED true
      !KEYLESS 1
   !END

   !PARAMETER -out
      !ALIAS -o
      !TYPE string
      !DEFAULT splitmolcomplex.oeb.gz
      !BRIEF Output molecule (usually an oeb)
      !VISIBILITY simple
      !REQUIRED false
      !KEYLESS 2
   !END
!END

!CATEGORY ""Display options :""
   !PARAMETER -verbose
      !ALIAS -v
      !TYPE bool
      !DEFAULT false
      !BRIEF If true, return show fragment titles and number of binding sites
      !VISIBILITY simple
      !REQUIRED false
   !END
!END
";
}

Preparing a Protein

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

using System;
using OpenEye.OEChem;
using OpenEye.OEBio;

public class ProteinPrep
{
    static uint WaterProcess(string processName)
    {
        if (processName.Equals("fullsearch"))
            return OEPlaceHydrogensWaterProcessing.FullSearch;
        else if (processName.Equals("focused"))
            return OEPlaceHydrogensWaterProcessing.Focused;
        return OEPlaceHydrogensWaterProcessing.Ignore;
    }

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

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

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

        bool verbose = itf.GetBool("-verbose");
        if (verbose)
            OEChem.OEThrow.SetLevel(OEErrorLevel.Verbose);

        string altProcess = itf.GetString("-alts");
        bool keepAlts     = ! altProcess.Equals("a");
        bool highestOcc   =  (altProcess.Equals("occupancy"));
        bool compareAlts  =  (altProcess.Equals("compare"));

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

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

        string watProcessName = itf.GetString("-waterprocessing");
        uint waterProcess = WaterProcess(watProcessName);

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

        uint 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.");

        uint 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() + ".");

          uint howManySites = OEBio.OECountMolComplexSites(frags);
          if (howManySites < siteNum)
          {
            OEChem.OEThrow.Warning("Binding site count (" + howManySites +
                                   ") less than requested site (" + siteNum +
                                   ") in " + inmol.GetTitle() + ".");
            return 0;
          }

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

        return 0;
    }

    private static string interfaceData = @"
!BRIEF <inmol> [<outcplx> [<outlig>]]

!CATEGORY ""input/output options :"" 1
   !PARAMETER -in 1
      !ALIAS -i
      !TYPE string
      !BRIEF Input molecule filename (must have 3D coordinates)
      !SIMPLE true
      !REQUIRED true
      !KEYLESS 1
   !END

   !PARAMETER -cplxout 2
      !ALIAS -p
      !TYPE string
      !DEFAULT proteinprep.oeb.gz
      !BRIEF Output complex filename
      !SIMPLE true
      !REQUIRED false
      !KEYLESS 2
   !END

   !PARAMETER -ligout 3
      !ALIAS -l
      !TYPE string
      !BRIEF Output ligand filename
      !SIMPLE true
      !REQUIRED false
      !KEYLESS 3
   !END
!END

!CATEGORY ""Calculation options :"" 2
    !PARAMETER -alts 1
       !TYPE string
       !LEGAL_VALUE occupancy
       !LEGAL_VALUE a
       !LEGAL_VALUE ignore
       !LEGAL_VALUE compare
       !DEFAULT occupancy
       !BRIEF Alternate location atom handling (affects atom:atom interactions)
       !SIMPLE true
       !REQUIRED false
       !DETAIL
         occupancy - keep just the highest average occupancy for each alt group
         a - keep only loc code A (and blank)
         ignore - assume alts already selected appropriately
         compare - keep all alts but only interact if same loc code (or blank)
    !END

    !PARAMETER -placehydrogens 2
       !TYPE bool
       !DEFAULT true
       !BRIEF If false, hydrogens will not be added
       !SIMPLE true
       !REQUIRED false
    !END

    !PARAMETER -waterprocessing 3
       !TYPE string
       !LEGAL_VALUE ignore
       !LEGAL_VALUE focused
       !LEGAL_VALUE fullsearch
       !DEFAULT fullsearch
       !BRIEF How waters are processed
       !SIMPLE true
       !REQUIRED false
       !DETAIL
         ignore - leave water hydrogens in a random orientation
         focused - search orientations based on neighboring polar groups
         fullsearch - do an extensive search of water orientations
    !END

    !PARAMETER -standardizehyd 4
       !ALIAS -stdhyd
       !TYPE bool
       !DEFAULT true
       !BRIEF If false, bonds for hydrogens are not adjusted to standard lengths
       !SIMPLE false
       !REQUIRED false
    !END

    !PARAMETER -clashcutoff 5
        !TYPE double
        !DEFAULT 0.4
        !BRIEF Van der Waals overlap (in Angstroms) defined to be a bad clash
        !SIMPLE false
        !REQUIRED false
    !END

    !PARAMETER -flipbias 6
        !TYPE double
        !DEFAULT 1.0
        !BRIEF Scale factor for the bias against flipping sidechains such as HIS
        !SIMPLE false
        !REQUIRED false
    !END

    !PARAMETER -maxsubstates 7
        !TYPE double
        !DEFAULT 1.0e8
        !BRIEF Maximum number of substates in a single step of hydrogen placement optimization
        !SIMPLE false
        !REQUIRED false
    !END
!END

!CATEGORY ""Display options :"" 9
   !PARAMETER -verbose 1
      !ALIAS -v
      !TYPE bool
      !DEFAULT false
      !BRIEF Display more information about the process
      !SIMPLE true
      !REQUIRED false
   !END
!END
";

}

Perceive and Print Protein-Ligand Interactions

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

using System;
using System.Collections.Generic;
using OpenEye.OEChem;
using OpenEye.OEBio;

public class PrintInteractions
{
    private static OEInteractionHintComponentTypeBase ligtype = new OELigandInteractionHintComponent();
    private static OEInteractionHintComponentTypeBase protype = new OEProteinInteractionHintComponent();

    public static void Main(string[] argv)
    {
        OEInterface itf = new OEInterface(interfaceData);
        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);

        Console.WriteLine("Number of interactions: " + asite.NumInteractions());
        foreach (OEInteractionHintTypeBase itype in OEBio.OEGetActiveSiteInteractionHintTypes())
        {
            Console.WriteLine(itype.GetName() + " :");

            foreach (OEInteractionHint inter in asite.GetInteractions(new OEHasInteractionHintType(itype)))
            {
                printInteraction(inter);
            }
        }
        Console.WriteLine("\nResidue interactions:");
        OEMolBase protein = asite.GetMolecule(new OEProteinInteractionHintComponent());
        foreach (OEResidue residue in OEBio.OEGetResidues(protein))
        {
            printResidueInteraction(asite, residue);
        }
        Console.WriteLine("\nLigand atom interactions:");
        OEMolBase ligand = asite.GetMolecule(new OELigandInteractionHintComponent());
        foreach (OEAtomBase atom in ligand.GetAtoms())
        {
            printLigandAtomInteractions(asite, atom);
        }
    }

    public static String getResidueName(OEResidue residue)
    {
        String name = String.Format("{0,3} {1,4:D} {2}", residue.GetName(),
                                                    residue.GetResidueNumber(),
                                                    residue.GetChainID());
        return name;
    }

    public static String getAtomName(OEAtomBase atom)
    {
        String name = String.Format("{0,2:D} {1}",
            atom.GetIdx(),
            OEChem.OEGetAtomicSymbol(atom.GetAtomicNum()));
        return name;
    }

    public static void printFragment(OEInteractionHintFragment frag) {
        OEInteractionHintComponentTypeBase fragtype = frag.GetComponentType();
        if (fragtype.Equals(ligtype))
        {
            Console.Write("ligand: ");
	      }
	      else if (fragtype.Equals(protype))
        {
            Console.Write("protein: ");
	      }
        foreach (OEAtomBase atom in frag.GetAtoms())
        {
            Console.Write(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);
        }
        Console.WriteLine("");
    }

    public static void printResidueInteraction(OEInteractionHintContainer asite, OEResidue residue)
    {
        HashSet<OEAtomBase> ligatoms = new HashSet<OEAtomBase>();
        OEHasResidueInteractionHint ipred = new OEHasResidueInteractionHint(residue);
        foreach (OEInteractionHint inter in asite.GetInteractions(ipred))
        {
            OEInteractionHintFragment ligfrag = inter.GetFragment(new OELigandInteractionHintComponent());
            if ((object)ligfrag != null)
            {
                foreach (OEAtomBase atom in ligfrag.GetAtoms())
                {
                    ligatoms.Add(atom);
                }
            }
        }
        if (ligatoms.Count > 0)
        {
            Console.Write(getResidueName(residue) + " :  ");
            foreach (OEAtomBase atom in ligatoms)
            {
                Console.Write(getAtomName(atom) + " ");
            }
            Console.WriteLine("");
        }
    }

    public static void printLigandAtomInteractions(OEInteractionHintContainer asite, OEAtomBase atom)
    {
        HashSet<String> resnames = new HashSet<String>();
        OEHasInteractionHint ipred = new OEHasInteractionHint(atom);
        foreach (OEInteractionHint inter in asite.GetInteractions(ipred))
        {
            OEInteractionHintFragment profrag = inter.GetFragment(new OEProteinInteractionHintComponent());
            if ((object)profrag != null)
            {
                foreach (OEAtomBase patom in profrag.GetAtoms())
                {
                    OEResidue res = OEChem.OEAtomGetResidue(patom);
                    resnames.Add(getResidueName(res));
                }
            }
        }
        if (resnames.Count > 0)
        {
            Console.Write(getAtomName(atom) + " : ");
            foreach (String resname in resnames)
            {
                Console.Write(resname + " ");
            }
            Console.WriteLine("");
        }
    }
    private static string interfaceData = @"
!BRIEF [-complex] <input>

!CATEGORY input/output options :

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

!END
";

}