RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
RGroupCore.h
Go to the documentation of this file.
1//
2// Copyright (C) 2020-2021 Novartis Institutes for BioMedical Research and
3// other RDKit contributors
4//
5// @@ All Rights Reserved @@
6// This file is part of the RDKit.
7// The contents are covered by the terms of the BSD license
8// which is included in the file license.txt, found at the root
9// of the RDKit source tree.
10//
11#ifndef RGROUP_CORE
12#define RGROUP_CORE
13
15#include "../RDKitBase.h"
16#include "RGroupUtils.h"
18
19// #define VERBOSE 1
20
21namespace RDKit {
22class TautomerQuery;
23
24//! RCore is the core common to a series of molecules
25struct RCore {
26 boost::shared_ptr<RWMol> core;
27 // core with terminal user R groups stripped for matching
28 boost::shared_ptr<RWMol> matchingMol;
29 boost::shared_ptr<RWMol> labelledCore;
30
31 // Bitset: indices corresponding to atoms bearing user-defined labels are 1
32 boost::dynamic_bitset<> core_atoms_with_user_labels;
33 // Number of user labelled rgroups in the core
35 RCore() {}
36 RCore(const RWMol &c) : core(new RWMol(c)) { init(); }
37
38 void init();
39
40 inline bool isCoreAtomUserLabelled(int idx) const {
41 return core_atoms_with_user_labels.test(idx);
42 }
43
47
48 // Find all the core atoms that have user
49 // label and set their indices to 1 into core_atoms_with_user_labels
51
52 // Return a copy of core where dummy atoms are replaced by
53 // the respective matching atom in mol, while other atoms have
54 // their aromatic flag and formal charge copied from
55 // the respective matching atom in mol
57 const MatchVectType &match) const;
58
59 // Final core returned to user, created by extracting core from target
60 // molecule
62 const ROMol &mol, const MatchVectType &match,
63 const RGroupDecompositionParameters &params) const;
64
65 std::vector<MatchVectType> matchTerminalUserRGroups(
66 const RWMol &target, MatchVectType match,
68
69 std::shared_ptr<TautomerQuery> getMatchingTautomerQuery();
70
71 inline bool isTerminalRGroupWithUserLabel(const int idx) const {
72 return terminalRGroupAtomToNeighbor.find(idx) !=
73 terminalRGroupAtomToNeighbor.end();
74 }
75
76 /*
77 * For when onlyMatchAtRGroups = true. Checks the query core can satisfy all
78 * attachment points. Including when two user defined attachment points can
79 * match the same target atom.
80 */
81 [[deprecated("please use checkAllBondsToRGroupPresent")]]
83 const ROMol &mol, const int attachmentIdx,
84 const MatchVectType &mapping) const;
85
86 /*
87 * For when onlyMatchAtRGroups = true. Checks the query core can satisfy all
88 * attachment points. Including when two user defined attachment points can
89 * match the same target atom.
90 */
92 const ROMol &mol, const int attachmentIdx,
93 const std::vector<std::vector<int>> &targetToCoreIndices) const;
94
95 private:
96 // The set of atom indices in the core for terminal R groups with atom indices
97 // with or without user labels
98 std::set<int> terminalRGroupAtoms;
99 // An atom index map of terminal R groups to their heavy atom neighbor
100 std::map<int, int> terminalRGroupAtomToNeighbor;
101 // TautomerQuery for matching
102 bool checkedForTautomerQuery = false;
103 std::shared_ptr<TautomerQuery> matchingTautomerQuery = nullptr;
104
105 void replaceCoreAtom(RWMol &mol, Atom &atom, const Atom &other) const;
106
107 // Convert a matching molecule index to a core index
108 int matchingIndexToCoreIndex(int matchingIndex) const;
109
110 // Build the matching molecule (core minus user R groups)
111 void buildMatchingMol();
112
113 // Add attachment points to unlabelled R Groups
114 void addDummyAtomsToUnlabelledCoreAtoms();
115};
116
117} // namespace RDKit
118#endif
The class for representing atoms.
Definition Atom.h:75
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
Std stuff.
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx)
bool rdvalue_is(const RDValue_cast_t)
boost::shared_ptr< ROMol > ROMOL_SPTR
boost::shared_ptr< RWMol > RWMOL_SPTR
Definition RWMol.h:222
RCore is the core common to a series of molecules.
Definition RGroupCore.h:25
size_t numberUserRGroups
Definition RGroupCore.h:34
bool isCoreAtomUserLabelled(int idx) const
Definition RGroupCore.h:40
void findIndicesWithRLabel()
void countUserRGroups()
Definition RGroupCore.h:44
ROMOL_SPTR replaceCoreAtomsWithMolMatches(const ROMol &mol, const MatchVectType &match) const
bool checkAllBondsToAttachmentPointPresent(const ROMol &mol, const int attachmentIdx, const MatchVectType &mapping) const
RWMOL_SPTR extractCoreFromMolMatch(const ROMol &mol, const MatchVectType &match, const RGroupDecompositionParameters &params) const
bool isTerminalRGroupWithUserLabel(const int idx) const
Definition RGroupCore.h:71
boost::dynamic_bitset core_atoms_with_user_labels
Definition RGroupCore.h:32
boost::shared_ptr< RWMol > core
Definition RGroupCore.h:26
std::shared_ptr< TautomerQuery > getMatchingTautomerQuery()
boost::shared_ptr< RWMol > labelledCore
Definition RGroupCore.h:29
std::vector< MatchVectType > matchTerminalUserRGroups(const RWMol &target, MatchVectType match, const SubstructMatchParameters &sssParams) const
bool checkAllBondsToRGroupPresent(const ROMol &mol, const int attachmentIdx, const std::vector< std::vector< int > > &targetToCoreIndices) const
boost::shared_ptr< RWMol > matchingMol
Definition RGroupCore.h:28
RCore(const RWMol &c)
Definition RGroupCore.h:36