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 #pragma once
11 #include <vector>
12 #include <string>
13 #include <stdexcept>
14 #include "../RDKitBase.h"
15 #include "Graph.h"
16 #ifndef RDKIT_WRAP_DECL
17 #define RDKIT_WRAP_DECL
18 #endif
19 
20 namespace RDKit {
21 struct MCSParameters;
22 
27 
28  public:
30  : MatchValences(false), MatchChiralTag(false), MatchFormalCharge(false) {}
31 };
32 
37 
38  public:
40  : RingMatchesRingOnly(false),
41  CompleteRingsOnly(false),
42  MatchStereo(false) {}
43 };
44 
46  const short unsigned c1[], const short unsigned c2[], const ROMol& mol1,
47  const FMCS::Graph& query, const ROMol& mol2, const FMCS::Graph& target,
48  const MCSParameters* p);
50  const ROMol& mol1, unsigned int atom1,
51  const ROMol& mol2, unsigned int atom2,
52  void* userData);
54  const ROMol& mol1, unsigned int bond1,
55  const ROMol& mol2, unsigned int bond2,
56  void* userData);
57 
58 // Some predefined functors:
60  const ROMol& mol1, unsigned int atom1,
61  const ROMol& mol2, unsigned int atom2,
62  void* userData);
63 
65  const ROMol& mol1,
66  unsigned int atom1,
67  const ROMol& mol2,
68  unsigned int atom2, void* userData);
70  const ROMol& mol1,
71  unsigned int atom1,
72  const ROMol& mol2,
73  unsigned int atom2, void* userData);
74 
76  const ROMol& mol1, unsigned int bond1,
77  const ROMol& mol2, unsigned int bond2,
78  void* userData);
80  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
81  const ROMol& mol2, unsigned int bond2,
82  void* userData); // ignore Aromatization
84  const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1,
85  const ROMol& mol2, unsigned int bond2, void* userData);
86 
88  unsigned NumAtoms;
89  unsigned NumBonds;
90  unsigned SeedProcessed;
91 
92  public:
93  MCSProgressData() : NumAtoms(0), NumBonds(0), SeedProcessed(0) {}
94 };
95 
96 typedef bool (*MCSProgressCallback)(const MCSProgressData& stat,
97  const MCSParameters& params,
98  void* userData);
100  const MCSParameters& params, void* userData);
101 
104  double Threshold;
105  unsigned Timeout; // in seconds
106  bool Verbose;
112  MCSProgressCallback ProgressCallback; // return false to interrupt execution
115  FinalMatchChecker; // FinalChiralityCheckFunction() to check chirality
116  std::string InitialSeed; // user defined or empty string (default)
117  public:
119  : MaximizeBonds(true),
120  Threshold(1.0) // match to all
121  ,
122  Timeout(-1),
123  Verbose(false),
124  AtomTyper(MCSAtomCompareElements),
125  BondTyper(MCSBondCompareOrder),
126  CompareFunctionsUserData(0),
127  ProgressCallback(0),
128  ProgressCallbackUserData(0),
129  FinalMatchChecker(0),
130  InitialSeed("") {}
131 };
132 
133 struct MCSResult {
134  unsigned NumAtoms;
135  unsigned NumBonds;
136  std::string SmartsString;
137  bool Canceled; // interrupted by timeout or user defined progress callback.
138  // Contains valid current MCS !
139  public:
140  MCSResult() : NumAtoms(0), NumBonds(0), Canceled(false) {}
141  bool isCompleted() const { return !Canceled; }
142 };
143 
144 void parseMCSParametersJSON(const char* json, MCSParameters* params);
145 
146 MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols,
147  const MCSParameters* params = 0);
148 MCSResult findMCS_P(const std::vector<ROMOL_SPTR>& mols,
149  const char* params_json);
150 
151 typedef enum {
156 typedef enum {
161 MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds,
162  double threshold = 1.0, unsigned timeout = 3600,
163  bool verbose = false, bool matchValences = false,
164  bool ringMatchesRingOnly = false,
165  bool completeRingsOnly = false, bool matchChiralTag = false,
166  AtomComparator atomComp = AtomCompareElements,
167  BondComparator bondComp = BondCompareOrder);
168 
169 } // namespace RDKit
RDKIT_WRAP_DECL bool MCSBondCompareAny(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
MCSFinalMatchCheckFunction FinalMatchChecker
Definition: FMCS.h:115
RDKIT_WRAP_DECL bool MCSBondCompareOrder(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
unsigned NumAtoms
Definition: FMCS.h:134
double Threshold
Definition: FMCS.h:104
bool(* MCSAtomCompareFunction)(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
Definition: FMCS.h:49
unsigned SeedProcessed
Definition: FMCS.h:90
unsigned NumAtoms
Definition: FMCS.h:88
AtomComparator
Definition: FMCS.h:151
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:106
MCSAtomCompareFunction AtomTyper
Definition: FMCS.h:109
#define RDKIT_WRAP_DECL
Definition: FMCS.h:17
void * CompareFunctionsUserData
Definition: FMCS.h:111
bool Canceled
Definition: FMCS.h:137
MCSProgressCallback ProgressCallback
Definition: FMCS.h:112
void * ProgressCallbackUserData
Definition: FMCS.h:113
MCSBondCompareFunction BondTyper
Definition: FMCS.h:110
bool isCompleted() const
Definition: FMCS.h:141
bool MaximizeBonds
Definition: FMCS.h:103
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:45
bool(* MCSProgressCallback)(const MCSProgressData &stat, const MCSParameters &params, void *userData)
Definition: FMCS.h:96
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:29
bool MCSProgressCallbackTimeout(const MCSProgressData &stat, const MCSParameters &params, void *userData)
RDKIT_WRAP_DECL bool MCSAtomCompareIsotopes(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
MCSBondCompareParameters BondCompareParameters
Definition: FMCS.h:108
void parseMCSParametersJSON(const char *json, MCSParameters *params)
std::string SmartsString
Definition: FMCS.h:136
RDKIT_WRAP_DECL bool MCSAtomCompareElements(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
MCSResult findMCS_P(const std::vector< ROMOL_SPTR > &mols, const char *params_json)
unsigned Timeout
Definition: FMCS.h:105
BondComparator
Definition: FMCS.h:156
RDKIT_WRAP_DECL bool MCSAtomCompareAny(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
MCSResult findMCS(const std::vector< ROMOL_SPTR > &mols, const MCSParameters *params=0)
bool(* MCSBondCompareFunction)(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
Definition: FMCS.h:53
RDKIT_WRAP_DECL bool MCSBondCompareOrderExact(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
unsigned NumBonds
Definition: FMCS.h:135
MCSAtomCompareParameters AtomCompareParameters
Definition: FMCS.h:107
std::string InitialSeed
Definition: FMCS.h:116
unsigned NumBonds
Definition: FMCS.h:89