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) != terminalRGroupAtomToNeighbor.end();
73 }
74
75 /*
76 * For when onlyMatchAtRGroups = true. Checks the query core can satisfy all
77 * attachment points. Including when two user defined attachment points can
78 * match the same target atom.
79 */
80 [[deprecated("please use checkAllBondsToRGroupPresent")]]
82 const ROMol &mol, const int attachmentIdx,
83 const MatchVectType &mapping) const;
84
85 /*
86 * For when onlyMatchAtRGroups = true. Checks the query core can satisfy all
87 * attachment points. Including when two user defined attachment points can
88 * match the same target atom.
89 */
91 const ROMol &mol, const int attachmentIdx,
92 const std::vector<std::vector<int>> &targetToCoreIndices) const;
93
94 private:
95 // The set of atom indices in the core for terminal R groups with atom indices
96 // with or without user labels
97 std::set<int> terminalRGroupAtoms;
98 // An atom index map of terminal R groups to their heavy atom neighbor
99 std::map<int, int> terminalRGroupAtomToNeighbor;
100 // TautomerQuery for matching
101 bool checkedForTautomerQuery = false;
102 std::shared_ptr<TautomerQuery> matchingTautomerQuery = nullptr;
103
104 void replaceCoreAtom(RWMol &mol, Atom &atom, const Atom &other) const;
105
106 // Convert a matching molecule index to a core index
107 int matchingIndexToCoreIndex(int matchingIndex) const;
108
109 // Build the matching molecule (core minus user R groups)
110 void buildMatchingMol();
111
112 // Add attachment points to unlabelled R Groups
113 void addDummyAtomsToUnlabelledCoreAtoms();
114};
115
116} // namespace RDKit
117#endif
pulls in the core RDKit functionality
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:221
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