SiteHopper Search¶
Search a SiteHopper Database¶
Listing 1: Simple example to search a SiteHopper database
/*
(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 <oebio.h>
#include <oechem.h>
#include <oeplatform.h>
#include <oesitehopper.h>
#include <oesystem.h>
#include <openeye.h>
using namespace OESiteHopper;
using namespace OEBio;
using namespace OESystem;
using namespace OEChem;
using namespace OEPlatform;
int main(int argc, char* argv[])
{
if (argc < 4)
{
OEThrow.Usage("%s <shdb> <query du> <hits oedu>", argv[0]);
return 0;
}
OESiteHopperDatabase shdb;
if (!shdb.Open(argv[1], OESiteHopperDatabaseMode::SEARCH))
OEThrow.Fatal("Unable to open %s for reading", argv[1]);
oeofstream ofs;
if (!ofs.open(argv[3]))
OEThrow.Fatal("Unable to open %s for writing", argv[3]);
OEDesignUnit query;
if (!OEReadDesignUnit(argv[2], query))
OEThrow.Fatal("Unable to read query from %s.", argv[2]);
// write out query to top of hits file
OEAddPatchSurface(query, shdb.GetOptions().GetPatchOptions());
OEWriteDesignUnit(ofs, query);
OESiteHopperSearch search(shdb);
OESiteHopperSearchOptions opts;
opts.SetNormalizeAndRescore(true);
opts.SetMaxHits(25);
OEConsoleProgressTracer tracer;
OEIter<OESiteHopperScore> score = search.Search(query, opts, tracer);
for (; score; ++score)
{
OEThrow.Info("Rank: %3d\tTitle: %25s\tPatchScore: %.2f", score->GetRank(), score->GetTitle().c_str(),
score->GetPatchScore());
auto hitDU = score->GetDesignUnit();
// this attaches all the score numerical data to the protein in the DU for
// visualization in VIDA
OESetProteinSDData(hitDU, score);
OEWriteDesignUnit(ofs, hitDU);
}
return 0;
}
Download code
SiteHopper Database¶
Creating a new Database¶
Listing 2: Simple example to create new SiteHopper database
/*
(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 <oebio.h>
#include <oechem.h>
#include <oeplatform.h>
#include <oesitehopper.h>
#include <oesystem.h>
#include <openeye.h>
using namespace OESiteHopper;
using namespace OEBio;
using namespace OESystem;
using namespace OEChem;
using namespace OEPlatform;
int main(int argc, char* argv[])
{
if (argc < 3 || argc > 4)
{
OEThrow.Usage("%s <shdb> <du directory> [-verbose]", argv[0]);
return 0;
}
OEConsoleProgressTracer consoleTracer;
OENullTracer nullTracer;
OETracerBase* tracer = &consoleTracer;
if (argc == 4)
{
tracer = &nullTracer;
if (std::string(argv[3]) == "-verbose")
OEThrow.SetLevel(OEErrorLevel::Debug);
else
OEThrow.Fatal("unknown argument: %s", argv[3]);
}
if (OEFileExists(argv[1]))
OEThrow.Fatal("%s already exists, exiting...", argv[1]);
OESiteHopperDatabase shdb;
if (!shdb.Open(argv[1], OESiteHopperDatabaseMode::CREATE))
OEThrow.Fatal("Unable to open %s for creation.", argv[1]);
auto ncpu = 0; // use all available CPUs
shdb.AddDirectory(argv[2], ncpu, *tracer);
return 0;
}
Download code