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
19 public:
20 explicit SearchResults() : d_maxNumResults(0) {}
21 SearchResults(std::vector<std::unique_ptr<ROMol>> &&mols, size_t maxNumRes,
22 bool timedOut, bool cancelled);
23 SearchResults(const SearchResults &other);
24 SearchResults(SearchResults &&other) = default;
25 ~SearchResults() = default;
26
29
30 /*!
31 * Returns the upper bound on the number of results the search might return.
32 * There may be fewer than this in practice for several reasons such as
33 * duplicate reagent sets being removed or the final product not matching the
34 * query even though the synthons suggested it would.
35 *
36 * @return int
37 */
38 size_t getMaxNumResults() const { return d_maxNumResults; }
39 /*!
40 * Returns the hits from the search. Not necessarily all those possible,
41 * just the maximum number requested.
42 *
43 * @return std::vector<std::unique_ptr<ROMol>>
44 */
45 const std::vector<std::unique_ptr<ROMol>> &getHitMolecules() const {
46 return d_hitMolecules;
47 }
48
49 /*!
50 * Returns whether the search timed out or not,
51 * @return bool
52 */
53 bool getTimedOut() const { return d_timedOut; }
54 /*!
55 * Returns whether the search was cancelled or not,
56 * @return bool
57 */
58 bool getCancelled() const { return d_cancelled; }
59
60 private:
61 std::vector<std::unique_ptr<ROMol>> d_hitMolecules;
62 size_t d_maxNumResults;
63 bool d_timedOut{false};
64 bool d_cancelled{false};
65};
66
67inline SearchResults::SearchResults(std::vector<std::unique_ptr<ROMol>> &&mols,
68 const size_t maxNumRes, bool timedOut,
69 bool cancelled)
70 : d_maxNumResults(maxNumRes), d_timedOut(timedOut), d_cancelled(cancelled) {
71 d_hitMolecules = std::move(mols);
72 mols.clear();
73}
74
76 : d_maxNumResults(other.d_maxNumResults),
77 d_timedOut(other.d_timedOut),
78 d_cancelled(other.d_cancelled) {
79 for (const auto &hm : other.d_hitMolecules) {
80 d_hitMolecules.emplace_back(new ROMol(*hm));
81 }
82}
83} // namespace RDKit::SynthonSpaceSearch
84
85#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 & operator=(const SearchResults &other)
SearchResults(SearchResults &&other)=default
#define RDKIT_SYNTHONSPACESEARCH_EXPORT
Definition export.h:545
bool rdvalue_is(const RDValue_cast_t)