Bioisostere Examples

The following table lists the currently available Bioisostere TK examples:

Program

Description

brood_database

Building Brood Database (CHOMP)

brood_query

Creating Brood Query

brood_hitlist

Generating Brood Hits

brood_matches

Generating Brood Matches

fragment_overlay

Overlay between Fragments

replace_fragment

Replacing a Fragment in a Molecule

Building Brood Database (CHOMP)

The following code example shows how to build a Brood database from a library of molecules.

Listing 1: Building Brood Database (CHOMP)

#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence 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 Cadence 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 Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.


from openeye import oechem
from openeye import oebioisostere
from openeye import oemolprop

class ChompOptions(oechem.OEOptions):
    def __init__(self):
        oechem.OEOptions.__init__(self, "ChompOptions")

        dbParam = oechem.OEStringParameter("-out")
        dbParam.SetVisibility(oechem.OEParamVisibility_Simple)
        dbParam.SetBrief("Output database folder name")
        dbParam.SetRequired(True)
        dbParam.SetKeyless(2)
        self._dbParam = self.AddParameter(dbParam)

        self._fragOpts = oebioisostere.ToFragmentOptions(self.AddOption(oebioisostere.OEFragmentOptions()))
        self._screenOpts = oebioisostere.ToDBScreenOptions(self.AddOption(oebioisostere.OEDBScreenOptions()))
        pass

    def CreateCopy(self):
        return self

    def GetDBName(self):
        return self._dbParam.GetStringValue()

    def GetFragOpts(self):
        return self._fragOpts

    def GetScreenOpts(self):
        return self._screenOpts


def main(argv=[__name__]):
    chompOpts = ChompOptions()
    opts = oechem.OESimpleAppOptions(chompOpts, "BroodDataBase", oechem.OEFileStringType_Mol)
    if oechem.OEConfigureOpts(opts, argv, False) == oechem.OEOptsConfigureStatus_Help:
        return 0
    chompOpts.UpdateValues(opts)

    ifs = oechem.oemolistream()
    if not ifs.open(opts.GetInFile()):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetInFile())

    print("Generating fragments...")
    builder = oebioisostere.OEDBBuilder(chompOpts.GetFragOpts())
    for mol in ifs.GetOEMols():
        builder.Generate(mol)

    print("Building 2D fragments library...")
    builder.Filter(oebioisostere.OECreateFragFilter())
    builder.Expand(oebioisostere.OECreateFlipperOptions())
    builder.Screen(chompOpts.GetScreenOpts())

    print("Generating fragment conformers...")
    writer = oebioisostere.OEDBWriter()
    writer.Init(chompOpts.GetDBName())
    count = 0
    for frag in builder.GetFrags():
        if oebioisostere.OEGenerateConformers(frag):
            writer.Write(frag)
            count += 1
    writer.Finish()
    print("Generated fragments: %d" % count)


if __name__ == "__main__":
    import sys
    sys.exit(main(sys.argv))

Download code

brood_database.py

Creating Brood Query

The following code example shows how to create a Brood Query from a molecule that could be used for Bioisosteric fragment replacements using Brood.

See also

Listing 2: Creating Brood Query

#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence 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 Cadence 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 Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.


from openeye import oechem
from openeye import oebioisostere

class QueryOptions(oechem.OEOptions):
    def __init__(self):
        oechem.OEOptions.__init__(self, "QueryOptions")

        idxParam = oechem.OEUIntParameter("-atomIndices")
        idxParam.SetIsList(True)
        idxParam.SetRequired(True)
        idxParam.SetBrief("Index of atoms in fragment")
        self._idxParam = self.AddParameter(idxParam)

        duParam = oechem.OEFileStringParameter("-du", oechem.OEFileStringType_DU)
        duParam.SetBrief("Design unit containing protein target for bump check")
        self._duParam = self.AddParameter(duParam)

        maskParam = oechem.OEUIntParameter("-proteinMask", oechem.OEDesignUnitComponents_TargetComplex)
        maskParam.SetBrief("Design unit mask to identify protein target")
        self._maskParam = self.AddParameter(maskParam)

    def CreateCopy(self):
        return self

    def GetIndices(self):
        indices = []
        for idx in self._idxParam.GetStringValues():
            indices.append(int(idx))
        return indices

    def GetDU(self):
        ifs = oechem.oeifstream()
        if not self._duParam.GetHasValue():
            return None
        if not ifs.open(self._duParam.GetStringValue()):
            oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetInFile())
        du = oechem.OEDesignUnit()
        if not oechem.OEReadDesignUnit(ifs, du):
            oechem.OEThrow.Fatal("Unable to read design unit")
        return du

    def GetProteinMask(self):
        mask = self._maskParam.GetStringValue()
        if mask == "":
            mask = self._maskParam.GetStringDefault()
        return int(mask)


