FMCS.h
Go to the documentation of this file.
//
// Copyright (C) 2014 Novartis Institutes for BioMedical Research
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#pragma once
#include <vector>
#include <string>
#include <stdexcept>
#include "../RDKitBase.h"
#include "Graph.h"
namespace RDKit {
struct MCSParameters;
struct MCSAtomCompareParameters {
bool MatchValences;
bool MatchChiralTag;
public:
MCSAtomCompareParameters() : MatchValences(false), MatchChiralTag(false) {}
};
struct MCSBondCompareParameters {
bool RingMatchesRingOnly;
bool CompleteRingsOnly;
bool MatchStereo;
public:
MCSBondCompareParameters() : RingMatchesRingOnly(false), CompleteRingsOnly(false), MatchStereo(false) {}
};
typedef 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);
typedef bool (*MCSAtomCompareFunction)(const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1, const ROMol& mol2, unsigned int atom2, void* userData);
typedef bool (*MCSBondCompareFunction)(const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1, const ROMol& mol2, unsigned int bond2, void* userData);
// Some predefined functors:
bool MCSAtomCompareAny (const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1, const ROMol& mol2, unsigned int atom2, void* userData);
bool MCSAtomCompareElements (const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1, const ROMol& mol2, unsigned int atom2, void* userData);
bool MCSAtomCompareIsotopes (const MCSAtomCompareParameters& p, const ROMol& mol1, unsigned int atom1, const ROMol& mol2, unsigned int atom2, void* userData);
bool MCSBondCompareAny (const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1, const ROMol& mol2, unsigned int bond2, void* userData);
bool MCSBondCompareOrder (const MCSBondCompareParameters& p, const ROMol& mol1, unsigned int bond1, const ROMol& mol2, unsigned int bond2, void* userData); // ignore Aromatization
bool MCSBondCompareOrderExact(const MCSBondCompareParameters&p, const ROMol& mol1, unsigned int bond1, const ROMol& mol2, unsigned int bond2, void* userData);
struct MCSProgressData {
unsigned NumAtoms;
unsigned NumBonds;
unsigned SeedProcessed;
public:
MCSProgressData() : NumAtoms(0), NumBonds(0), SeedProcessed(0) {}
};
typedef bool (*MCSProgressCallback)(const MCSProgressData& stat, const MCSParameters &params, void* userData);
bool MCSProgressCallbackTimeout(const MCSProgressData& stat, const MCSParameters &params, void* userData);
struct MCSParameters {
bool MaximizeBonds;
double Threshold;
unsigned Timeout; // in seconds
bool Verbose;
MCSAtomCompareParameters AtomCompareParameters;
MCSBondCompareParameters BondCompareParameters;
MCSAtomCompareFunction AtomTyper;
MCSBondCompareFunction BondTyper;
void* CompareFunctionsUserData;
MCSProgressCallback ProgressCallback; // return false to interrupt execution
void* ProgressCallbackUserData;
MCSFinalMatchCheckFunction FinalMatchChecker; // FinalChiralityCheckFunction() to check chirality
public:
MCSParameters(): MaximizeBonds(true)
, Threshold(1.0) // match to all
, Timeout(-1)
, Verbose(false)
, AtomTyper(MCSAtomCompareElements)
, BondTyper(MCSBondCompareOrder)
, CompareFunctionsUserData(0)
, ProgressCallback(MCSProgressCallbackTimeout)
, ProgressCallbackUserData(0)
, FinalMatchChecker(0)
{}
};
struct MCSResult {
unsigned NumAtoms;
unsigned NumBonds;
std::string SmartsString;
bool Canceled; // interrupted by timeout or user defined progress callback. Contains valid current MCS !
public:
MCSResult() : NumAtoms(0), NumBonds(0), Canceled(false) {}
bool isCompleted()const {
return !Canceled;
}
};
void parseMCSParametersJSON (const char* json, MCSParameters* params);
MCSResult findMCS (const std::vector<ROMOL_SPTR>& mols, const MCSParameters* params=0);
MCSResult findMCS_P (const std::vector<ROMOL_SPTR>& mols, const char* params_json);
typedef enum {
AtomCompareAny,
AtomCompareElements,
AtomCompareIsotopes
} AtomComparator;
typedef enum {
BondCompareAny,
BondCompareOrder,
BondCompareOrderExact
} BondComparator;
MCSResult findMCS (const std::vector<ROMOL_SPTR>& mols,
bool maximizeBonds,
double threshold=1.0,
unsigned timeout=3600,
bool verbose=false,
bool matchValences=false,
bool ringMatchesRingOnly=false,
bool completeRingsOnly=false,
bool matchChiralTag=false,
AtomComparator atomComp=AtomCompareElements,
BondComparator bondComp=BondCompareOrder);
} // namespace RDKit
RDKit::MCSParameters::FinalMatchChecker
MCSFinalMatchCheckFunction FinalMatchChecker
Definition: FMCS.h:73
RDKit::MCSResult::NumAtoms
unsigned NumAtoms
Definition: FMCS.h:89
RDKit::MCSBondCompareParameters::RingMatchesRingOnly
bool RingMatchesRingOnly
Definition: FMCS.h:28
RDKit::MCSParameters::Threshold
double Threshold
Definition: FMCS.h:63
RDKit::MCSAtomCompareParameters
Definition: FMCS.h:20
RDKit::MCSBondCompareParameters
Definition: FMCS.h:27
RDKit::MCSParameters::Verbose
bool Verbose
Definition: FMCS.h:65
RDKit::MCSProgressData
Definition: FMCS.h:50
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:37
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:53
RDKit::MCSProgressData::NumAtoms
unsigned NumAtoms
Definition: FMCS.h:51
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:112
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:32
RDKit::AtomCompareIsotopes
Definition: FMCS.h:108
RDKit::MCSBondCompareParameters::CompleteRingsOnly
bool CompleteRingsOnly
Definition: FMCS.h:29
RDKit::AtomComparator
AtomComparator
Definition: FMCS.h:105
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:105
RDKit::MCSParameters::AtomTyper
MCSAtomCompareFunction AtomTyper
Definition: FMCS.h:68
RDKit::MCSParameters::CompareFunctionsUserData
void * CompareFunctionsUserData
Definition: FMCS.h:70
RDKit::BondCompareOrderExact
Definition: FMCS.h:113
RDKit::MCSResult::Canceled
bool Canceled
Definition: FMCS.h:92
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:71
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:72
RDKit::MCSParameters::BondTyper
MCSBondCompareFunction BondTyper
Definition: FMCS.h:69
RDKit::MCSResult::isCompleted
bool isCompleted() const
Definition: FMCS.h:95
RDKit::FMCS::Graph
Definition: Graph.h:21
RDKit::BondCompareAny
Definition: FMCS.h:111
RDKit::MCSAtomCompareParameters::MatchValences
bool MatchValences
Definition: FMCS.h:21
RDKit::MCSParameters::MaximizeBonds
bool MaximizeBonds
Definition: FMCS.h:62
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:35
RDKit::MCSProgressCallback
bool(* MCSProgressCallback)(const MCSProgressData &stat, const MCSParameters &params, void *userData)
Definition: FMCS.h:58
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:55
RDKit::MCSAtomCompareParameters::MCSAtomCompareParameters
MCSAtomCompareParameters()
Definition: FMCS.h:24
RDKit::MCSResult::MCSResult
MCSResult()
Definition: FMCS.h:94
RDKit::MCSParameters::BondCompareParameters
MCSBondCompareParameters BondCompareParameters
Definition: FMCS.h:67
RDKit::parseMCSParametersJSON
void parseMCSParametersJSON(const char *json, MCSParameters *params)
Graph.h
RDKit::MCSResult::SmartsString
std::string SmartsString
Definition: FMCS.h:91
RDKit::MCSParameters
Definition: FMCS.h:61
RDKit::findMCS_P
MCSResult findMCS_P(const std::vector< ROMOL_SPTR > &mols, const char *params_json)
RDKit::MCSParameters::Timeout
unsigned Timeout
Definition: FMCS.h:64
RDKit::BondComparator
BondComparator
Definition: FMCS.h:110
RDKit::findMCS
MCSResult findMCS(const std::vector< ROMOL_SPTR > &mols, const MCSParameters *params=0)
RDKit::AtomCompareElements
Definition: FMCS.h:107
RDKit::MCSBondCompareFunction
bool(* MCSBondCompareFunction)(const MCSBondCompareParameters &p, const ROMol &mol1, unsigned int bond1, const ROMol &mol2, unsigned int bond2, void *userData)
Definition: FMCS.h:38
RDKit::MCSResult
Definition: FMCS.h:88
RDKit::MCSBondCompareParameters::MatchStereo
bool MatchStereo
Definition: FMCS.h:30
RDKit::MCSAtomCompareParameters::MatchChiralTag
bool MatchChiralTag
Definition: FMCS.h:22
RDKit::MCSResult::NumBonds
unsigned NumBonds
Definition: FMCS.h:90
RDKit::AtomCompareAny
Definition: FMCS.h:106
RDKit::MCSParameters::AtomCompareParameters
MCSAtomCompareParameters AtomCompareParameters
Definition: FMCS.h:66
RDKit::MCSProgressData::NumBonds
unsigned NumBonds
Definition: FMCS.h:52
RDKit::MCSParameters::MCSParameters
MCSParameters()
Definition: FMCS.h:75