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