def main(argv=[__name__]):
    queryOpts = QueryOptions()
    opts = oechem.OESimpleAppOptions(queryOpts, "BroodQuery", oechem.OEFileStringType_Mol3D, "oeb")
    if oechem.OEConfigureOpts(opts, argv, False) == oechem.OEOptsConfigureStatus_Help:
        return 0
    queryOpts.UpdateValues(opts)

    ifs = oechem.oemolistream()
    if not ifs.open(opts.GetInFile()):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetInFile())

    ofs = oechem.oemolostream()
    if not ofs.open(opts.GetOutFile()):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % opts.GetOutFile())

    queryMol = oechem.OEMol()
    if not oechem.OEReadMolecule(ifs, queryMol):
        oechem.OEThrow.Fatal("Unable to load molecule")

    indices = queryOpts.GetIndices()
    atoms = []
    for idx in indices:
        atom = queryMol.GetAtom(oechem.OEHasAtomIdx(idx))
        if not atom:
            oechem.OEThrow.Fatal("Invalid atom index %d" % idx)
        atoms.append(atom)
    
    bonds = []
    for atom in atoms:
        for bond in atom.GetBonds():
            if bond not in bonds:
                bonds.append(bond)

    selection = oechem.OEAtomBondSet()
    selection.AddAtoms(atoms)
    selection.AddBonds(bonds)

    query = oebioisostere.OEBroodQuery()
    du = queryOpts.GetDU()
    if du is None:
        retCode = oebioisostere.OECreateBroodQuery(query, queryMol, selection)
    else:
        retCode = oebioisostere.OECreateBroodQuery(query, queryMol, selection, du, queryOpts.GetProteinMask())
    
    if retCode != oebioisostere.OEBroodStatusCode_Success:
        oechem.OEThrow.Fatal("%s" % oebioisostere.OEGetBroodStatus(retCode))
    oebioisostere.OEWriteBroodQuery(ofs, query)

if __name__ == "__main__":
    import sys
    sys.exit(main(sys.argv))

Download code

brood_query.py

Generating Brood Hits

The following code example shows how to perform Bioisosteric fragment replacements on a Brood Query and generate a hitlist.

Listing 3: Generating Brood Hits

#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence 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 Cadence 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 Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.


from openeye import oechem
from openeye import oebioisostere

class BroodOptions(oechem.OEOptions):
    def __init__(self):
        oechem.OEOptions.__init__(self, "BroodOptions")

        dbParam = oechem.OEStringParameter("-db")
        dbParam.SetRequired(True)
        dbParam.SetVisibility(oechem.OEParamVisibility_Simple)
        dbParam.SetBrief("Database folder")
        self._dbParam = self.AddParameter(dbParam)

        self._genOpts = oebioisostere.ToGeneralOptions(self.AddOption(oebioisostere.OEBroodGeneralOptions()))
        self._scoreOpts = oebioisostere.ToScoreOptions(self.AddOption(oebioisostere.OEBroodScoreOptions()))
        self._hitOpts = oebioisostere.ToHitlistOptions(self.AddOption(oebioisostere.OEBroodHitlistOptions()))
        pass

    def CreateCopy(self):
        return self

    def GetDatabase(self):
        return self._dbParam.GetStringValue()

    def GetGenOpts(self):
        return self._genOpts

    def GetScoreOpts(self):
        return self._scoreOpts

    def GetHitlistOpts(self):
        return self._hitOpts


