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 <boost/random.hpp>
19
20#include <RDGeneral/export.h>
23
24namespace RDKit {
25class ROMol;
26
27namespace SynthonSpaceSearch {
28
30 public:
33 const SynthonSpaceSearchParams &params,
35 : d_query(query), d_params(params), d_space(space) {}
40
41 virtual ~SynthonSpaceSearcher() = default;
42
44
45 SynthonSpace &getSpace() const { return d_space; }
46 const ROMol &getQuery() const { return d_query; }
47 const SynthonSpaceSearchParams &getParams() const { return d_params; }
48
49 private:
50 std::unique_ptr<boost::mt19937> d_randGen;
51
52 const ROMol &d_query;
53 const SynthonSpaceSearchParams &d_params;
54 SynthonSpace &d_space;
55
56 // Do the search of this fragSet against the SynthonSpace in the
57 // appropriate way, for example by substructure or fingerprint
58 // similarity.
59 virtual std::vector<SynthonSpaceHitSet> searchFragSet(
60 std::vector<std::unique_ptr<ROMol>> &fragSet) const = 0;
61 // Make the hit, constructed from a specific combination of
62 // synthons in the SynthonSet, and verify that it matches the
63 // query in the appropriate way. There'll be 1 entry in synthNums
64 // for each synthon list in the reaction. Returns an empty pointer
65 // if the hit isn't accepted for whatever reason.
66 std::unique_ptr<ROMol> buildAndVerifyHit(
67 const std::unique_ptr<SynthonSet> &reaction,
68 const std::vector<size_t> &synthNums,
69 std::set<std::string> &resultsNames) const;
70 virtual bool verifyHit(const ROMol &mol) const = 0;
71
72 // Build the molecules from the synthons identified in reagentsToUse.
73 // There should be bitset in reagentsToUse for each reagent set.
74 // If not, it will fail. Checks that all the results produced match the
75 // query. totHits is the maximum number of hits that are possible from
76 // the hitsets, including duplicates. Duplicates by name are not returned,
77 // but duplicate SMILES from different reactions will be. Hitsets will
78 // be re-ordered on exit.
79 void buildHits(std::vector<SynthonSpaceHitSet> &hitsets, size_t totHits,
80 std::vector<std::unique_ptr<ROMol>> &results) const;
81 void buildAllHits(const std::vector<SynthonSpaceHitSet> &hitsets,
82 std::set<std::string> &resultsNames,
83 std::vector<std::unique_ptr<ROMol>> &results) const;
84 void buildRandomHits(const std::vector<SynthonSpaceHitSet> &hitsets,
85 size_t totHits, std::set<std::string> &resultsNames,
86 std::vector<std::unique_ptr<ROMol>> &results) const;
87 // get the subset of synthons for the given reaction to use for this
88 // enumeration.
89 std::vector<std::vector<ROMol *>> getSynthonsToUse(
90 const std::vector<boost::dynamic_bitset<>> &synthonsToUse,
91 const std::string &reaction_id) const;
92};
93
94} // namespace SynthonSpaceSearch
95} // namespace RDKit
96#endif // SYNTHONSPACESEARCHER_H
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)