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 
26 
27  public:
29  : MatchValences(false),
30  MatchChiralTag(false),
31  MatchFormalCharge(false),
32  RingMatchesRingOnly(false) {}
33 };
34 
39 
40  public:
42  : RingMatchesRingOnly(false),
43  CompleteRingsOnly(false),
44  MatchStereo(false) {}
45 };
46 
48  const short unsigned c1[], const short unsigned c2[], const ROMol& mol1,
49  const FMCS::Graph& query, const ROMol& mol2, const FMCS::Graph& target,
50  const MCSParameters* p);
52  const ROMol& mol1, unsigned int atom1,
53  const ROMol& mol2, unsigned int atom2,
54  void* userData);
56  const ROMol& mol1, unsigned int bond1,
57  const ROMol& mol2, unsigned int bond2,
58  void* userData);
59 
60 // Some predefined functors:
62  const ROMol& mol1, unsigned int atom1,
63  const ROMol& mol2, unsigned int atom2,
64  void* userData);
65 
67  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
68  const ROMol& mol2, unsigned int atom2, void* userData);
70  const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1,
71  const ROMol& mol2, unsigned int atom2, void* userData);
72 
74  const ROMol& mol1, unsigned int bond1,
75  const ROMol& mol2, unsigned int bond2,
76  void* userData);
78  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
79  const ROMol& mol2, unsigned int bond2,
80  void* userData); // ignore Aromatization
82  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
83  const ROMol& mol2, unsigned int bond2, void* userData);
84 
86  unsigned NumAtoms;
87  unsigned NumBonds;
88  unsigned SeedProcessed;
89 
90  public:
91  MCSProgressData() : NumAtoms(0), NumBonds(0), SeedProcessed(0) {}
92 };
93 
94 typedef bool (*MCSProgressCallback)(const MCSProgressData& stat,
95  const MCSParameters& params,
96  void* userData);
98  const MCSParameters& params,
99  void* userData);
100 
103  double Threshold;
104  unsigned Timeout; // in seconds
105  bool Verbose;
111  MCSProgressCallback ProgressCallback; // return false to interrupt execution
114  FinalMatchChecker; // FinalChiralityCheckFunction() to check chirality
115  std::string InitialSeed; // user defined or empty string (default)
116  public:
118  : MaximizeBonds(true),
119  Threshold(1.0) // match to all
120  ,
121  Timeout(-1),
122  Verbose(false),
123  AtomTyper(MCSAtomCompareElements),
124  BondTyper(MCSBondCompareOrder),
125  CompareFunctionsUserData(0),
126  ProgressCallback(0),
127  ProgressCallbackUserData(0),
128  FinalMatchChecker(0),
129  InitialSeed("") {}
130 };
131 
133  unsigned NumAtoms;
134  unsigned NumBonds;
135  std::string SmartsString;
136  bool Canceled; // interrupted by timeout or user defined progress callback.
137  // Contains valid current MCS !
138  public:
139  MCSResult() : NumAtoms(0), NumBonds(0), Canceled(false) {}
140  bool isCompleted() const { return !Canceled; }
141 };
142 
143 RDKIT_FMCS_EXPORT void parseMCSParametersJSON(const char* json,
144  MCSParameters* params);
145 
146 RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols,
147  const MCSParameters* params = 0);
148 RDKIT_FMCS_EXPORT MCSResult findMCS_P(const std::vector<ROMOL_SPTR>& mols,
149  const char* params_json);
150 
151 typedef enum {
156 typedef enum {
162 findMCS(const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds,
163  double threshold = 1.0, unsigned timeout = 3600, bool verbose = false,
164  bool matchValences = false, bool ringMatchesRingOnly = false,
165  bool completeRingsOnly = false, bool matchChiralTag = false,
166  AtomComparator atomComp = AtomCompareElements,
167  BondComparator bondComp = BondCompareOrder);
168 
169 } // namespace RDKit
MCSFinalMatchCheckFunction FinalMatchChecker
Definition: FMCS.h:114
RDKIT_FMCS_EXPORT bool MCSBondCompareAny(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
unsigned NumAtoms
Definition: FMCS.h:133
RDKIT_FMCS_EXPORT MCSResult findMCS(const std::vector< ROMOL_SPTR > &mols, const MCSParameters *params=0)
RDKIT_FMCS_EXPORT bool MCSAtomCompareIsotopes(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
double Threshold
Definition: FMCS.h:103
RDKIT_FMCS_EXPORT bool MCSBondCompareOrderExact(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
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 &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
Definition: FMCS.h:51
unsigned SeedProcessed
Definition: FMCS.h:88
RDKIT_FMCS_EXPORT bool MCSProgressCallbackTimeout(const MCSProgressData &stat, const MCSParameters &params, void *userData)
unsigned NumAtoms
Definition: FMCS.h:86
AtomComparator
Definition: FMCS.h:151
MCSAtomCompareFunction AtomTyper
Definition: FMCS.h:108
#define RDKIT_FMCS_EXPORT
Definition: export.h:190
void * CompareFunctionsUserData
Definition: FMCS.h:110
bool Canceled
Definition: FMCS.h:136
MCSProgressCallback ProgressCallback
Definition: FMCS.h:111
void * ProgressCallbackUserData
Definition: FMCS.h:112
MCSBondCompareFunction BondTyper
Definition: FMCS.h:109
bool isCompleted() const
Definition: FMCS.h:140
bool MaximizeBonds
Definition: FMCS.h:102
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:47
bool(* MCSProgressCallback)(const MCSProgressData &stat, const MCSParameters &params, void *userData)
Definition: FMCS.h:94
Std stuff.
Definition: Atom.h:30
RDKIT_FMCS_EXPORT void parseMCSParametersJSON(const char *json, MCSParameters *params)
MCSBondCompareParameters BondCompareParameters
Definition: FMCS.h:107
std::string SmartsString
Definition: FMCS.h:135
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 MCSResult findMCS_P(const std::vector< ROMOL_SPTR > &mols, const char *params_json)
RDKIT_FMCS_EXPORT bool MCSBondCompareOrder(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
unsigned Timeout
Definition: FMCS.h:104
BondComparator
Definition: FMCS.h:156
bool(* MCSBondCompareFunction)(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
Definition: FMCS.h:55
unsigned NumBonds
Definition: FMCS.h:134
MCSAtomCompareParameters AtomCompareParameters
Definition: FMCS.h:106
std::string InitialSeed
Definition: FMCS.h:115
unsigned NumBonds
Definition: FMCS.h:87