def main(argv=[__name__]):
    broodOpts = BroodOptions()
    opts = oechem.OESimpleAppOptions(broodOpts, "BroodHitlist", oechem.OEFileStringType_Mol3D,
                                     oechem.OEFileStringType_Mol3D)
    if oechem.OEConfigureOpts(opts, argv, False) == oechem.OEOptsConfigureStatus_Help:
        return 0
    broodOpts.UpdateValues(opts)

    ifs = oechem.oemolistream()
    if not ifs.open(opts.GetInFile()):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetInFile())

    ofs = oechem.oemolostream()
    if not ofs.open(opts.GetOutFile()):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % opts.GetOutFile())

    query = oebioisostere.OEBroodQuery()
    retCode = oebioisostere.OEReadBroodQuery(ifs, query)
    if retCode != oebioisostere.OEBroodStatusCode_Success:
        oechem.OEThrow.Fatal("Failed: %s" % oebioisostere.OEGetBroodStatus(retCode))

    reader = oebioisostere.OEDBReader()
    if not reader.Init(broodOpts.GetDatabase(), query, broodOpts.GetGenOpts()):
        oechem.OEThrow.Fatal("Unable to load Brood database")

    overlay = oebioisostere.OEBroodOverlay(broodOpts.GetGenOpts(), broodOpts.GetScoreOpts())
    overlay.SetupRef(query);

    hlist = oebioisostere.OEHitlistBuilder(query, broodOpts.GetGenOpts(), broodOpts.GetHitlistOpts())

    packetCount = 0
    packet = oebioisostere.OEBroodDBPacket()
    while reader.GetNextPacket(packet):
        packetCount += 1
        print("Processing packet %d with %d fragments" % (packetCount, packet.GetFragCount()))
        vecScores = overlay.Overlay(packet)
        hlist.AddScores(vecScores);
    print("Generating hitlist...")
    hlist.Build();
    print("Total number of fragments overlayed: %d" % hlist.GetAddCount())
    print("Number of final hits: %d" % hlist.GetHitCount())

    for idx, hit in enumerate(hlist.GetHits()):
        oechem.OEWriteMolecule(ofs, hit.GetMol())
        cobmoScore = hit.GetComboScore()
        if broodOpts.GetGenOpts().GetScoreType() == oebioisostere.OEBroodScoreType_ET:
            cobmoScore = hit.GetETComboScore()
        print("Hit: %d %s Combo Score: %2f Belief Score: %.2f Complexity: %2f"
              % (idx+1, hit.GetMol().GetTitle(), cobmoScore, hit.GetBeliefScore(), hit.GetComplexity()))


if __name__ == "__main__":
    import sys
    sys.exit(main(sys.argv))

Download code

brood_hitlist.py

Generating Brood Matches

The following code example shows how to perform Bioisosteric fragment replacements on a Brood Query and generate all possible matches. This could be a use case when generating all possible design ideas using BROOD and post processing them with other tools.

Listing 4: Generating Brood Matches

#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence 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 Cadence 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 Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

import sys

from openeye import oechem
from openeye import oebioisostere

class BroodOptions(oechem.OEOptions):
    def __init__(self):
        oechem.OEOptions.__init__(self, "BroodOptions")

        dbParam = oechem.OEStringParameter("-db")
        dbParam.SetRequired(True)
        dbParam.SetVisibility(oechem.OEParamVisibility_Simple)
        dbParam.SetBrief("Database folder")
        self._dbParam = self.AddParameter(dbParam)

        self._genOpts = oebioisostere.ToGeneralOptions(self.AddOption(oebioisostere.OEBroodGeneralOptions()))
        self._scoreOpts = oebioisostere.ToScoreOptions(self.AddOption(oebioisostere.OEBroodScoreOptions()))
        self._buildOpts = oebioisostere.ToBuildOptions(self.AddOption(oebioisostere.OEBroodBuildOptions()))
        pass

    def CreateCopy(self):
        return self

    def GetDatabase(self):
        return self._dbParam.GetStringValue()

    def GetGenOpts(self):
        return self._genOpts

    def GetScoreOpts(self):
        return self._scoreOpts

    def GetBuildOpts(self):
        return self._buildOpts


