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"
17#include <vector>
18#include <map>
19
20namespace RDKit {
21
22extern const std::string _rgroupInputDummy;
23
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
29 // this caches the size of the previous matches vector
30 // such that the size of the current chunk can be inferred
32 // the default for Greedy/GreedyChunks is keeping only the best
33 // permutation after each call to process()
34 bool prunePermutations = true;
36
37 std::vector<std::vector<RGroupMatch>> matches;
38 std::set<int> labels;
39 std::vector<size_t> permutation;
40 unsigned int pruneLength = 0U;
42 std::map<int, std::vector<int>> userLabels;
43
44 std::vector<int> processedRlabels;
45
46 std::map<int, int> finalRlabelMapping;
48
51
52 RGroupDecompData(const std::vector<ROMOL_SPTR> &inputCores,
54
55 void addCore(const ROMol &inputCore);
56
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
106 bool finalize = false);
107
108 private:
109 void addInputCore(const ROMol &inputCore);
110};
111} // namespace RDKit
112
113#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.
const std::string _rgroupInputDummy
bool rdvalue_is(const RDValue_cast_t)
const unsigned int EMPTY_CORE_LABEL
Definition RGroupUtils.h:28
A single rgroup attached to a given core.
Definition RGroupData.h:22
std::vector< std::vector< RGroupMatch > > matches
FingerprintVarianceScoreData prunedFingerprintVarianceScoreData
RGroupDecompData(const RWMol &inputCore, RGroupDecompositionParameters inputParams)
double score(const std::vector< size_t > &permutation, FingerprintVarianceScoreData *fingerprintVarianceScoreData=nullptr) const
double scoreFromPrunedData(const std::vector< size_t > &permutation, bool reset=true)
void relabelRGroup(RGroupData &rgroup, const std::map< int, int > &mappings)
std::vector< size_t > permutation
std::map< int, std::vector< int > > userLabels
bool replaceHydrogenCoreDummy(const RGroupMatch &match, RWMol &core, const Atom &atom, const int currentLabel, const int rLabel)
RGroupDecompositionParameters params
std::map< std::string, int > newCores
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)
void addAtoms(RWMol &mol, const std::vector< std::pair< Atom *, Atom * > > &atomsToAdd)
RGroupDecompositionProcessResult process(bool pruneMatches, bool finalize=false)
std::map< int, RCore > cores
void setRlabel(Atom *atom, int rlabel)
void addCore(const ROMol &inputCore)
std::vector< int > processedRlabels
int getRlabel(Atom *atom) const
std::map< int, int > finalRlabelMapping
void addCoreUserLabels(const RWMol &core, std::set< int > &userLabels)
RGroupDecompData(const std::vector< ROMOL_SPTR > &inputCores, RGroupDecompositionParameters inputParams)
std::vector< RGroupMatch > GetCurrentBestPermutation() const
RGroupMatch is the decomposition for a single molecule.
Definition RGroupMatch.h:19