Bioisostere Examples¶
The following table lists the currently available Bioisostere TK examples:
Program |
Description |
---|---|
Building Brood Database (CHOMP) |
|
Creating Brood Query |
|
Generating Brood Hits |
|
Generating Brood Matches |
|
Overlay between Fragments |
|
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.
See also
OEFragmentOptions class
OEDBScreenOptions class
OEDBBuilder class
OEDBWriter class
OEGenerateConformers function
Listing 1: Building Brood Database (CHOMP)
/*
(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.
*/
#include <cstdio>
#include <string>
#include <openeye.h>
#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oebioisostere.h>
#include <oemolprop.h>
class ChompOptions : public OESystem::OEOptions
{
public:
ChompOptions(std::string name = "ChompOptions")
:OESystem::OEOptions(name)
{
OESystem::OEStringParameter pDBName("-out");
pDBName.SetRequired(true);
pDBName.SetKeyless(2);
pDBName.SetVisibility(OESystem::OEParamVisibility::Simple);
pDBName.SetBrief("Output database folder name");
m_dbParam = AddParameter(pDBName);
m_FragmentOptions = static_cast<OEBioisostere::OEFragmentOptions*>(AddOption(OEBioisostere::OEFragmentOptions()));
m_ScreenOptions = static_cast<OEBioisostere::OEDBScreenOptions*>(AddOption(OEBioisostere::OEDBScreenOptions()));
}
ChompOptions(const ChompOptions&) = default;
ChompOptions& operator=(const ChompOptions&) = default;
~ChompOptions() override =default;
ChompOptions* CreateCopy() const override { return new ChompOptions(*this);}
std::string GetDBName() const { return m_dbParam->GetStringValue(); }
OEBioisostere::OEFragmentOptions* GetFragOpts() const { return m_FragmentOptions; }
OEBioisostere::OEDBScreenOptions* GetScreenOpts() const { return m_ScreenOptions; }
private:
OESystem::OEParameter* m_dbParam;
OEBioisostere::OEFragmentOptions* m_FragmentOptions;
OEBioisostere::OEDBScreenOptions* m_ScreenOptions;
};
int main(int argc, char* argv[])
{
ChompOptions chompOpts;
OEChem::OESimpleAppOptions opts(chompOpts, "BroodDataBase", OEChem::OEFileStringType::Mol);
if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
return 0;
chompOpts.UpdateValues(opts);
OEChem::oemolistream ifs;
if (!ifs.open(opts.GetInFile()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());
printf("Generating fragments...\n");
OEBioisostere::OEDBBuilder builder = OEBioisostere::OEDBBuilder( *chompOpts.GetFragOpts());
OEChem::OEGraphMol mol;
while(OEChem::OEReadMolecule(ifs, mol))
builder.Generate(mol);
printf("Building 2D fragments library...\n");
builder.Filter(*OEBioisostere::OECreateFragFilter());
builder.Expand(*OEBioisostere::OECreateFlipperOptions());
builder.Screen(*chompOpts.GetScreenOpts());
printf("Generating fragment conformers...\n");
OEBioisostere::OEDBWriter writer;
writer.Init(chompOpts.GetDBName());
unsigned count=0;
OESystem::OEIter<OEChem::OEMCMolBase> frag = builder.GetFrags();
for(; frag; ++frag)
{
count++;
OEBioisostere::OEGenerateConformers(*frag);
writer.Write(*frag);
}
writer.Finish();
printf("Generated fragments: %d \n",count);
}
Download code
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
OEBroodQuery class
OECreateBroodQuery function
Listing 2: Creating Brood Query
/*
(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.
*/
#include <cstdio>
#include <string>
#include <openeye.h>
#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oebioisostere.h>
class QueryOptions : public OESystem::OEOptions
{
public:
QueryOptions(std::string name = "QueryOptions")
:OESystem::OEOptions(name)
{
OESystem::OEUIntParameter idxParam("-atomIndices");
idxParam.SetIsList(true);
idxParam.SetRequired(true);
idxParam.SetBrief("Index of atoms in fragment");
m_idxParam = AddParameter(idxParam);
OEChem::OEFileStringParameter duParam("-du",OEChem::OEFileStringType::DU);
duParam.SetBrief("Design unit containg protein target for bump check");
m_duParam = AddParameter(duParam);
OESystem::OEUIntParameter maskParam("-proteinMask", OEBio::OEDesignUnitComponents::TargetComplex);
maskParam.SetBrief("Design unit mask to identify protein target");
m_maskParam = AddParameter(maskParam);
}
QueryOptions(const QueryOptions&) = default;
QueryOptions& operator=(const QueryOptions&) = default;
~QueryOptions() override =default;
QueryOptions* CreateCopy() const override { return new QueryOptions(*this);}
std::vector<int> GetIndices()
{
std::vector<int> indices;
OESystem::OEIter<const std::string> Value = m_idxParam->GetStringValues();
for (;Value;++Value)
{
indices.push_back(std::stoi(Value));
}
return indices;
}
bool GetDU(OEChem::OESimpleAppOptions opts, OEBio::OEDesignUnit& du)
{
OEChem::oemolistream ifs;
if(!m_duParam->GetHasValue())
return false;
if(!ifs.open(m_duParam->GetStringValue()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());
if(!OEBio::OEReadDesignUnit(ifs, du))
OESystem::OEThrow.Fatal("Unable to read design unit");
return true;
}
int GetProteinMask()
{
std::string mask = m_maskParam->GetStringValue();
if (mask == "")
mask = m_maskParam->GetStringDefault();
return std::stoi(mask);
}
private:
OESystem::OEParameter* m_idxParam;
OESystem::OEParameter* m_duParam;
OESystem::OEParameter* m_maskParam;
};
int main(int argc, char* argv[])
{
QueryOptions queryOpts;
OEChem::OESimpleAppOptions opts(queryOpts, "BroodQuery", OEChem::OEFileStringType::Mol3D, "oeb");
if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
return 0;
queryOpts.UpdateValues(opts);
OEChem::oemolistream ifs;
if (!ifs.open(opts.GetInFile()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());
OEChem::oemolostream ofs;
if (!ofs.open(opts.GetOutFile()))
OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());
OEChem::OEMol queryMol;
if (!OEChem::OEReadMolecule(ifs,queryMol))
OESystem::OEThrow.Fatal("Unable to load molecule");
std::vector<int> indices = queryOpts.GetIndices();
std::vector<OEChem::OEAtomBase*> atoms;
for (const auto& idx:indices)
{
OEChem::OEAtomBase* atom;
atom = queryMol.GetAtom(OEChem::OEHasAtomIdx(idx));
if (atom == nullptr)
OESystem::OEThrow.Fatal("Invalid atom index %d", idx);
atoms.push_back(std::move(atom));
}
OEChem::OEAtomBondSet selection;
selection.AddAtoms(atoms);
OEBioisostere::OEBroodQuery query;
OEBio::OEDesignUnit du;
unsigned retCode;
if (!queryOpts.GetDU(opts, du))
retCode = OEBioisostere::OECreateBroodQuery(query, queryMol, selection);
else
retCode = OEBioisostere::OECreateBroodQuery(query, queryMol, selection, du, queryOpts.GetProteinMask());
if(retCode != OEBioisostere::OEBroodStatusCode::Success)
OESystem::OEThrow.Fatal("%s", OEBioisostere::OEGetBroodStatus(retCode).c_str());
OEBioisostere::OEWriteBroodQuery(ofs, query);
}
Download code
Generating Brood Hits¶
The following code example shows how to perform Bioisosteric fragment replacements on a Brood Query and generate a hitlist.
See also
OEBroodGeneralOptions class
OEBroodScoreOptions class
OEBroodHitlistOptions class
OEBroodOverlay class
OEHitlistBuilder class
Listing 3: Generating Brood Hits
/*
(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.
*/
#include <cstdio>
#include <openeye.h>
#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oebioisostere.h>
class BroodOptions : public OESystem::OEOptions
{
public:
BroodOptions(std::string name = "BroodOptions")
:OESystem::OEOptions(name)
{
OESystem::OEStringParameter pDBName("-db");
pDBName.SetRequired(true);
pDBName.SetVisibility(OESystem::OEParamVisibility::Simple);
pDBName.SetBrief("Database Folder");
m_dbParam = AddParameter(pDBName);
m_GeneralOptions = static_cast<OEBioisostere::OEBroodGeneralOptions*>(AddOption(OEBioisostere::OEBroodGeneralOptions()));
m_ScoreOptions = static_cast<OEBioisostere::OEBroodScoreOptions*>(AddOption(OEBioisostere::OEBroodScoreOptions()));
m_HitlistOptions = static_cast<OEBioisostere::OEBroodHitlistOptions*>(AddOption(OEBioisostere::OEBroodHitlistOptions()));
}
BroodOptions(const BroodOptions&) = default;
BroodOptions& operator=(const BroodOptions&) = default;
~BroodOptions() override =default;
BroodOptions* CreateCopy() const override { return new BroodOptions(*this);}
std::string GetDataBase() const { return m_dbParam->GetStringValue(); }
OEBioisostere::OEBroodGeneralOptions* GetGenOpts() const { return m_GeneralOptions; }
OEBioisostere::OEBroodScoreOptions* GetScoreOpts() const { return m_ScoreOptions; }
OEBioisostere::OEBroodHitlistOptions* GetHitlistOpts() const { return m_HitlistOptions; }
private:
OESystem::OEParameter* m_dbParam;
OEBioisostere::OEBroodGeneralOptions* m_GeneralOptions;
OEBioisostere::OEBroodScoreOptions* m_ScoreOptions;
OEBioisostere::OEBroodHitlistOptions* m_HitlistOptions;
};
int main(int argc, char* argv[])
{
BroodOptions broodOpts;
OEChem::OESimpleAppOptions opts(broodOpts, "BroodHitlist", OEChem::OEFileStringType::Mol3D, OEChem::OEFileStringType::Mol3D);
if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
return 0;
broodOpts.UpdateValues(opts);
OEChem::oemolistream ifs;
if (!ifs.open(opts.GetInFile()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());
OEChem::oemolostream ofs;
if (!ofs.open(opts.GetOutFile()))
OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());
OEBioisostere::OEBroodQuery query;
bool retCode = OEBioisostere::OEReadBroodQuery(ifs,query);
if (retCode != OEBioisostere::OEBroodStatusCode::Success)
OESystem::OEThrow.Fatal("Failed: %", OEBioisostere::OEGetBroodStatus(retCode).c_str());
OEBioisostere::OEDBReader reader;
if(!reader.Init(broodOpts.GetDataBase(), query, *broodOpts.GetGenOpts()))
OESystem::OEThrow.Fatal("Unable to load Brood database");
OEBioisostere::OEBroodOverlay overlay = OEBioisostere::OEBroodOverlay(*broodOpts.GetGenOpts(), *broodOpts.GetScoreOpts());
overlay.SetupRef(query);
OEBioisostere::OEHitlistBuilder hlist = OEBioisostere::OEHitlistBuilder(query, *broodOpts.GetGenOpts(), *broodOpts.GetHitlistOpts());
unsigned packetCount = 0;
OEBioisostere::OEBroodDBPacket packet;
while(reader.GetNextPacket(packet))
{
packetCount++;
printf("Processing packet %d with %d fragments \n", packetCount, packet.GetFragCount());
std::vector<OEBioisostere::OEBroodScore> vecScores = overlay.Overlay(packet);
hlist.AddScores(vecScores);
}
printf("Generating hitlist... \n");
hlist.Build();
printf("Total number of fragments overlayed: %d \n", hlist.GetAddCount());
printf("Number of final hits: %d \n", hlist.GetHitCount());
std::vector<OEBioisostere::OEBroodHit> vecHits = hlist.GetHits();
unsigned index = 0;
for(const auto& hit:vecHits)
{
OEChem::OEWriteConstMolecule(ofs, hit.GetMol());
double cobmoScore = hit.GetComboScore();
if ((*broodOpts.GetGenOpts()).GetScoreType() == OEBioisostere::OEBroodScoreType::ET)
cobmoScore = hit.GetETComboScore();
printf("Hit: %d %s Combo Score: %2f Belief Score: %.2f Complexity: %2f \n", index+1, hit.GetMol().GetTitle(), cobmoScore, hit.GetBeliefScore(), hit.GetComplexity());
index++;
}
}
Download code
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.
See also
OEBroodGeneralOptions class
OEBroodScoreOptions class
OEBroodOverlay class
OEBroodMolBuilder class
Listing 4: Generating Brood Matches
/*
(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.
*/
#include <cstdio>
#include <string>
#include <openeye.h>
#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oebioisostere.h>
class BroodOptions : public OESystem::OEOptions
{
public:
BroodOptions(std::string name = "BroodOptions")
:OESystem::OEOptions(name)
{
OESystem::OEStringParameter pDBName("-db");
pDBName.SetRequired(true);
pDBName.SetVisibility(OESystem::OEParamVisibility::Simple);
pDBName.SetBrief("Database Folder");
m_dbParam = AddParameter(pDBName);
m_GeneralOptions = static_cast<OEBioisostere::OEBroodGeneralOptions*>(AddOption(OEBioisostere::OEBroodGeneralOptions()));
m_ScoreOptions = static_cast<OEBioisostere::OEBroodScoreOptions*>(AddOption(OEBioisostere::OEBroodScoreOptions()));
m_BuildOptions = static_cast<OEBioisostere::OEBroodBuildOptions*>(AddOption(OEBioisostere::OEBroodBuildOptions()));
}
BroodOptions(const BroodOptions&) = default;
BroodOptions& operator=(const BroodOptions&) = default;
~BroodOptions() override =default;
BroodOptions* CreateCopy() const override { return new BroodOptions(*this);}
std::string GetDataBase() const { return m_dbParam->GetStringValue(); }
OEBioisostere::OEBroodGeneralOptions* GetGenOpts() const { return m_GeneralOptions; }
OEBioisostere::OEBroodScoreOptions* GetScoreOpts() const { return m_ScoreOptions; }
OEBioisostere::OEBroodBuildOptions* GetBuildOpts() const { return m_BuildOptions; }
private:
OESystem::OEParameter* m_dbParam;
OEBioisostere::OEBroodGeneralOptions* m_GeneralOptions;
OEBioisostere::OEBroodScoreOptions* m_ScoreOptions;
OEBioisostere::OEBroodBuildOptions* m_BuildOptions;
};
int main(int argc, char* argv[])
{
BroodOptions broodOpts;
OEChem::OESimpleAppOptions opts(broodOpts, "BroodMatching", OEChem::OEFileStringType::Mol3D, OEChem::OEFileStringType::Mol3D);
if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
return 0;
broodOpts.UpdateValues(opts);
OEChem::oemolistream ifs;
if (!ifs.open(opts.GetInFile()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());
OEChem::oemolostream ofs;
if (!ofs.open(opts.GetOutFile()))
OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());
OEBioisostere::OEBroodQuery query;
bool retCode = OEBioisostere::OEReadBroodQuery(ifs,query);
if (retCode != OEBioisostere::OEBroodStatusCode::Success)
OESystem::OEThrow.Fatal("Failed: %s", OEBioisostere::OEGetBroodStatus(retCode).c_str());
OEBioisostere::OEDBReader reader;
if(!reader.Init(broodOpts.GetDataBase(), query, *broodOpts.GetGenOpts()))
OESystem::OEThrow.Fatal("Unable to load Brood database");
OEBioisostere::OEBroodOverlay overlay = OEBioisostere::OEBroodOverlay(*broodOpts.GetGenOpts(), *broodOpts.GetScoreOpts());
overlay.SetupRef(query);
OEBioisostere::OEBroodMolBuilder builder = OEBioisostere::OEBroodMolBuilder(query, *broodOpts.GetGenOpts(), *broodOpts.GetBuildOpts());
unsigned packetCount = 0;
unsigned totalCount = 0;
unsigned successCount = 0;
OEBioisostere::OEBroodDBPacket packet;
while(reader.GetNextPacket(packet))
{
packetCount++;
printf("Processing packet %d with %d fragments \n", packetCount, packet.GetFragCount());
std::vector<OEBioisostere::OEBroodScore> vecScores = overlay.Overlay(packet);
for (const auto& score:vecScores)
{
totalCount++;
if (score.GetStatus() == OEBioisostere::OEBroodStatusCode::Success)
{
OEBioisostere::OEBroodHit hit;
if(builder.Build(score,hit)==OEBioisostere::OEBroodStatusCode::Success)
{
OEChem::OEWriteConstMolecule(ofs, hit.GetMol());
successCount++;
}
}
}
}
ofs.close();
printf("Total number of fragments overlayed: %d \n",totalCount);
printf("Number of successful matches: %d \n",successCount);
}
Download code
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.
See also
OEBroodGeneralOptions class
OEBroodScoreOptions class
OEFragOverlay class
Listing 5: Overlay between Fragments
/*
(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.
*/
#include <cstdio>
#include <string>
#include <openeye.h>
#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oebioisostere.h>
int main(int argc, char* argv[])
{
OEBioisostere::OEBroodGeneralOptions genOpts;
OEChem::OERefInputAppOptions opts(genOpts, "FragmentOverlay", OEChem::OEFileStringType::Mol3D, OEChem::OEFileStringType::Mol3D, OEChem::OEFileStringType::Mol3D, "-queryFrag");
if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
return 0;
genOpts.UpdateValues(opts);
OEChem::oemolistream ifs;
if (!ifs.open(opts.GetInFile()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());
OEChem::oemolistream rfs;
if (!rfs.open(opts.GetRefFile()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());
OEChem::oemolostream ofs;
if (!ofs.open(opts.GetOutFile()))
OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());
OEChem::OEMol query;
if (!OEChem::OEReadMolecule(rfs, query))
OESystem::OEThrow.Fatal("Failed to read Query fragment");
OEBioisostere::OEBroodFragPrep prep;
OEBioisostere::OEFragOverlay overlay = OEBioisostere::OEFragOverlay(genOpts,OEBioisostere::OEBroodScoreOptions());
overlay.SetupRef(query);
OEChem::OEMol mol;
while (OEChem::OEReadMolecule(ifs, mol))
{
printf("Overlaying %s \n",mol.GetTitle());
prep.Prep(mol);
OEBioisostere::OEBroodScore score;
unsigned retCode = overlay.Overlay(mol, score);
if (retCode == OEBioisostere::OEBroodStatusCode::Success)
{
OEChem::OEGraphMol outmol;
score.GetFragMol(outmol);
overlay.Transform(outmol);
double comboScore = score.GetComboScore();
if(genOpts.GetScoreType() == OEBioisostere::OEBroodScoreType::ET)
comboScore = score.GetETComboScore();
printf("Fragment: %s Combo Score: %.5f \n",mol.GetTitle(),comboScore);
OEChem::OEWriteConstMolecule(ofs,outmol);
}
else
{
OESystem::OEThrow.Warning("%s: %s",mol.GetTitle(), OEBioisostere::OEGetBroodStatus(retCode).c_str());
}
}
return 0;
}
Download code
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.
See also
OEBroodGeneralOptions class
OEBroodScoreOptions class
OEBroodOverlay class
OEBroodMolBuilder class
Listing 6: Replacing a Fragment in a Molecule
/*
(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.
*/
#include <cstdio>
#include <string>
#include <openeye.h>
#include <oeplatform.h>
#include <oesystem.h>
#include <oechem.h>
#include <oebioisostere.h>
class BroodOptions : public OESystem::OEOptions
{
public:
BroodOptions(std::string name = "BroodOptions")
:OESystem::OEOptions(name)
{
m_GeneralOptions = static_cast<OEBioisostere::OEBroodGeneralOptions*>(AddOption(OEBioisostere::OEBroodGeneralOptions()));
m_ScoreOptions = static_cast<OEBioisostere::OEBroodScoreOptions*>(AddOption(OEBioisostere::OEBroodScoreOptions()));
m_BuildOptions = static_cast<OEBioisostere::OEBroodBuildOptions*>(AddOption(OEBioisostere::OEBroodBuildOptions()));
}
BroodOptions(const BroodOptions&) = default;
BroodOptions& operator=(const BroodOptions&) = default;
~BroodOptions() override =default;
BroodOptions* CreateCopy() const override { return new BroodOptions(*this);}
OEBioisostere::OEBroodGeneralOptions* GetGenOpts() const { return m_GeneralOptions; }
OEBioisostere::OEBroodScoreOptions* GetScoreOpts() const { return m_ScoreOptions; }
OEBioisostere::OEBroodBuildOptions* GetBuildOpts() const { return m_BuildOptions; }
private:
OEBioisostere::OEBroodGeneralOptions* m_GeneralOptions;
OEBioisostere::OEBroodScoreOptions* m_ScoreOptions;
OEBioisostere::OEBroodBuildOptions* m_BuildOptions;
};
int main(int argc, char* argv[])
{
BroodOptions broodOpts;
OEChem::OERefInputAppOptions opts(broodOpts, "ReplaceFragment", OEChem::OEFileStringType::Mol3D,OEChem::OEFileStringType::Mol3D, OEChem::OEFileStringType::Mol3D, "-query");
if (OESystem::OEConfigureOpts(opts, argc, argv, false) == OESystem::OEOptsConfigureStatus::Help)
return 0;
broodOpts.UpdateValues(opts);
OEChem::oemolistream ifs;
if (!ifs.open(opts.GetInFile()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetInFile().c_str());
OEChem::oemolistream rfs;
if (!rfs.open(opts.GetRefFile()))
OESystem::OEThrow.Fatal("Unable to open %s for reading", opts.GetRefFile().c_str());
OEChem::oemolostream ofs;
if (!ofs.open(opts.GetOutFile()))
OESystem::OEThrow.Fatal("Unable to open %s for writing", opts.GetOutFile().c_str());
OEBioisostere::OEBroodQuery query;
bool retCode = OEBioisostere::OEReadBroodQuery(rfs,query);
if (retCode != OEBioisostere::OEBroodStatusCode::Success)
OESystem::OEThrow.Fatal("Failed: %s", OEBioisostere::OEGetBroodStatus(retCode).c_str());
OEBioisostere::OEBroodFragPrep prep;
OEBioisostere::OEBroodOverlay overlay = OEBioisostere::OEBroodOverlay(*broodOpts.GetGenOpts(), *broodOpts.GetScoreOpts());
overlay.SetupRef(query);
OEBioisostere::OEBroodMolBuilder builder = OEBioisostere::OEBroodMolBuilder(query, *broodOpts.GetGenOpts(), *broodOpts.GetBuildOpts());
OEChem::OEMol mol;
while (OEChem::OEReadMolecule(ifs, mol))
{
printf("Replacement fragment %s \n",mol.GetTitle());
prep.Prep(mol);
OEBioisostere::OEBroodScore score;
unsigned retCode = overlay.Overlay(mol, score);
if (retCode == OEBioisostere::OEBroodStatusCode::Success)
{
double comboScore = score.GetComboScore();
if(broodOpts.GetGenOpts()->GetScoreType() == OEBioisostere::OEBroodScoreType::ET)
comboScore = score.GetETComboScore();
printf("Fragment: %s Combo Score: %.5f \n",mol.GetTitle(),comboScore);
OEBioisostere::OEBroodHit hit;
if(builder.Build(score, hit) == OEBioisostere::OEBroodStatusCode::Success)
OEChem::OEWriteConstMolecule(ofs, hit.GetMol());
}
else
{
OESystem::OEThrow.Warning("%s: %s",mol.GetTitle(), OEBioisostere::OEGetBroodStatus(retCode).c_str());
}
}
return 0;
}
Download code