RDKit
Open-source cheminformatics and machine learning.
Toggle main menu visibility
Loading...
Searching...
No Matches
Seed.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 <map>
13
#include <boost/dynamic_bitset.hpp>
14
#include "
../RDKitBase.h
"
15
// algorithm optimisation definitions
16
#include "
DebugTrace.h
"
17
#include "
Graph.h
"
18
#include "
DuplicatedSeedCache.h
"
19
#include "
SubstructMatchCustom.h
"
20
#include "
TargetMatch.h
"
21
22
namespace
RDKit
{
23
namespace
FMCS
{
24
class
MaximumCommonSubgraph
;
25
struct
TargetMatch
;
26
27
// Reference to a fragment of source molecule
28
struct
RDKIT_FMCS_EXPORT
MolFragment
{
29
std::vector<const Atom *>
Atoms
;
30
std::vector<const Bond *>
Bonds
;
31
// Full Query Molecule to Seed indices backward conversionmap
32
std::map<unsigned int, unsigned int>
SeedAtomIdxMap
;
33
};
34
35
struct
RDKIT_FMCS_EXPORT
NewBond
{
36
// index in qmol of new bond scheduled to be added into
37
// seed. This is outgoing bond from SourceAtomIdx
38
unsigned
int
BondIdx
{0};
39
// index in qmol of new atom scheduled to be
40
// added into seed. Another end of new bond
41
unsigned
int
NewAtomIdx
{0};
42
// index in the seed. RING. "New" Atom on the another
43
// end of new bond if it already exists in the seed.
44
unsigned
int
EndAtomIdx
{0};
45
// pointer to qmol's new atom scheduled to be
46
// added into seed. Another end of new bond
47
const
Atom
*
NewAtom
{
nullptr
};
48
49
NewBond
()
50
51
{}
52
53
NewBond
(
unsigned
int
bond_idx,
unsigned
int
new_atom,
unsigned
int
to_atom,
54
const
Atom
*a)
55
:
BondIdx
(bond_idx),
56
NewAtomIdx
(new_atom),
57
EndAtomIdx
(to_atom),
58
NewAtom
(a) {}
59
};
60
61
class
RDKIT_FMCS_EXPORT
Seed
{
62
private
:
63
boost::dynamic_bitset<> addNewBondsToSeed(
const
ROMol
&qmol,
64
Seed
&seed)
const
;
65
bool
canAddAllNonFusedRingBondsConnectedToBond(
66
const
Atom
&srcAtom,
const
Bond
&bond,
MaximumCommonSubgraph
&mcs)
const
;
67
void
addNewBondFromAtom(
const
Atom
&srcAtom,
const
Bond
&bond)
const
;
68
// for multistage growing. all directly connected outgoing bonds
69
mutable
std::vector<NewBond> NewBonds;
70
bool
StoreAllDegenerateMCS =
false
;
71
72
public
:
73
// this seed has been completely copied into list.
74
// postponed non-locked copy for MULTI_THREAD
75
bool
CopyComplete
{
false
};
76
// 0 new seed; -1 finished; n>0 in
77
// progress, exact stage of growing for SDF
78
mutable
unsigned
int
GrowingStage
{0};
79
// Reference to a fragment of source molecule
80
MolFragment
MoleculeFragment
;
81
// seed topology with references to source molecule
82
Graph
Topology
;
83
84
boost::dynamic_bitset<>
ExcludedBonds
;
85
// in this subgraph for improving performance of future growing
86
unsigned
int
LastAddedAtomsBeginIdx
{0};
87
// in this subgraph for DEBUG ONLY
88
unsigned
int
LastAddedBondsBeginIdx
{0};
89
unsigned
int
RemainingBonds
{0};
90
unsigned
int
RemainingAtoms
{0};
91
#ifdef DUP_SUBSTRUCT_CACHE
92
DuplicatedSeedCache::TKey
DupCacheKey
;
93
#endif
94
// for each target
95
std::vector<TargetMatch>
MatchResult
;
96
97
public
:
98
Seed
() {}
99
// Defined explicitly (rather than defaulted) so that copying goes through
100
// operator=, which sets CopyComplete last as a publication barrier for the
101
// multi-threaded growing path. Without a user-declared copy constructor the
102
// implicit one would be used and is deprecated (-Wdeprecated-copy), since
103
// operator= is user-provided.
104
Seed
(
const
Seed
&src) { *
this
= src; }
105
106
Seed
&
operator=
(
const
Seed
&src) {
107
NewBonds = src.NewBonds;
108
GrowingStage
= src.
GrowingStage
;
109
MoleculeFragment
= src.
MoleculeFragment
;
110
Topology
= src.
Topology
;
111
ExcludedBonds
= src.
ExcludedBonds
;
112
LastAddedAtomsBeginIdx
= src.
LastAddedAtomsBeginIdx
;
113
LastAddedBondsBeginIdx
= src.
LastAddedBondsBeginIdx
;
114
RemainingBonds
= src.
RemainingBonds
;
115
RemainingAtoms
= src.
RemainingAtoms
;
116
StoreAllDegenerateMCS = src.StoreAllDegenerateMCS;
117
#ifdef DUP_SUBSTRUCT_CACHE
118
DupCacheKey
= src.
DupCacheKey
;
119
#endif
120
MatchResult
= src.
MatchResult
;
121
CopyComplete
=
true
;
// LAST
122
return
*
this
;
123
}
124
void
setMoleculeFragment
(
const
Seed
&src) {
125
MoleculeFragment
= src.
MoleculeFragment
;
126
}
127
void
createFromParent
(
const
Seed
*parent) {
128
MoleculeFragment
= parent->
MoleculeFragment
;
129
Topology
= parent->
Topology
;
130
ExcludedBonds
= parent->
ExcludedBonds
;
131
RemainingBonds
= parent->
RemainingBonds
;
132
RemainingAtoms
= parent->
RemainingAtoms
;
133
StoreAllDegenerateMCS = parent->StoreAllDegenerateMCS;
134
#ifdef DUP_SUBSTRUCT_CACHE
135
DupCacheKey
= parent->
DupCacheKey
;
136
#endif
137
LastAddedAtomsBeginIdx
=
getNumAtoms
();
// previous size
138
LastAddedBondsBeginIdx
=
getNumBonds
();
// previous size
139
GrowingStage
= 0;
140
}
141
142
unsigned
int
getNumAtoms
()
const
{
return
MoleculeFragment
.Atoms.size(); }
143
unsigned
int
getNumBonds
()
const
{
return
MoleculeFragment
.Bonds.size(); }
144
145
void
grow
(
MaximumCommonSubgraph
&mcs)
const
;
146
bool
canGrowBiggerThan
(
unsigned
int
maxBonds,
unsigned
int
maxAtoms)
const
{
147
return
RemainingBonds
+
getNumBonds
() > maxBonds ||
148
(
RemainingBonds
+
getNumBonds
() == maxBonds &&
149
(
RemainingAtoms
+
getNumAtoms
() > maxAtoms ||
150
(StoreAllDegenerateMCS &&
151
RemainingAtoms
+
getNumAtoms
() == maxAtoms)));
152
}
153
void
computeRemainingSize
(
const
ROMol
&qmol);
154
155
unsigned
int
addAtom
(
const
Atom
*atom);
156
unsigned
int
addBond
(
const
Bond
*bond);
157
void
fillNewBonds
(
const
ROMol
&qmol,
158
MaximumCommonSubgraph
*mcs =
nullptr
)
const
;
159
void
setStoreAllDegenerateMCS
(
bool
value) { StoreAllDegenerateMCS = value; }
160
};
161
}
// namespace FMCS
162
}
// namespace RDKit
DebugTrace.h
DuplicatedSeedCache.h
Graph.h
RDKitBase.h
pulls in the core RDKit functionality
SubstructMatchCustom.h
TargetMatch.h
RDKit::Atom
The class for representing atoms.
Definition
Atom.h:75
RDKit::Bond
class for representing a bond
Definition
Bond.h:48
RDKit::FMCS::DuplicatedSeedCache::TKey
Definition
DuplicatedSeedCache.h:23
RDKit::FMCS::Graph
Definition
Graph.h:26
RDKit::FMCS::MaximumCommonSubgraph
Definition
MaximumCommonSubgraph.h:38
RDKit::FMCS::Seed::LastAddedBondsBeginIdx
unsigned int LastAddedBondsBeginIdx
Definition
Seed.h:88
RDKit::FMCS::Seed::addBond
unsigned int addBond(const Bond *bond)
RDKit::FMCS::Seed::getNumAtoms
unsigned int getNumAtoms() const
Definition
Seed.h:142
RDKit::FMCS::Seed::createFromParent
void createFromParent(const Seed *parent)
Definition
Seed.h:127
RDKit::FMCS::Seed::GrowingStage
unsigned int GrowingStage
Definition
Seed.h:78
RDKit::FMCS::Seed::LastAddedAtomsBeginIdx
unsigned int LastAddedAtomsBeginIdx
Definition
Seed.h:86
RDKit::FMCS::Seed::getNumBonds
unsigned int getNumBonds() const
Definition
Seed.h:143
RDKit::FMCS::Seed::Seed
Seed(const Seed &src)
Definition
Seed.h:104
RDKit::FMCS::Seed::grow
void grow(MaximumCommonSubgraph &mcs) const
RDKit::FMCS::Seed::setStoreAllDegenerateMCS
void setStoreAllDegenerateMCS(bool value)
Definition
Seed.h:159
RDKit::FMCS::Seed::Seed
Seed()
Definition
Seed.h:98
RDKit::FMCS::Seed::fillNewBonds
void fillNewBonds(const ROMol &qmol, MaximumCommonSubgraph *mcs=nullptr) const
RDKit::FMCS::Seed::RemainingAtoms
unsigned int RemainingAtoms
Definition
Seed.h:90
RDKit::FMCS::Seed::MoleculeFragment
MolFragment MoleculeFragment
Definition
Seed.h:80
RDKit::FMCS::Seed::DupCacheKey
DuplicatedSeedCache::TKey DupCacheKey
Definition
Seed.h:92
RDKit::FMCS::Seed::MatchResult
std::vector< TargetMatch > MatchResult
Definition
Seed.h:95
RDKit::FMCS::Seed::setMoleculeFragment
void setMoleculeFragment(const Seed &src)
Definition
Seed.h:124
RDKit::FMCS::Seed::RemainingBonds
unsigned int RemainingBonds
Definition
Seed.h:89
RDKit::FMCS::Seed::canGrowBiggerThan
bool canGrowBiggerThan(unsigned int maxBonds, unsigned int maxAtoms) const
Definition
Seed.h:146
RDKit::FMCS::Seed::addAtom
unsigned int addAtom(const Atom *atom)
RDKit::FMCS::Seed::ExcludedBonds
boost::dynamic_bitset ExcludedBonds
Definition
Seed.h:84
RDKit::FMCS::Seed::operator=
Seed & operator=(const Seed &src)
Definition
Seed.h:106
RDKit::FMCS::Seed::CopyComplete
bool CopyComplete
Definition
Seed.h:75
RDKit::FMCS::Seed::computeRemainingSize
void computeRemainingSize(const ROMol &qmol)
RDKit::FMCS::Seed::Topology
Graph Topology
Definition
Seed.h:82
RDKit::ROMol
Definition
ROMol.h:344
export.h
RDKIT_FMCS_EXPORT
#define RDKIT_FMCS_EXPORT
Definition
export.h:211
RDKit::FMCS
Definition
Composition2N.h:13
RDKit
Std stuff.
Definition
Abbreviations.h:19
RDKit::FMCS::MolFragment
Definition
Seed.h:28
RDKit::FMCS::MolFragment::SeedAtomIdxMap
std::map< unsigned int, unsigned int > SeedAtomIdxMap
Definition
Seed.h:32
RDKit::FMCS::MolFragment::Bonds
std::vector< const Bond * > Bonds
Definition
Seed.h:30
RDKit::FMCS::MolFragment::Atoms
std::vector< const Atom * > Atoms
Definition
Seed.h:29
RDKit::FMCS::NewBond::NewBond
NewBond()
Definition
Seed.h:49
RDKit::FMCS::NewBond::NewAtomIdx
unsigned int NewAtomIdx
Definition
Seed.h:41
RDKit::FMCS::NewBond::BondIdx
unsigned int BondIdx
Definition
Seed.h:38
RDKit::FMCS::NewBond::NewBond
NewBond(unsigned int bond_idx, unsigned int new_atom, unsigned int to_atom, const Atom *a)
Definition
Seed.h:53
RDKit::FMCS::NewBond::NewAtom
const Atom * NewAtom
Definition
Seed.h:47
RDKit::FMCS::NewBond::EndAtomIdx
unsigned int EndAtomIdx
Definition
Seed.h:44
RDKit::FMCS::TargetMatch
Definition
TargetMatch.h:23
GraphMol
FMCS
Seed.h
Generated on
for RDKit by
1.17.0