def main(argv=[__name__]):
    broodOpts = BroodOptions()
    opts = oechem.OESimpleAppOptions(broodOpts, "BroodMatching", oechem.OEFileStringType_Mol3D,
                                     oechem.OEFileStringType_Mol3D)
    if oechem.OEConfigureOpts(opts, argv, False) == oechem.OEOptsConfigureStatus_Help:
        return 0
    broodOpts.UpdateValues(opts)

    ifs = oechem.oemolistream()
    if not ifs.open(opts.GetInFile()):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetInFile())

    ofs = oechem.oemolostream()
    if not ofs.open(opts.GetOutFile()):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % opts.GetOutFile())

    query = oebioisostere.OEBroodQuery()
    retCode = oebioisostere.OEReadBroodQuery(ifs, query)
    if retCode != oebioisostere.OEBroodStatusCode_Success:
        oechem.OEThrow.Fatal("Failed: %s" % oebioisostere.OEGetBroodStatus(retCode))

    reader = oebioisostere.OEDBReader()
    if not reader.Init(broodOpts.GetDatabase(), query, broodOpts.GetGenOpts()):
        oechem.OEThrow.Fatal("Unable to load Brood database")

    overlay = oebioisostere.OEBroodOverlay(broodOpts.GetGenOpts(), broodOpts.GetScoreOpts())
    overlay.SetupRef(query);
    builder = oebioisostere.OEBroodMolBuilder(query, broodOpts.GetGenOpts(), broodOpts.GetBuildOpts())

    packetCount = 0
    packet = oebioisostere.OEBroodDBPacket()
    totalCount = 0
    successCount = 0
    while reader.GetNextPacket(packet):
        packetCount += 1
        print("Processing packet %d with %d fragments" % (packetCount, packet.GetFragCount()))
        vecScores = overlay.Overlay(packet)
        for score in vecScores:
            totalCount += 1
            if score.GetStatus() == oebioisostere.OEBroodStatusCode_Success:
                hit = oebioisostere.OEBroodHit()
                if builder.Build(score, hit) == oebioisostere.OEBroodStatusCode_Success:
                    oechem.OEWriteMolecule(ofs, hit.GetMol())
                    successCount += 1

    print("Total number of fragments overlayed: %d" % totalCount)
    print("Number of successful matches: %d" % successCount)


if __name__ == "__main__":
    import sys
    sys.exit(main(sys.argv))

Download code

brood_matching.py

Overlay between Fragments

The following code example shows how to overlay a fragment against a query fragment. This could be a use case when working with synthons and trying to find similar synthon based on 3D similarity.

Listing 5: Overlay between Fragments

#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence 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 Cadence 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 Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

import sys

from openeye import oechem
from openeye import oebioisostere

def main(argv=[__name__]):
    genOpts = oebioisostere.OEBroodGeneralOptions()
    opts = oechem.OERefInputAppOptions(genOpts, "FragmentOverlay", oechem.OEFileStringType_Mol3D,
                                     oechem.OEFileStringType_Mol3D, oechem.OEFileStringType_Mol3D, "-queryFrag")
    if oechem.OEConfigureOpts(opts, argv, False) == oechem.OEOptsConfigureStatus_Help:
        return 0
    genOpts.UpdateValues(opts)

    ifs = oechem.oemolistream()
    if not ifs.open(opts.GetInFile()):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetInFile())

    rfs = oechem.oemolistream()
    if not rfs.open(opts.GetRefFile()):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetRefFile())

    ofs = oechem.oemolostream()
    if not ofs.open(opts.GetOutFile()):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % opts.GetOutFile())

    query = oechem.OEMol()
    if not oechem.OEReadMolecule(rfs, query):
        oechem.OEThrow.Fatal("Failed to read Query fragment")

    prep = oebioisostere.OEBroodFragPrep()
    overlay = oebioisostere.OEFragOverlay(genOpts, oebioisostere.OEBroodScoreOptions())
    overlay.SetupRef(query);

    for frag in ifs.GetOEMols():
        oechem.OEThrow.Info("Overlaying %s" % frag.GetTitle())
        prep.Prep(frag)
        score = oebioisostere.OEBroodScore()
        ret_code = overlay.Overlay(frag, score)
        if ret_code == oebioisostere.OEBroodStatusCode_Success:
            outmol = oechem.OEGraphMol()
            score.GetFragMol(outmol)
            overlay.Transform(outmol)
            comboScore = score.GetComboScore()
            if genOpts.GetScoreType() == oebioisostere.OEBroodScoreType_ET:
                comboScore = score.GetETComboScore()
            print("Fragment: %s Combo Score: %2f" % (frag.GetTitle(), comboScore))
            oechem.OEWriteMolecule(ofs, outmol)
        else:
            errMsg = oebioisostere.OEGetBroodStatus(ret_code)
            oechem.OEThrow.Warning("%s: %s" % (frag.GetTitle(), errMsg))
    return 0


