RDKit
Open-source cheminformatics and machine learning.
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 
18 namespace RDKit {
19 struct MCSParameters;
20 
21 typedef enum {
27 
28 typedef enum {
33 
34 typedef enum {
39 
41  bool MatchValences = false;
42  bool MatchChiralTag = false;
43  bool MatchFormalCharge = false;
44  bool RingMatchesRingOnly = false;
45  bool MatchIsotope = false;
46 };
47 
49  bool RingMatchesRingOnly = false;
50  bool CompleteRingsOnly = false;
51  bool MatchFusedRings = false;
52  bool MatchFusedRingsStrict = false;
53  bool MatchStereo = false;
54 };
55 
57  const std::uint32_t c1[], const std::uint32_t c2[], const ROMol& mol1,
58  const FMCS::Graph& query, const ROMol& mol2, const FMCS::Graph& target,
59  const MCSParameters* p);
61  const ROMol& mol1, unsigned int atom1,
62  const ROMol& mol2, unsigned int atom2,
63  void* userData);
65  const ROMol& mol1, unsigned int bond1,
66  const ROMol& mol2, unsigned int bond2,
67  void* userData);
68 
69 // Some predefined functors:
71  const ROMol& mol1, unsigned int atom1,
72  const ROMol& mol2,
73  unsigned int atom2);
75  const ROMol& mol1, unsigned int atom1,
76  const ROMol& mol2, unsigned int atom2);
78  const ROMol& mol1, unsigned int atom1,
79  const ROMol& mol2,
80  unsigned int atom2);
81 
83  const ROMol& mol1, unsigned int atom1,
84  const ROMol& mol2, unsigned int atom2,
85  void* userData);
87  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
88  const ROMol& mol2, unsigned int atom2, void* userData);
89 
91  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
92  const ROMol& mol2, unsigned int atom2, void* userData);
94  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
95  const ROMol& mol2, unsigned int atom2, void* userData);
96 
98  const ROMol& mol1, unsigned int bond1,
99  const ROMol& mol2, unsigned int bond2);
101  const ROMol& mol1, unsigned int bond1,
102  const ROMol& mol2, unsigned int bond2,
103  void* v_ringMatchMatrixSet);
104 
106  const ROMol& mol1, unsigned int bond1,
107  const ROMol& mol2, unsigned int bond2,
108  void* userData);
110  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
111  const ROMol& mol2, unsigned int bond2,
112  void* userData); // ignore Aromatization
114  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
115  const ROMol& mol2, unsigned int bond2, void* userData);
116 
118  unsigned NumAtoms{0};
119  unsigned NumBonds{0};
120  unsigned SeedProcessed{0};
121 
122  public:
124 };
125 
126 typedef bool (*MCSProgressCallback)(const MCSProgressData& stat,
127  const MCSParameters& params,
128  void* userData);
130  const MCSParameters& params,
131  void* userData);
132 
134  bool MaximizeBonds = true;
135  double Threshold = 1.0; // match all molecules
136  unsigned Timeout = -1; // in seconds
137  bool Verbose = false;
142  void* CompareFunctionsUserData = nullptr;
143  MCSProgressCallback ProgressCallback =
144  nullptr; // return false to interrupt execution
145  void* ProgressCallbackUserData = nullptr;
146  MCSFinalMatchCheckFunction FinalMatchChecker =
147  nullptr; // FinalMatchCheckFunction() to check chirality and ring fusion
148  std::string InitialSeed = ""; // user defined or empty string (default)
150  void setMCSAtomTyperFromConstChar(const char* atomComp);
152  void setMCSBondTyperFromConstChar(const char* bondComp);
153 };
154 
156  unsigned NumAtoms{0};
157  unsigned NumBonds{0};
158  std::string SmartsString;
159  bool Canceled{false}; // interrupted by timeout or user defined progress
160  // callback. Contains valid current MCS !
162 
163  public:
165  bool isCompleted() const { return !Canceled; }
166 };
167 
169  MCSParameters* params);
170 
171 RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols,
172  const MCSParameters* params = nullptr);
173 RDKIT_FMCS_EXPORT MCSResult findMCS_P(const std::vector<ROMOL_SPTR>& mols,
174  const char* params_json);
175 
177  const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds, double threshold,
178  unsigned timeout, bool verbose, bool matchValences,
179  bool ringMatchesRingOnly, bool completeRingsOnly, bool matchChiralTag,
180  AtomComparator atomComp, BondComparator bondComp, RingComparator ringComp);
182 findMCS(const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds,
183  double threshold = 1.0, unsigned timeout = 3600, bool verbose = false,
184  bool matchValences = false, bool ringMatchesRingOnly = false,
185  bool completeRingsOnly = false, bool matchChiralTag = false,
187  BondComparator bondComp = BondCompareOrder);
188 
189 } // namespace RDKit
#define RDKIT_FMCS_EXPORT
Definition: export.h:242
Std stuff.
Definition: Abbreviations.h:17
bool(* MCSAtomCompareFunction)(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
Definition: FMCS.h:60
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:21
@ AtomCompareElements
Definition: FMCS.h:23
@ AtomCompareAnyHeavyAtom
Definition: FMCS.h:25
@ AtomCompareAny
Definition: FMCS.h:22
@ AtomCompareIsotopes
Definition: FMCS.h:24
BondComparator
Definition: FMCS.h:28
@ BondCompareOrderExact
Definition: FMCS.h:31
@ BondCompareAny
Definition: FMCS.h:29
@ BondCompareOrder
Definition: FMCS.h:30
RDKIT_FMCS_EXPORT bool MCSAtomCompareElements(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
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)
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)
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:34
@ StrictRingFusion
Definition: FMCS.h:37
@ IgnoreRingFusion
Definition: FMCS.h:35
@ PermissiveRingFusion
Definition: FMCS.h:36
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)
RDKIT_FMCS_EXPORT bool checkBondRingMatch(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *v_ringMatchMatrixSet)
boost::shared_ptr< ROMol > ROMOL_SPTR
bool(* MCSBondCompareFunction)(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
Definition: FMCS.h:64
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:126
RDKIT_FMCS_EXPORT bool MCSProgressCallbackTimeout(const MCSProgressData &stat, const MCSParameters &params, void *userData)
bool(* MCSFinalMatchCheckFunction)(const std::uint32_t c1[], const std::uint32_t c2[], const ROMol &mol1, const FMCS::Graph &query, const ROMol &mol2, const FMCS::Graph &target, const MCSParameters *p)
Definition: FMCS.h:56
RDKIT_FMCS_EXPORT bool MCSBondCompareOrderExact(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
void setMCSBondTyperFromEnum(BondComparator bondComp)
void setMCSBondTyperFromConstChar(const char *bondComp)
void setMCSAtomTyperFromConstChar(const char *atomComp)
void setMCSAtomTyperFromEnum(AtomComparator atomComp)
MCSAtomCompareParameters AtomCompareParameters
Definition: FMCS.h:138
MCSBondCompareParameters BondCompareParameters
Definition: FMCS.h:139
ROMOL_SPTR QueryMol
Definition: FMCS.h:161
std::string SmartsString
Definition: FMCS.h:158
bool isCompleted() const
Definition: FMCS.h:165