RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
SynthonSpaceSearcher.h
Go to the documentation of this file.
1//
2// Copyright (C) David Cosgrove 2024.
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10
11// This file declares an abstract base class for searching a synthon
12// space. Concrete base classes include SynthonSpaceSubstructureSearcher
13// and SynthonSpaceFingerprintSearcher.
14
15#ifndef SYNTHONSPACESEARCHER_H
16#define SYNTHONSPACESEARCHER_H
17
18#include <chrono>
19
20#include <boost/random.hpp>
21
22#include <RDGeneral/export.h>
25
26using Clock = std::chrono::steady_clock;
27using TimePoint = std::chrono::time_point<Clock>;
28
29namespace RDKit {
30class ROMol;
31
32namespace SynthonSpaceSearch {
33
35 public:
38 const SynthonSpaceSearchParams &params,
44
45 virtual ~SynthonSpaceSearcher() = default;
46
48
49 SynthonSpace &getSpace() const { return d_space; }
50 const ROMol &getQuery() const { return d_query; }
51 const SynthonSpaceSearchParams &getParams() const { return d_params; }
52
53 private:
54 std::unique_ptr<boost::mt19937> d_randGen;
55
56 const ROMol &d_query;
57 const SynthonSpaceSearchParams &d_params;
58 SynthonSpace &d_space;
59
60 // Do the search of this fragSet against the SynthonSpace in the
61 // appropriate way, for example by substructure or fingerprint
62 // similarity.
63 virtual std::vector<SynthonSpaceHitSet> searchFragSet(
64 std::vector<std::unique_ptr<ROMol>> &fragSet) const = 0;
65 // Make the hit, constructed from a specific combination of
66 // synthons in the SynthonSet, and verify that it matches the
67 // query in the appropriate way. There'll be 1 entry in synthNums
68 // for each synthon list in the reaction. Returns an empty pointer
69 // if the hit isn't accepted for whatever reason.
70 std::unique_ptr<ROMol> buildAndVerifyHit(
71 const std::unique_ptr<SynthonSet> &reaction,
72 const std::vector<size_t> &synthNums,
73 std::set<std::string> &resultsNames) const;
74 // Some of the search methods (Rascal, for example) can do a quick
75 // check on whether this set of synthons can match the query without having to
76 // build the full molecule from the synthons. They will over-ride this
77 // function which by default passes everything.
78 virtual bool quickVerify(
79 [[maybe_unused]] const std::unique_ptr<SynthonSet> &reaction,
80 [[maybe_unused]] const std::vector<size_t> &synthNums) const {
81 return true;
82 }
83 virtual bool verifyHit(const ROMol &mol) const = 0;
84
85 // Build the molecules from the synthons identified in reagentsToUse.
86 // There should be bitset in reagentsToUse for each reagent set.
87 // If not, it will fail. Checks that all the results produced match the
88 // query. totHits is the maximum number of hits that are possible from
89 // the hitsets, including duplicates. Duplicates by name are not returned,
90 // but duplicate SMILES from different reactions will be. Hitsets will
91 // be re-ordered on exit.
92 void buildHits(std::vector<SynthonSpaceHitSet> &hitsets, size_t totHits,
93 const TimePoint *endTime, bool &timedOut,
94 std::vector<std::unique_ptr<ROMol>> &results) const;
95 void buildAllHits(const std::vector<SynthonSpaceHitSet> &hitsets,
96 std::set<std::string> &resultsNames,
97 const TimePoint *endTime, bool &timedOut,
98 std::vector<std::unique_ptr<ROMol>> &results) const;
99 void buildRandomHits(const std::vector<SynthonSpaceHitSet> &hitsets,
100 size_t totHits, std::set<std::string> &resultsNames,
101 const TimePoint *endTime, bool &timedOut,
102 std::vector<std::unique_ptr<ROMol>> &results) const;
103 // get the subset of synthons for the given reaction to use for this
104 // enumeration.
105 std::vector<std::vector<ROMol *>> getSynthonsToUse(
106 const std::vector<boost::dynamic_bitset<>> &synthonsToUse,
107 const std::string &reaction_id) const;
108};
109
110} // namespace SynthonSpaceSearch
111} // namespace RDKit
112#endif // SYNTHONSPACESEARCHER_H
std::chrono::steady_clock Clock
std::chrono::time_point< Clock > TimePoint
contains a class for searching combinatorial libraries in Synthon format such as Enamine REAL.
SynthonSpaceSearcher(const ROMol &query, const SynthonSpaceSearchParams &params, SynthonSpace &space)
SynthonSpaceSearcher(SynthonSpaceSearcher &&other)=delete
SynthonSpaceSearcher(const SynthonSpaceSearcher &other)=delete
SynthonSpaceSearcher & operator=(const SynthonSpaceSearcher &other)=delete
const SynthonSpaceSearchParams & getParams() const
SynthonSpaceSearcher & operator=(SynthonSpaceSearcher &&other)=delete
Std stuff.
bool rdvalue_is(const RDValue_cast_t)