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 
26 
27  public:
28  MCSAtomCompareParameters() : MatchValences(false), MatchChiralTag(false) {}
29 };
30 
35 
36  public:
38  : RingMatchesRingOnly(false),
39  CompleteRingsOnly(false),
40  MatchStereo(false) {}
41 };
42 
44  const short unsigned c1[], const short unsigned c2[], const ROMol& mol1,
45  const FMCS::Graph& query, const ROMol& mol2, const FMCS::Graph& target,
46  const MCSParameters* p);
48  const ROMol& mol1, unsigned int atom1,
49  const ROMol& mol2, unsigned int atom2,
50  void* userData);
52  const ROMol& mol1, unsigned int bond1,
53  const ROMol& mol2, unsigned int bond2,
54  void* userData);
55 
56 // Some predefined functors:
58  unsigned int atom1, const ROMol& mol2,
59  unsigned int atom2, void* userData);
60 
62  const ROMol& mol1, unsigned int atom1,
63  const ROMol& mol2, unsigned int atom2,
64  void* userData);
66  const ROMol& mol1, unsigned int atom1,
67  const ROMol& mol2, unsigned int atom2,
68  void* userData);
69 
71  unsigned int bond1, const ROMol& mol2,
72  unsigned int bond2, void* userData);
74  unsigned int bond1, const ROMol& mol2,
75  unsigned int bond2,
76  void* userData); // ignore Aromatization
78  const ROMol& mol1, unsigned int bond1,
79  const ROMol& mol2, unsigned int bond2,
80  void* userData);
81 
83  unsigned NumAtoms;
84  unsigned NumBonds;
85  unsigned SeedProcessed;
86 
87  public:
88  MCSProgressData() : NumAtoms(0), NumBonds(0), SeedProcessed(0) {}
89 };
90 
91 typedef bool (*MCSProgressCallback)(const MCSProgressData& stat,
92  const MCSParameters& params,
93  void* userData);
95  const MCSParameters& params, void* userData);
96 
97 struct MCSParameters {
99  double Threshold;
100  unsigned Timeout; // in seconds
101  bool Verbose;
107  MCSProgressCallback ProgressCallback; // return false to interrupt execution
110  FinalMatchChecker; // FinalChiralityCheckFunction() to check chirality
111  std::string InitialSeed; // user defined or empty string (default)
112  public:
114  : MaximizeBonds(true),
115  Threshold(1.0) // match to all
116  ,
117  Timeout(-1),
118  Verbose(false),
119  AtomTyper(MCSAtomCompareElements),
120  BondTyper(MCSBondCompareOrder),
121  CompareFunctionsUserData(0),
122  ProgressCallback(0),
123  ProgressCallbackUserData(0),
124  FinalMatchChecker(0),
125  InitialSeed("") {}
126 };
127 
128 struct MCSResult {
129  unsigned NumAtoms;
130  unsigned NumBonds;
131  std::string SmartsString;
132  bool Canceled; // interrupted by timeout or user defined progress callback.
133  // Contains valid current MCS !
134  public:
135  MCSResult() : NumAtoms(0), NumBonds(0), Canceled(false) {}
136  bool isCompleted() const { return !Canceled; }
137 };
138 
139 void parseMCSParametersJSON(const char* json, MCSParameters* params);
140 
141 MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols,
142  const MCSParameters* params = 0);
143 MCSResult findMCS_P(const std::vector<ROMOL_SPTR>& mols,
144  const char* params_json);
145 
146 typedef enum {
151 typedef enum {
156 MCSResult findMCS(const std::vector<ROMOL_SPTR>& mols, bool maximizeBonds,
157  double threshold = 1.0, unsigned timeout = 3600,
158  bool verbose = false, bool matchValences = false,
159  bool ringMatchesRingOnly = false,
160  bool completeRingsOnly = false, bool matchChiralTag = false,
161  AtomComparator atomComp = AtomCompareElements,
162  BondComparator bondComp = BondCompareOrder);
163 
164 } // 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:110
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:129
double Threshold
Definition: FMCS.h:99
bool(* MCSAtomCompareFunction)(const MCSAtomCompareParameters &p, const ROMol &mol1, unsigned int atom1, const ROMol &mol2, unsigned int atom2, void *userData)
Definition: FMCS.h:47
unsigned SeedProcessed
Definition: FMCS.h:85
unsigned NumAtoms
Definition: FMCS.h:83
AtomComparator
Definition: FMCS.h:146
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:103
MCSAtomCompareFunction AtomTyper
Definition: FMCS.h:104
#define RDKIT_WRAP_DECL
Definition: FMCS.h:17
void * CompareFunctionsUserData
Definition: FMCS.h:106
bool Canceled
Definition: FMCS.h:132
MCSProgressCallback ProgressCallback
Definition: FMCS.h:107
void * ProgressCallbackUserData
Definition: FMCS.h:108
MCSBondCompareFunction BondTyper
Definition: FMCS.h:105
bool isCompleted() const
Definition: FMCS.h:136
bool MaximizeBonds
Definition: FMCS.h:98
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:43
bool(* MCSProgressCallback)(const MCSProgressData &stat, const MCSParameters &params, void *userData)
Definition: FMCS.h:91
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:103
void parseMCSParametersJSON(const char *json, MCSParameters *params)
std::string SmartsString
Definition: FMCS.h:131
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:100
BondComparator
Definition: FMCS.h:151
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:51
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:130
MCSAtomCompareParameters AtomCompareParameters
Definition: FMCS.h:102
std::string InitialSeed
Definition: FMCS.h:111
unsigned NumBonds
Definition: FMCS.h:84