RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
MaximumCommonSubgraph.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 "FMCS.h"
17#include "DebugTrace.h" // algorithm filter definitions
18#include "SeedSet.h"
19#include "Target.h"
20#include "SubstructureCache.h"
21#include "DuplicatedSeedCache.h"
22#include "MatchTable.h"
23#include "TargetMatch.h"
24
25namespace RDKit {
26
28 const std::uint32_t c1[], const std::uint32_t c2[], const ROMol& mol1,
29 const FMCS::Graph& query, const ROMol& mol2, const FMCS::Graph& target,
30 const MCSParameters* p);
31
32bool FinalMatchCheckFunction(const std::uint32_t c1[], const std::uint32_t c2[],
33 const ROMol& mol1, const FMCS::Graph& query,
34 const ROMol& mol2, const FMCS::Graph& target,
35 const MCSParameters* p);
36
37namespace FMCS {
39 // current result. Reference to a fragment of source molecule
40 struct MCS {
41 std::vector<const Atom*> Atoms;
42 std::vector<const Bond*> Bonds;
43 const ROMol* QueryMolecule;
44 std::vector<Target> Targets;
45 };
46 unsigned long long To;
47 MCSProgressData Stat;
49 // min number of matches
50 unsigned int ThresholdCount;
51 std::vector<const ROMol*> Molecules;
52#ifdef FAST_SUBSTRUCT_CACHE
53 // for Morgan code. Value based on current functor and parameters
54 std::vector<unsigned int> QueryAtomLabels;
55 // for Morgan code. Value based on current functor and parameters
56 std::vector<unsigned int> QueryBondLabels;
57 SubstructureCache HashCache;
58 MatchTable QueryAtomMatchTable;
59 MatchTable QueryBondMatchTable;
60#endif
61#ifdef DUP_SUBSTRUCT_CACHE
62 DuplicatedSeedCache DuplicateCache;
63#endif
64 const ROMol* QueryMolecule;
65 unsigned int QueryMoleculeMatchedBonds;
66 unsigned int QueryMoleculeMatchedAtoms;
67 const Atom* QueryMoleculeSingleMatchedAtom;
68 std::vector<Target> Targets;
69 SeedSet Seeds;
70 MCS McsIdx;
71 std::map<std::vector<unsigned int>, MCS> DegenerateMcsMap;
72
73 public:
74#ifdef VERBOSE_STATISTICS_ON
76#endif
77
80 MCSResult find(const std::vector<ROMOL_SPTR>& mols);
81 const ROMol& getQueryMolecule() const { return *QueryMolecule; }
82 unsigned int getMaxNumberBonds() const { return McsIdx.Bonds.size(); }
83
84 unsigned int getMaxNumberAtoms() const { return McsIdx.Atoms.size(); }
86 bool match(Seed& seed);
87 const MCSParameters& parameters() const { return Parameters; }
88 MCSParameters& parameters() { return Parameters; }
89
90 private:
91 void clear() {
92 Targets.clear();
93 Molecules.clear();
94 To = nanoClock();
95 }
96 void init(size_t startIdx);
97 void makeInitialSeeds();
98 bool createSeedFromMCS(size_t newQueryTarget, Seed& seed);
99 bool growSeeds(); // returns false if canceled
100 std::pair<std::string, ROMOL_SPTR> generateResultSMARTSAndQueryMol(
101 const MCS& mcsIdx) const;
102
103 bool matchIncrementalFast(Seed& seed, unsigned int itarget);
104};
105} // namespace FMCS
106} // namespace RDKit
static unsigned long long nanoClock(void)
Definition DebugTrace.h:97
pulls in the core RDKit functionality
The class for representing atoms.
Definition Atom.h:75
MaximumCommonSubgraph(const MCSParameters *params)
bool checkIfMatchAndAppend(Seed &seed)
MCSResult find(const std::vector< ROMOL_SPTR > &mols)
const MCSParameters & parameters() const
#define RDKIT_FMCS_EXPORT
Definition export.h:153
Std stuff.
bool rdvalue_is(const RDValue_cast_t)
bool FinalChiralityCheckFunction(const std::uint32_t c1[], const std::uint32_t c2[], const ROMol &mol1, const FMCS::Graph &query, const ROMol &mol2, const FMCS::Graph &target, const MCSParameters *p)
bool FinalMatchCheckFunction(const std::uint32_t c1[], const std::uint32_t c2[], const ROMol &mol1, const FMCS::Graph &query, const ROMol &mol2, const FMCS::Graph &target, const MCSParameters *p)