RDKit: RGroupDecompData.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
RGroupDecompData.h
Go to the documentation of this file.
1//
2// Copyright (C) 2017-2022 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_DECOMP_DATA
12#define RGROUP_DECOMP_DATA
13
14#include "RGroupCore.h"
15#include "RGroupScore.h"
16#include "RGroupFingerprintScore.h"
17#include <vector>
18#include <map>
19
20namespace RDKit {
21
22extern const std::string _rgroupInputDummy;
23
24 struct RGroupDecompData {
25 // matches[mol_idx] == vector of potential matches
26 std::map<int, RCore> cores;
27 std::map<std::string, int> newCores; // new "cores" found along the way
28 int newCoreLabel = EMPTY_CORE_LABEL;
29 // this caches the size of the previous matches vector
30 // such that the size of the current chunk can be inferred
31 size_t previousMatchSize = 0;
32 // the default for Greedy/GreedyChunks is keeping only the best
33 // permutation after each call to process()
34 bool prunePermutations = true;
35 RGroupDecompositionParameters params;
36
37 std::vector<std::vector<RGroupMatch>> matches;
38 std::set<int> labels;
39 std::vector<size_t> permutation;
40 unsigned int pruneLength = 0U;
41 FingerprintVarianceScoreData prunedFingerprintVarianceScoreData;
42 std::map<int, std::vector<int>> userLabels;
43
44 std::vector<int> processedRlabels;
45
46 std::map<int, int> finalRlabelMapping;
47 mutable RGroupScorer rGroupScorer;
48
49 RGroupDecompData(const RWMol &inputCore,
50 RGroupDecompositionParameters inputParams);
51
52 RGroupDecompData(const std::vector<ROMOL_SPTR> &inputCores,
53 RGroupDecompositionParameters inputParams);
54
55 void addCore(const ROMol &inputCore);
56
57 void prepareCores();
58
59 void setRlabel(Atom *atom, int rlabel);
60
61 int getRlabel(Atom *atom) const;
62
63 double scoreFromPrunedData(const std::vector<size_t> &permutation,
64 bool reset = true);
65
66 void prune();
67
68 // Return the RGroups with the current "best" permutation
69 // of matches.
70 std::vector<RGroupMatch> GetCurrentBestPermutation() const;
71
72 class UsedLabels {
73 public:
74 std::set<int> labels_used;
75
76 bool add(int rlabel);
77
78 int next();
79 };
80
81 void addCoreUserLabels(const RWMol &core, std::set<int> &userLabels);
82
83 void addAtoms(RWMol &mol,
84 const std::vector<std::pair<Atom *, Atom *>> &atomsToAdd);
85
86 bool replaceHydrogenCoreDummy(const RGroupMatch &match, RWMol &core,
87 const Atom &atom, const int currentLabel,
88 const int rLabel);
89
90 void relabelCore(RWMol &core, std::map<int, int> &mappings,
91 UsedLabels &used_labels, const std::set<int> &indexLabels,
92 const std::map<int, std::vector<int>> &extraAtomRLabels,
93 const RGroupMatch *const match = nullptr);
94
95 void relabelRGroup(RGroupData &rgroup, const std::map<int, int> &mappings);
96
97 // relabel the core and sidechains using the specified user labels
98 // if matches exist for non labelled atoms, these are added as well
99 void relabel();
100
101 double score(const std::vector<size_t> &permutation,
102 FingerprintVarianceScoreData *fingerprintVarianceScoreData =
103 nullptr) const;
104
105 RGroupDecompositionProcessResult process(bool pruneMatches,
106 bool finalize = false);
107
108 private:
109 void addInputCore(const ROMol &inputCore);
110};
111} // namespace RDKit
112
113#endif
RGroupCore.h
RGroupFingerprintScore.h
RGroupScore.h
RDKit::Atom
The class for representing atoms.
Definition Atom.h:74
RDKit::RGroupDecompData::UsedLabels
Definition RGroupDecompData.h:72
RDKit::RGroupDecompData::UsedLabels::add
bool add(int rlabel)
RDKit::RGroupDecompData::UsedLabels::next
int next()
RDKit::RGroupDecompData::UsedLabels::labels_used
std::set< int > labels_used
Definition RGroupDecompData.h:74
RDKit::RGroupScorer
Definition RGroupScore.h:71
RDKit::ROMol
Definition ROMol.h:199
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::_rgroupInputDummy
const std::string _rgroupInputDummy
RDKit::EMPTY_CORE_LABEL
const unsigned int EMPTY_CORE_LABEL
Definition RGroupUtils.h:28
RDKit::FingerprintVarianceScoreData
Definition RGroupFingerprintScore.h:42
RDKit::RGroupData
A single rgroup attached to a given core.
Definition RGroupData.h:22
RDKit::RGroupDecompData::previousMatchSize
size_t previousMatchSize
Definition RGroupDecompData.h:31
RDKit::RGroupDecompData::matches
std::vector< std::vector< RGroupMatch > > matches
Definition RGroupDecompData.h:37
RDKit::RGroupDecompData::newCoreLabel
int newCoreLabel
Definition RGroupDecompData.h:28
RDKit::RGroupDecompData::prunedFingerprintVarianceScoreData
FingerprintVarianceScoreData prunedFingerprintVarianceScoreData
Definition RGroupDecompData.h:41
RDKit::RGroupDecompData::RGroupDecompData
RGroupDecompData(const RWMol &inputCore, RGroupDecompositionParameters inputParams)
RDKit::RGroupDecompData::score
double score(const std::vector< size_t > &permutation, FingerprintVarianceScoreData *fingerprintVarianceScoreData=nullptr) const
RDKit::RGroupDecompData::scoreFromPrunedData
double scoreFromPrunedData(const std::vector< size_t > &permutation, bool reset=true)
RDKit::RGroupDecompData::relabelRGroup
void relabelRGroup(RGroupData &rgroup, const std::map< int, int > &mappings)
RDKit::RGroupDecompData::permutation
std::vector< size_t > permutation
Definition RGroupDecompData.h:39
RDKit::RGroupDecompData::prune
void prune()
RDKit::RGroupDecompData::userLabels
std::map< int, std::vector< int > > userLabels
Definition RGroupDecompData.h:42
RDKit::RGroupDecompData::labels
std::set< int > labels
Definition RGroupDecompData.h:38
RDKit::RGroupDecompData::replaceHydrogenCoreDummy
bool replaceHydrogenCoreDummy(const RGroupMatch &match, RWMol &core, const Atom &atom, const int currentLabel, const int rLabel)
RDKit::RGroupDecompData::params
RGroupDecompositionParameters params
Definition RGroupDecompData.h:35
RDKit::RGroupDecompData::newCores
std::map< std::string, int > newCores
Definition RGroupDecompData.h:27
RDKit::RGroupDecompData::relabelCore
void relabelCore(RWMol &core, std::map< int, int > &mappings, UsedLabels &used_labels, const std::set< int > &indexLabels, const std::map< int, std::vector< int > > &extraAtomRLabels, const RGroupMatch *const match=nullptr)
RDKit::RGroupDecompData::addAtoms
void addAtoms(RWMol &mol, const std::vector< std::pair< Atom *, Atom * > > &atomsToAdd)
RDKit::RGroupDecompData::process
RGroupDecompositionProcessResult process(bool pruneMatches, bool finalize=false)
RDKit::RGroupDecompData::cores
std::map< int, RCore > cores
Definition RGroupDecompData.h:26
RDKit::RGroupDecompData::pruneLength
unsigned int pruneLength
Definition RGroupDecompData.h:40
RDKit::RGroupDecompData::setRlabel
void setRlabel(Atom *atom, int rlabel)
RDKit::RGroupDecompData::addCore
void addCore(const ROMol &inputCore)
RDKit::RGroupDecompData::relabel
void relabel()
RDKit::RGroupDecompData::processedRlabels
std::vector< int > processedRlabels
Definition RGroupDecompData.h:44
RDKit::RGroupDecompData::getRlabel
int getRlabel(Atom *atom) const
RDKit::RGroupDecompData::prunePermutations
bool prunePermutations
Definition RGroupDecompData.h:34
RDKit::RGroupDecompData::finalRlabelMapping
std::map< int, int > finalRlabelMapping
Definition RGroupDecompData.h:46
RDKit::RGroupDecompData::prepareCores
void prepareCores()
RDKit::RGroupDecompData::addCoreUserLabels
void addCoreUserLabels(const RWMol &core, std::set< int > &userLabels)
RDKit::RGroupDecompData::RGroupDecompData
RGroupDecompData(const std::vector< ROMOL_SPTR > &inputCores, RGroupDecompositionParameters inputParams)
RDKit::RGroupDecompData::GetCurrentBestPermutation
std::vector< RGroupMatch > GetCurrentBestPermutation() const
RDKit::RGroupDecompData::rGroupScorer
RGroupScorer rGroupScorer
Definition RGroupDecompData.h:47
RDKit::RGroupDecompositionParameters
Definition RGroupDecompParams.h:39
RDKit::RGroupDecompositionProcessResult
Definition RGroupDecomp.h:22
RDKit::RGroupMatch
RGroupMatch is the decomposition for a single molecule.
Definition RGroupMatch.h:19