if __name__ == "__main__":
    import sys
    sys.exit(main(sys.argv))

Download code

fragment_overlay.py

Replacing a Fragment in a Molecule

The following code example shows how to replace a fragment in a molecule defined in the form of a BROOD Query.

Listing 6: Overlay between Fragments

#!/usr/bin/env python
# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence 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 Cadence 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 Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

import sys

from openeye import oechem
from openeye import oebioisostere

class BroodOptions(oechem.OEOptions):
    def __init__(self):
        oechem.OEOptions.__init__(self, "BroodOptions")
        self._genOpts = oebioisostere.ToGeneralOptions(self.AddOption(oebioisostere.OEBroodGeneralOptions()))
        self._scoreOpts = oebioisostere.ToScoreOptions(self.AddOption(oebioisostere.OEBroodScoreOptions()))
        self._buildOpts = oebioisostere.ToBuildOptions(self.AddOption(oebioisostere.OEBroodBuildOptions()))
        pass

    def CreateCopy(self):
        return self

    def GetGenOpts(self):
        return self._genOpts

    def GetScoreOpts(self):
        return self._scoreOpts

    def GetBuildOpts(self):
        return self._buildOpts


def main(argv=[__name__]):
    broodOpts = BroodOptions()
    opts = oechem.OERefInputAppOptions(broodOpts, "ReplaceFragment", oechem.OEFileStringType_Mol3D,
                                     oechem.OEFileStringType_Mol3D, oechem.OEFileStringType_Mol3D, "-query")
    if oechem.OEConfigureOpts(opts, argv, False) == oechem.OEOptsConfigureStatus_Help:
        return 0
    broodOpts.UpdateValues(opts)

    ifs = oechem.oemolistream()
    if not ifs.open(opts.GetInFile()):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetInFile())

    rfs = oechem.oemolistream()
    if not rfs.open(opts.GetRefFile()):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % opts.GetRefFile())

    ofs = oechem.oemolostream()
    if not ofs.open(opts.GetOutFile()):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % opts.GetOutFile())

    query = oebioisostere.OEBroodQuery()
    retCode = oebioisostere.OEReadBroodQuery(rfs, query)
    if retCode != oebioisostere.OEBroodStatusCode_Success:
        oechem.OEThrow.Fatal("Failed: %s" % oebioisostere.OEGetBroodStatus(retCode))

    prep = oebioisostere.OEBroodFragPrep()
    overlay = oebioisostere.OEBroodOverlay(broodOpts.GetGenOpts(), broodOpts.GetScoreOpts())
    overlay.SetupRef(query);
    builder = oebioisostere.OEBroodMolBuilder(query, broodOpts.GetGenOpts(), broodOpts.GetBuildOpts())

    for frag in ifs.GetOEMols():
        print("Replacement fragment %s" % frag.GetTitle())
        prep.Prep(frag)
        score = oebioisostere.OEBroodScore()
        ret_code = overlay.Overlay(frag, score)
        if ret_code == oebioisostere.OEBroodStatusCode_Success:
            comboScore = score.GetComboScore()
            if broodOpts.GetGenOpts().GetScoreType() == oebioisostere.OEBroodScoreType_ET:
                comboScore = score.GetETComboScore()
            print("Fragment: %s Combo Score: %2f" % (frag.GetTitle(), comboScore))
            hit = oebioisostere.OEBroodHit()
            if builder.Build(score, hit) == oebioisostere.OEBroodStatusCode_Success:
                oechem.OEWriteMolecule(ofs, hit.GetMol())
        else:
            errMsg = oebioisostere.OEGetBroodStatus(ret_code)
            oechem.OEThrow.Warning("%s: %s" % (frag.GetTitle(), errMsg))
    return 0


if __name__ == "__main__":
    import sys
    sys.exit(main(sys.argv))

Download code

replace_fragment.py