RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
SearchResults.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#ifndef RDKIT_SYNTHONSPACE_SEARCHRESULTS_H
12#define RDKIT_SYNTHONSPACE_SEARCHRESULTS_H
13
14#include <RDGeneral/export.h>
15#include <GraphMol/ROMol.h>
16
18
19// A class holding a set of results from a search. Contains the hit
20// molecules and information about how the search progressed, whether
21// it timed out etc.
23 public:
24 explicit SearchResults() : d_maxNumResults(0) {}
25 SearchResults(std::vector<std::unique_ptr<ROMol>> &&mols, std::uint64_t maxNumRes,
26 bool timedOut, bool cancelled);
28 SearchResults(SearchResults &&other) = default;
29 ~SearchResults() = default;
30
33
34 /*!
35 * Returns the upper bound on the number of results the search might return.
36 * There may be fewer than this in practice for several reasons such as
37 * duplicate reagent sets being removed or the final product not matching the
38 * query even though the synthons suggested it would.
39 *
40 * @return int
41 */
42 std::uint64_t getMaxNumResults() const { return d_maxNumResults; }
43 /*!
44 * Returns the hit molecules from the search. Not necessarily all
45 * those possible, just the maximum number requested.
46 *
47 * @return std::vector<std::unique_ptr<ROMol>>
48 */
49 const std::vector<std::unique_ptr<ROMol>> &getHitMolecules() const {
50 return d_hitMolecules;
51 }
52
53 /*!
54 * Returns whether the search timed out or not,
55 * @return bool
56 */
57 bool getTimedOut() const { return d_timedOut; }
58 /*!
59 * Returns whether the search was cancelled or not,
60 * @return bool
61 */
62 bool getCancelled() const { return d_cancelled; }
63
64 // Merge other into this, keeping only molecules with unique
65 // names and destroying contents of other on exit.
67
68 private:
69 std::vector<std::unique_ptr<ROMol>> d_hitMolecules;
70 // Only used when merging in another set, so will be
71 // filled in then if needed, empty otherwise.
72 std::unordered_set<std::string> d_molNames;
73
74 std::uint64_t d_maxNumResults;
75 bool d_timedOut{false};
76 bool d_cancelled{false};
77};
78
79} // namespace RDKit::SynthonSpaceSearch
80
81#endif // RDKIT_SYNTHONSPACE_SEARCHRESULTS_H
Defines the primary molecule class ROMol as well as associated typedefs.
const std::vector< std::unique_ptr< ROMol > > & getHitMolecules() const
SearchResults & operator=(SearchResults &&other)=default
SearchResults(const SearchResults &other)
SearchResults & operator=(const SearchResults &other)
void mergeResults(SearchResults &other)
SearchResults(std::vector< std::unique_ptr< ROMol > > &&mols, std::uint64_t maxNumRes, bool timedOut, bool cancelled)
SearchResults(SearchResults &&other)=default
#define RDKIT_SYNTHONSPACESEARCH_EXPORT
Definition export.h:545