RDKit
Open-source cheminformatics and machine learning.
SubstructMatch.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2017 Greg Landrum and Rational Discovery LLC
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 #ifndef RD_SUBSTRUCTMATCH_H
11 #define RD_SUBSTRUCTMATCH_H
12 
13 // std bits
14 #include <vector>
15 
16 namespace RDKit {
17 class ROMol;
18 class Atom;
19 class Bond;
20 class ResonanceMolSupplier;
21 class MolBundle;
22 
23 //! \brief used to return matches from substructure searching,
24 //! The format is (queryAtomIdx, molAtomIdx)
25 typedef std::vector<std::pair<int, int> > MatchVectType;
26 
27 //! Find a substructure match for a query in a molecule
28 /*!
29  \param mol The ROMol to be searched
30  \param query The query ROMol
31  \param matchVect Used to return the match
32  (pre-existing contents will be deleted)
33  \param recursionPossible flags whether or not recursive matches are allowed
34  \param useChirality use atomic CIP codes as part of the comparison
35  \param useQueryQueryMatches if set, the contents of atom and bond queries
36  will be used as part of the matching
37 
38  \return whether or not a match was found
39 
40 */
41 bool SubstructMatch(const ROMol &mol, const ROMol &query,
42  MatchVectType &matchVect, bool recursionPossible = true,
43  bool useChirality = false,
44  bool useQueryQueryMatches = false);
45 
46 //! Find a substructure match for a query in a ResonanceMolSupplier object
47 /*!
48  \param resMolSuppl The ResonanceMolSupplier object to be searched
49  \param query The query ROMol
50  \param matchVect Used to return the match
51  (pre-existing contents will be deleted)
52  \param recursionPossible flags whether or not recursive matches are allowed
53  \param useChirality use atomic CIP codes as part of the comparison
54  \param useQueryQueryMatches if set, the contents of atom and bond queries
55  will be used as part of the matching
56 
57  \return whether or not a match was found
58 
59 */
60 bool SubstructMatch(ResonanceMolSupplier &resMolSuppl, const ROMol &query,
61  MatchVectType &matchVect, bool recursionPossible = true,
62  bool useChirality = false,
63  bool useQueryQueryMatches = false);
64 
65 //! Find all substructure matches for a query in a molecule
66 /*!
67  \param mol The ROMol to be searched
68  \param query The query ROMol
69  \param matchVect Used to return the matches
70  (pre-existing contents will be deleted)
71  \param uniquify Toggles uniquification (by atom index) of the results
72  \param recursionPossible flags whether or not recursive matches are allowed
73  \param useChirality use atomic CIP codes as part of the comparison
74  \param useQueryQueryMatches if set, the contents of atom and bond queries
75  will be used as part of the matching
76  \param maxMatches The maximum number of matches that will be returned.
77  In high-symmetry cases with medium-sized molecules, it is
78  very
79  easy to end up with a combinatorial explosion in the
80  number of
81  possible matches. This argument prevents that from having
82  unintended consequences
83 
84  \return the number of matches found
85 
86 */
87 unsigned int SubstructMatch(const ROMol &mol, const ROMol &query,
88  std::vector<MatchVectType> &matchVect,
89  bool uniquify = true, bool recursionPossible = true,
90  bool useChirality = false,
91  bool useQueryQueryMatches = false,
92  unsigned int maxMatches = 1000);
93 
94 //! Find all substructure matches for a query in a ResonanceMolSupplier object
95 /*!
96  \param resMolSuppl The ResonanceMolSupplier object to be searched
97  \param query The query ROMol
98  \param matchVect Used to return the matches
99  (pre-existing contents will be deleted)
100  \param uniquify Toggles uniquification (by atom index) of the results
101  \param recursionPossible flags whether or not recursive matches are allowed
102  \param useChirality use atomic CIP codes as part of the comparison
103  \param useQueryQueryMatches if set, the contents of atom and bond queries
104  will be used as part of the matching
105  \param maxMatches The maximum number of matches that will be returned.
106  In high-symmetry cases with medium-sized molecules, it is
107  very
108  easy to end up with a combinatorial explosion in the
109  number of
110  possible matches. This argument prevents that from having
111  unintended consequences
112  \param numThreads The number of threads used during the search
113  (defaults to 1; 0 selects the number of
114  concurrent threads supported by the hardware;
115  negative values are added to the number of
116  concurrent threads supported by the
117  hardware)
118 
119  \return the number of matches found
120 
121 */
122 unsigned int SubstructMatch(ResonanceMolSupplier &resMolSuppl,
123  const ROMol &query,
124  std::vector<MatchVectType> &matchVect,
125  bool uniquify = false,
126  bool recursionPossible = true,
127  bool useChirality = false,
128  bool useQueryQueryMatches = false,
129  unsigned int maxMatches = 1000, int numThreads = 1);
130 
131 //! \overload
132 //! finds the first match in the bundle
133 bool SubstructMatch(const MolBundle &bundle, const ROMol &query,
134  MatchVectType &matchVect, bool recursionPossible = true,
135  bool useChirality = false,
136  bool useQueryQueryMatches = false);
137 //! \overload
138 //! finds the first match in the bundle
139 bool SubstructMatch(const ROMol &bundle, const MolBundle &query,
140  MatchVectType &matchVect, bool recursionPossible = true,
141  bool useChirality = false,
142  bool useQueryQueryMatches = false);
143 //! \overload
144 //! finds the first match in the bundle
145 bool SubstructMatch(const MolBundle &bundle, const MolBundle &query,
146  MatchVectType &matchVect, bool recursionPossible = true,
147  bool useChirality = false,
148  bool useQueryQueryMatches = false);
149 //! \overload
150 //! finds all matches in the first molecule of the bundle that matches the query
151 unsigned int SubstructMatch(const MolBundle &mol, const ROMol &query,
152  std::vector<MatchVectType> &matchVect,
153  bool uniquify = true, bool recursionPossible = true,
154  bool useChirality = false,
155  bool useQueryQueryMatches = false,
156  unsigned int maxMatches = 1000);
157 
158 //! \overload
159 //! finds all matches in the first molecule of the bundle that matches
160 unsigned int SubstructMatch(const MolBundle &mol, const MolBundle &query,
161  std::vector<MatchVectType> &matchVect,
162  bool uniquify = true, bool recursionPossible = true,
163  bool useChirality = false,
164  bool useQueryQueryMatches = false,
165  unsigned int maxMatches = 1000);
166 //! \overload
167 //! finds all matches against the first molecule of the query bundle that
168 //! matches
169 unsigned int SubstructMatch(const ROMol &mol, const MolBundle &query,
170  std::vector<MatchVectType> &matchVect,
171  bool uniquify = true, bool recursionPossible = true,
172  bool useChirality = false,
173  bool useQueryQueryMatches = false,
174  unsigned int maxMatches = 1000);
175 }
176 
177 #endif
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx) ...
bool SubstructMatch(const ROMol &mol, const ROMol &query, MatchVectType &matchVect, bool recursionPossible=true, bool useChirality=false, bool useQueryQueryMatches=false)
Find a substructure match for a query in a molecule.
Std stuff.
Definition: Atom.h:29