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, unsigned int atom2);
74  const ROMol& mol1, unsigned int atom1,
75  const ROMol& mol2, unsigned int atom2);
77  const ROMol& mol1, unsigned int atom1,
78  const ROMol& mol2, unsigned int atom2);
79 
81  const ROMol& mol1, unsigned int atom1,
82  const ROMol& mol2, unsigned int atom2,
83  void* userData);
85  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
86  const ROMol& mol2, unsigned int atom2, void* userData);
87 
89  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
90  const ROMol& mol2, unsigned int atom2, void* userData);
92  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
93  const ROMol& mol2, unsigned int atom2, void* userData);
94 
96  const ROMol& mol1, unsigned int bond1,
97  const ROMol& mol2, unsigned int bond2);
99  const ROMol& mol1, unsigned int bond1,
100  const ROMol& mol2, unsigned int bond2,
101  void* v_ringMatchMatrixSet);
102 
104  const ROMol& mol1, unsigned int bond1,
105  const ROMol& mol2, unsigned int bond2,
106  void* userData);
108  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
109  const ROMol& mol2, unsigned int bond2,
110  void* userData); // ignore Aromatization
112  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
113  const ROMol& mol2, unsigned int bond2, void* userData);
114 
116  unsigned NumAtoms;
117  unsigned NumBonds;
118  unsigned SeedProcessed;
119 
120  public:
121  MCSProgressData() : NumAtoms(0), NumBonds(0), SeedProcessed(0) {}
122 };
123 
124 typedef bool (*MCSProgressCallback)(const MCSProgressData& stat,
125  const MCSParameters& params,
126  void* userData);
128  const MCSParameters& params,
129  void* userData);
130 
132  bool MaximizeBonds = true;
133  double Threshold = 1.0; // match all molecules
134  unsigned Timeout = -1; // in seconds
135  bool Verbose = false;
140  void* CompareFunctionsUserData = nullptr;
141  MCSProgressCallback ProgressCallback =
142  nullptr; // return false to interrupt execution
143  void* ProgressCallbackUserData = nullptr;
144  MCSFinalMatchCheckFunction FinalMatchChecker =
145  nullptr; // FinalMatchCheckFunction() to check chirality and ring fusion
146  std::string InitialSeed = ""; // user defined or empty string (default)
148  void setMCSAtomTyperFromConstChar(const char *atomComp);
150  void setMCSBondTyperFromConstChar(const char *bondComp);
151 };
152 
154  unsigned NumAtoms;
155  unsigned NumBonds;
156  std::string SmartsString;
157  bool Canceled; // interrupted by timeout or user defined progress callback.
158  // Contains valid current MCS !
160 
161  public:
162  MCSResult() : NumAtoms(0), NumBonds(0), Canceled(false) {}
163  bool isCompleted() const { return !Canceled; }
164 };
165 
167  MCSParameters* params);
168 
169 RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols,
170  const MCSParameters* params = 0);
171 RDKIT_FMCS_EXPORT MCSResult findMCS_P(const std::vector<ROMOL_SPTR>& mols,
172  const char* params_json);
173 
175  const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds, double threshold,
176  unsigned timeout, bool verbose, bool matchValences,
177  bool ringMatchesRingOnly, bool completeRingsOnly, bool matchChiralTag,
178  AtomComparator atomComp, BondComparator bondComp, RingComparator ringComp);
180 findMCS(const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds,
181  double threshold = 1.0, unsigned timeout = 3600, bool verbose = false,
182  bool matchValences = false, bool ringMatchesRingOnly = false,
183  bool completeRingsOnly = false, bool matchChiralTag = false,
185  BondComparator bondComp = BondCompareOrder);
186 
187 } // namespace RDKit
RDKit::MCSBondCompareOrder
RDKIT_FMCS_EXPORT bool MCSBondCompareOrder(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
RDKit::MCSParameters::AtomCompareParameters
MCSAtomCompareParameters AtomCompareParameters
Definition: FMCS.h:136
RDKit::MCSResult::MCSResult
MCSResult()
Definition: FMCS.h:162
RDKit::MCSResult::Canceled
bool Canceled
Definition: FMCS.h:157
RDKit::MCSProgressData::NumAtoms
unsigned NumAtoms
Definition: FMCS.h:116
RDKit::MCSParameters
Definition: FMCS.h:131
RDKit::MCSResult::NumBonds
unsigned NumBonds
Definition: FMCS.h:155
RDKit::MCSProgressCallbackTimeout
RDKIT_FMCS_EXPORT bool MCSProgressCallbackTimeout(const MCSProgressData &stat, const MCSParameters &params, void *userData)
RDKit::BondCompareAny
@ BondCompareAny
Definition: FMCS.h:29
RDKit::MCSParameters::setMCSAtomTyperFromConstChar
void setMCSAtomTyperFromConstChar(const char *atomComp)
RDKit::MCSProgressData::NumBonds
unsigned NumBonds
Definition: FMCS.h:117
RDKit::PermissiveRingFusion
@ PermissiveRingFusion
Definition: FMCS.h:36
RDKit::AtomCompareElements
@ AtomCompareElements
Definition: FMCS.h:23
RDKit::MCSResult
Definition: FMCS.h:153
RDKit::parseMCSParametersJSON
RDKIT_FMCS_EXPORT void parseMCSParametersJSON(const char *json, MCSParameters *params)
RDKit::MCSProgressData::MCSProgressData
MCSProgressData()
Definition: FMCS.h:121
RDKit::MCSAtomCompareFunction
bool(* MCSAtomCompareFunction)(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
Definition: FMCS.h:60
RDKit::AtomCompareAny
@ AtomCompareAny
Definition: FMCS.h:22
RDKit::MCSAtomCompareIsotopes
RDKIT_FMCS_EXPORT bool MCSAtomCompareIsotopes(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
RDKit::MCSParameters::setMCSAtomTyperFromEnum
void setMCSAtomTyperFromEnum(AtomComparator atomComp)
RDKit::MCSResult::QueryMol
ROMOL_SPTR QueryMol
Definition: FMCS.h:159
RDKit::MCSProgressData::SeedProcessed
unsigned SeedProcessed
Definition: FMCS.h:118
RDKit::MCSAtomCompareParameters
Definition: FMCS.h:40
RDKit::MCSBondCompareParameters
Definition: FMCS.h:48
RDKit::BondCompareOrderExact
@ BondCompareOrderExact
Definition: FMCS.h:31
RDKit::MCSResult::isCompleted
bool isCompleted() const
Definition: FMCS.h:163
RDKit::checkBondStereo
RDKIT_FMCS_EXPORT bool checkBondStereo(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2)
RDKit::ROMol
Definition: ROMol.h:171
RDKit::MCSAtomCompareAnyHeavyAtom
RDKIT_FMCS_EXPORT bool MCSAtomCompareAnyHeavyAtom(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
RDKit::checkAtomRingMatch
RDKIT_FMCS_EXPORT bool checkAtomRingMatch(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2)
RDKit::MCSBondCompareFunction
bool(* MCSBondCompareFunction)(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
Definition: FMCS.h:64
RDKit::checkBondRingMatch
RDKIT_FMCS_EXPORT bool checkBondRingMatch(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *v_ringMatchMatrixSet)
RDKit::IgnoreRingFusion
@ IgnoreRingFusion
Definition: FMCS.h:35
RDKit::BondComparator
BondComparator
Definition: FMCS.h:28
RDKit::MCSParameters::BondCompareParameters
MCSBondCompareParameters BondCompareParameters
Definition: FMCS.h:137
RDKit::AtomComparator
AtomComparator
Definition: FMCS.h:21
RDKit::StrictRingFusion
@ StrictRingFusion
Definition: FMCS.h:37
RDKit::checkAtomCharge
RDKIT_FMCS_EXPORT bool checkAtomCharge(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2)
RDKit::MCSBondCompareAny
RDKIT_FMCS_EXPORT bool MCSBondCompareAny(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
RDKit::BondCompareOrder
@ BondCompareOrder
Definition: FMCS.h:30
RDKit::MCSProgressCallback
bool(* MCSProgressCallback)(const MCSProgressData &stat, const MCSParameters &params, void *userData)
Definition: FMCS.h:124
RDKit::AtomCompareIsotopes
@ AtomCompareIsotopes
Definition: FMCS.h:24
RDKit::MCSParameters::setMCSBondTyperFromConstChar
void setMCSBondTyperFromConstChar(const char *bondComp)
RDKit::MCSResult::NumAtoms
unsigned NumAtoms
Definition: FMCS.h:154
RDKit::MCSAtomCompareElements
RDKIT_FMCS_EXPORT bool MCSAtomCompareElements(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
RDKit
Std stuff.
Definition: Atom.h:30
Graph.h
RDKit::MCSParameters::setMCSBondTyperFromEnum
void setMCSBondTyperFromEnum(BondComparator bondComp)
RDKit::RingComparator
RingComparator
Definition: FMCS.h:34
RDKIT_FMCS_EXPORT
#define RDKIT_FMCS_EXPORT
Definition: export.h:203
RDKit::MCSAtomCompareAny
RDKIT_FMCS_EXPORT bool MCSAtomCompareAny(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
RDKit::FMCS::Graph
Definition: Graph.h:24
RDKit::MCSResult::SmartsString
std::string SmartsString
Definition: FMCS.h:156
RDKit::findMCS_P
RDKIT_FMCS_EXPORT MCSResult findMCS_P(const std::vector< ROMOL_SPTR > &mols, const char *params_json)
RDKit::AtomCompareAnyHeavyAtom
@ AtomCompareAnyHeavyAtom
Definition: FMCS.h:25
RDKit::MCSBondCompareOrderExact
RDKIT_FMCS_EXPORT bool MCSBondCompareOrderExact(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
RDKit::MCSFinalMatchCheckFunction
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::MCSProgressData
Definition: FMCS.h:115
RDKit::ROMOL_SPTR
boost::shared_ptr< ROMol > ROMOL_SPTR
Definition: ChemTransforms.h:22
RDKit::checkAtomChirality
RDKIT_FMCS_EXPORT bool checkAtomChirality(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2)
RDKit::findMCS
RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector< ROMOL_SPTR > &mols, const MCSParameters *params=0)
export.h