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 
22  bool MatchValences = false;
23  bool MatchChiralTag = false;
24  bool MatchFormalCharge = false;
25  bool RingMatchesRingOnly = false;
26 };
27 
29  bool RingMatchesRingOnly = false;
30  bool CompleteRingsOnly = false;
31  bool MatchFusedRings = false;
32  bool MatchFusedRingsStrict = false;
33  bool MatchStereo = false;
34 };
35 
37  const short unsigned c1[], const short unsigned c2[], const ROMol& mol1,
38  const FMCS::Graph& query, const ROMol& mol2, const FMCS::Graph& target,
39  const MCSParameters* p);
41  const ROMol& mol1, unsigned int atom1,
42  const ROMol& mol2, unsigned int atom2,
43  void* userData);
45  const ROMol& mol1, unsigned int bond1,
46  const ROMol& mol2, unsigned int bond2,
47  void* userData);
48 
49 // Some predefined functors:
51  const ROMol& mol1, unsigned int atom1,
52  const ROMol& mol2, unsigned int atom2,
53  void* userData);
55  const ROMol& mol1, unsigned int atom1,
56  const ROMol& mol2, unsigned int atom2,
57  void* userData);
58 
60  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
61  const ROMol& mol2, unsigned int atom2, void* userData);
63  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
64  const ROMol& mol2, unsigned int atom2, void* userData);
65 
67  const ROMol& mol1, unsigned int bond1,
68  const ROMol& mol2, unsigned int bond2,
69  void* userData);
71  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
72  const ROMol& mol2, unsigned int bond2,
73  void* userData); // ignore Aromatization
75  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
76  const ROMol& mol2, unsigned int bond2, void* userData);
77 
79  unsigned NumAtoms;
80  unsigned NumBonds;
81  unsigned SeedProcessed;
82 
83  public:
84  MCSProgressData() : NumAtoms(0), NumBonds(0), SeedProcessed(0) {}
85 };
86 
87 typedef bool (*MCSProgressCallback)(const MCSProgressData& stat,
88  const MCSParameters& params,
89  void* userData);
91  const MCSParameters& params,
92  void* userData);
93 
95  bool MaximizeBonds = true;
96  double Threshold = 1.0; // match all molecules
97  unsigned Timeout = -1; // in seconds
98  bool Verbose = false;
103  void* CompareFunctionsUserData = nullptr;
104  MCSProgressCallback ProgressCallback =
105  nullptr; // return false to interrupt execution
106  void* ProgressCallbackUserData = nullptr;
107  MCSFinalMatchCheckFunction FinalMatchChecker =
108  nullptr; // FinalMatchCheckFunction() to check chirality and ring fusion
109  std::string InitialSeed = ""; // user defined or empty string (default)
110 };
111 
113  unsigned NumAtoms;
114  unsigned NumBonds;
115  std::string SmartsString;
116  bool Canceled; // interrupted by timeout or user defined progress callback.
117  // Contains valid current MCS !
118  public:
119  MCSResult() : NumAtoms(0), NumBonds(0), Canceled(false) {}
120  bool isCompleted() const { return !Canceled; }
121 };
122 
123 RDKIT_FMCS_EXPORT void parseMCSParametersJSON(const char* json,
124  MCSParameters* params);
125 
126 RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols,
127  const MCSParameters* params = 0);
128 RDKIT_FMCS_EXPORT MCSResult findMCS_P(const std::vector<ROMOL_SPTR>& mols,
129  const char* params_json);
130 
131 typedef enum {
137 typedef enum {
142 typedef enum {
147 RDKIT_FMCS_EXPORT MCSResult
148 findMCS(const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds,
149  double threshold, unsigned timeout, bool verbose,
150  bool matchValences, bool ringMatchesRingOnly,
151  bool completeRingsOnly, bool matchChiralTag,
152  AtomComparator atomComp,
153  BondComparator bondComp,
154  RingComparator ringComp);
155 RDKIT_FMCS_EXPORT MCSResult
156 findMCS(const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds,
157  double threshold = 1.0, unsigned timeout = 3600, bool verbose = false,
158  bool matchValences = false, bool ringMatchesRingOnly = false,
159  bool completeRingsOnly = false, bool matchChiralTag = false,
161  BondComparator bondComp = BondCompareOrder);
162 
163 } // 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:99
RDKit::MCSResult::MCSResult
MCSResult()
Definition: FMCS.h:119
RDKit::MCSResult::Canceled
bool Canceled
Definition: FMCS.h:116
RDKit::MCSProgressData::NumAtoms
unsigned NumAtoms
Definition: FMCS.h:79
RDKit::MCSParameters
Definition: FMCS.h:94
RDKit::MCSResult::NumBonds
unsigned NumBonds
Definition: FMCS.h:114
RDKit::MCSProgressCallbackTimeout
RDKIT_FMCS_EXPORT bool MCSProgressCallbackTimeout(const MCSProgressData &stat, const MCSParameters &params, void *userData)
RDKit::BondCompareAny
@ BondCompareAny
Definition: FMCS.h:138
RDKit::MCSProgressData::NumBonds
unsigned NumBonds
Definition: FMCS.h:80
RDKit::PermissiveRingFusion
@ PermissiveRingFusion
Definition: FMCS.h:144
RDKit::AtomCompareElements
@ AtomCompareElements
Definition: FMCS.h:133
RDKit::MCSResult
Definition: FMCS.h:112
RDKit::parseMCSParametersJSON
RDKIT_FMCS_EXPORT void parseMCSParametersJSON(const char *json, MCSParameters *params)
RDKit::MCSProgressData::MCSProgressData
MCSProgressData()
Definition: FMCS.h:84
RDKit::MCSAtomCompareFunction
bool(* MCSAtomCompareFunction)(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
Definition: FMCS.h:40
RDKit::AtomCompareAny
@ AtomCompareAny
Definition: FMCS.h:132
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::MCSProgressData::SeedProcessed
unsigned SeedProcessed
Definition: FMCS.h:81
RDKit::MCSAtomCompareParameters
Definition: FMCS.h:21
RDKit::MCSBondCompareParameters
Definition: FMCS.h:28
RDKit::BondCompareOrderExact
@ BondCompareOrderExact
Definition: FMCS.h:140
RDKit::MCSResult::isCompleted
bool isCompleted() const
Definition: FMCS.h:120
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::MCSBondCompareFunction
bool(* MCSBondCompareFunction)(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
Definition: FMCS.h:44
RDKit::IgnoreRingFusion
@ IgnoreRingFusion
Definition: FMCS.h:143
RDKit::BondComparator
BondComparator
Definition: FMCS.h:137
RDKit::MCSParameters::BondCompareParameters
MCSBondCompareParameters BondCompareParameters
Definition: FMCS.h:100
RDKit::AtomComparator
AtomComparator
Definition: FMCS.h:131
RDKit::StrictRingFusion
@ StrictRingFusion
Definition: FMCS.h:145
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:139
RDKit::MCSProgressCallback
bool(* MCSProgressCallback)(const MCSProgressData &stat, const MCSParameters &params, void *userData)
Definition: FMCS.h:87
RDKit::AtomCompareIsotopes
@ AtomCompareIsotopes
Definition: FMCS.h:134
RDKit::MCSResult::NumAtoms
unsigned NumAtoms
Definition: FMCS.h:113
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::RingComparator
RingComparator
Definition: FMCS.h:142
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:115
RDKit::MCSFinalMatchCheckFunction
bool(* MCSFinalMatchCheckFunction)(const short unsigned c1[], const short unsigned c2[], const ROMol &mol1, const FMCS::Graph &query, const ROMol &mol2, const FMCS::Graph &target, const MCSParameters *p)
Definition: FMCS.h:36
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:135
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::MCSProgressData
Definition: FMCS.h:78
RDKit::findMCS
RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector< ROMOL_SPTR > &mols, const MCSParameters *params=0)
export.h