RDKit: FMCS.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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