RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
FMCS.h
Go to the documentation of this file.
1//
2// Copyright (C) 2014 Novartis Institutes for BioMedical Research
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#pragma once
12#include <vector>
13#include <string>
14#include <stdexcept>
15#include "../RDKitBase.h"
16#include "Graph.h"
17
18namespace RDKit {
19
20struct MCSParameters;
21
28
34
40
42 bool MatchValences = false;
43 bool MatchChiralTag = false;
44 bool MatchFormalCharge = false;
45 bool RingMatchesRingOnly = false;
46 bool CompleteRingsOnly = false;
47 bool MatchIsotope = false;
48 double MaxDistance = -1.0;
49};
50
52 bool RingMatchesRingOnly = false;
53 bool CompleteRingsOnly = false;
54 bool MatchFusedRings = false;
55 bool MatchFusedRingsStrict = false;
56 bool MatchStereo = false;
57};
58
60 const ROMol&, unsigned int, const ROMol&,
61 unsigned int, void*);
63 const ROMol&, unsigned int, const ROMol&,
64 unsigned int, void*);
65typedef bool (*MCSAcceptanceFunction)(const ROMol&, const ROMol&,
66 const std::vector<std::pair<int, int>>&,
67 const std::vector<std::pair<int, int>>&,
68 const MCSParameters*);
69typedef bool (*MCSFinalMatchCheckFunction)(const std::uint32_t[],
70 const std::uint32_t[], const ROMol&,
71 const FMCS::Graph&, const ROMol&,
72 const FMCS::Graph&,
73 const MCSParameters*);
74
75// Some predefined functors:
77 const ROMol& mol1, unsigned int atom1,
78 const ROMol& mol2,
79 unsigned int atom2);
81 const ROMol& mol1, unsigned int atom1,
82 const ROMol& mol2, unsigned int atom2);
84 const ROMol& mol1, unsigned int atom1,
85 const ROMol& mol2,
86 unsigned int atom2);
88 const ROMol& mol1, unsigned int atom1,
89 const ROMol& mol2, unsigned int atom2);
90
92 const ROMol& mol1, unsigned int atom1,
93 const ROMol& mol2, unsigned int atom2,
94 void* userData);
96 const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
97 const ROMol& mol2, unsigned int atom2, void* userData);
98
100 const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
101 const ROMol& mol2, unsigned int atom2, void* userData);
103 const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
104 const ROMol& mol2, unsigned int atom2, void* userData);
105
107 const ROMol& mol1, unsigned int bond1,
108 const ROMol& mol2, unsigned int bond2);
109
111 const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
112 const ROMol& mol2, unsigned int bond2);
113
115 const ROMol& mol1, unsigned int bond1,
116 const ROMol& mol2,
117 unsigned int bond2);
118
120 const ROMol& mol1, unsigned int bond1,
121 const ROMol& mol2, unsigned int bond2,
122 void* userData);
124 const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
125 const ROMol& mol2, unsigned int bond2,
126 void* userData); // ignore Aromatization
128 const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
129 const ROMol& mol2, unsigned int bond2, void* userData);
130
132 unsigned int NumAtoms{0};
133 unsigned int NumBonds{0};
134 unsigned int SeedProcessed{0};
135
136 public:
138};
139
141 const MCSParameters& params,
142 void* userData);
144 const MCSParameters& params,
145 void* userData);
146
150 if (other) {
151 *this = *other;
152 }
153 }
154 MCSParameters(const MCSParameters& other) = default;
155 MCSParameters& operator=(const MCSParameters& other) = default;
156 virtual ~MCSParameters() {}
157 bool StoreAll = false;
158 bool MaximizeBonds = true;
159 double Threshold = 1.0; // match all molecules
160 unsigned int Timeout = 0; // in seconds
161 bool Verbose = false;
166 void* CompareFunctionsUserData = nullptr;
167 MCSProgressCallback ProgressCallback =
168 nullptr; // return false to interrupt execution
169 void* ProgressCallbackUserData = nullptr;
170 // FinalMatchCheckFunction() to accept/reject a growing MCS candidate based on
171 // user-defined criteria
172 MCSFinalMatchCheckFunction FinalMatchChecker = nullptr;
173 void* FinalMatchCheckerUserData = nullptr;
174 // ShouldAcceptMCS() to accept/reject a fully-grown MCS candidate based on
175 // user-defined criteria
176 MCSAcceptanceFunction ShouldAcceptMCS = nullptr;
177 void* ShouldAcceptMCSUserData = nullptr;
178 std::string InitialSeed = ""; // user defined or empty string (default)
180 void setMCSAtomTyperFromConstChar(const char* atomComp);
182 void setMCSBondTyperFromConstChar(const char* bondComp);
183};
184
193
195 unsigned int NumAtoms{0};
196 unsigned int NumBonds{0};
197 std::string SmartsString;
198 bool Canceled{false}; // interrupted by timeout or user defined progress
199 // callback. Contains valid current MCS !
201 std::map<std::string, ROMOL_SPTR> DegenerateSmartsQueryMolDict;
202
203 public:
205 bool isCompleted() const { return !Canceled; }
206};
207
209 MCSParameters* params);
210
211RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols,
212 const MCSParameters* params = nullptr);
213RDKIT_FMCS_EXPORT MCSResult findMCS_P(const std::vector<ROMOL_SPTR>& mols,
214 const char* params_json);
215
217 const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds, double threshold,
218 unsigned int timeout, bool verbose, bool matchValences,
219 bool ringMatchesRingOnly, bool completeRingsOnly, bool matchChiralTag,
222 const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds,
223 double threshold = 1.0, unsigned int timeout = 3600, bool verbose = false,
224 bool matchValences = false, bool ringMatchesRingOnly = false,
225 bool completeRingsOnly = false, bool matchChiralTag = false,
228
229} // namespace RDKit
pulls in the core RDKit functionality
#define RDKIT_FMCS_EXPORT
Definition export.h:153
Std stuff.
RDKIT_FMCS_EXPORT MCSResult findMCS_P(const std::vector< ROMOL_SPTR > &mols, const char *params_json)
RDKIT_FMCS_EXPORT bool MCSAtomCompareAnyHeavyAtom(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
AtomComparator
Definition FMCS.h:22
@ AtomCompareElements
Definition FMCS.h:24
@ AtomCompareAnyHeavyAtom
Definition FMCS.h:26
@ AtomCompareAny
Definition FMCS.h:23
@ AtomCompareIsotopes
Definition FMCS.h:25
bool rdvalue_is(const RDValue_cast_t)
BondComparator
Definition FMCS.h:29
@ BondCompareOrderExact
Definition FMCS.h:32
@ BondCompareAny
Definition FMCS.h:30
@ BondCompareOrder
Definition FMCS.h:31
RDKIT_FMCS_EXPORT bool checkBondRingMatch(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2)
RDKIT_FMCS_EXPORT bool MCSAtomCompareElements(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
bool(* MCSFinalMatchCheckFunction)(const std::uint32_t[], const std::uint32_t[], const ROMol &, const FMCS::Graph &, const ROMol &, const FMCS::Graph &, const MCSParameters *)
Definition FMCS.h:69
RDKIT_FMCS_EXPORT bool checkAtomDistance(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2)
RDKIT_FMCS_EXPORT bool checkBondStereo(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2)
RDKIT_FMCS_EXPORT void parseMCSParametersJSON(const char *json, MCSParameters *params)
bool(* MCSBondCompareFunction)(const MCSBondCompareParameters &, const ROMol &, unsigned int, const ROMol &, unsigned int, void *)
Definition FMCS.h:62
RDKIT_FMCS_EXPORT bool MCSBondCompareAny(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector< ROMOL_SPTR > &mols, const MCSParameters *params=nullptr)
RDKIT_FMCS_EXPORT bool MCSAtomCompareAny(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
bool(* MCSAtomCompareFunction)(const MCSAtomCompareParameters &, const ROMol &, unsigned int, const ROMol &, unsigned int, void *)
Definition FMCS.h:59
RDKIT_FMCS_EXPORT bool MCSBondCompareOrder(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
RDKIT_FMCS_EXPORT bool checkAtomRingMatch(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2)
RingComparator
Definition FMCS.h:35
@ StrictRingFusion
Definition FMCS.h:38
@ IgnoreRingFusion
Definition FMCS.h:36
@ PermissiveRingFusion
Definition FMCS.h:37
RDKIT_FMCS_EXPORT bool checkAtomCharge(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2)
RDKIT_FMCS_EXPORT bool MCSAtomCompareIsotopes(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
boost::shared_ptr< ROMol > ROMOL_SPTR
RDKIT_FMCS_EXPORT bool havePairOfCompatibleRings(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2)
RDKIT_FMCS_EXPORT bool checkAtomChirality(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2)
bool(* MCSProgressCallback)(const MCSProgressData &stat, const MCSParameters &params, void *userData)
Definition FMCS.h:140
RDKIT_FMCS_EXPORT bool MCSProgressCallbackTimeout(const MCSProgressData &stat, const MCSParameters &params, void *userData)
bool(* MCSAcceptanceFunction)(const ROMol &, const ROMol &, const std::vector< std::pair< int, int > > &, const std::vector< std::pair< int, int > > &, const MCSParameters *)
Definition FMCS.h:65
RDKIT_FMCS_EXPORT bool MCSBondCompareOrderExact(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
MCSParameters(const MCSParameters *other)
Definition FMCS.h:149
void setMCSBondTyperFromEnum(BondComparator bondComp)
void setMCSBondTyperFromConstChar(const char *bondComp)
virtual ~MCSParameters()
Definition FMCS.h:156
MCSParameters(const MCSParameters &other)=default
MCSParameters & operator=(const MCSParameters &other)=default
void setMCSAtomTyperFromConstChar(const char *atomComp)
void setMCSAtomTyperFromEnum(AtomComparator atomComp)
MCSAtomCompareParameters AtomCompareParameters
Definition FMCS.h:162
MCSBondCompareParameters BondCompareParameters
Definition FMCS.h:163
ROMOL_SPTR QueryMol
Definition FMCS.h:200
std::string SmartsString
Definition FMCS.h:197
std::map< std::string, ROMOL_SPTR > DegenerateSmartsQueryMolDict
Definition FMCS.h:201
bool isCompleted() const
Definition FMCS.h:205
MCSParametersInternal(const MCSParameters *params)
MCSFinalMatchCheckFunction UserFinalMatchChecker
Definition FMCS.h:190