Loading...
Searching...
No Matches
RGroupDecompData.h
Go to the documentation of this file.
//
// Copyright (C) 2017-2022 Novartis Institutes for BioMedical Research and
// other RDKit contributors
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#ifndef RGROUP_DECOMP_DATA
#define RGROUP_DECOMP_DATA
#include "RGroupCore.h"
#include "RGroupScore.h"
#include "RGroupFingerprintScore.h"
#include <vector>
#include <map>
namespace RDKit {
extern const std::string _rgroupInputDummy;
struct RGroupDecompData {
// matches[mol_idx] == vector of potential matches
std::map<int, RCore> cores;
std::map<std::string, int> newCores; // new "cores" found along the way
int newCoreLabel = EMPTY_CORE_LABEL;
// this caches the size of the previous matches vector
// such that the size of the current chunk can be inferred
size_t previousMatchSize = 0;
// the default for Greedy/GreedyChunks is keeping only the best
// permutation after each call to process()
bool prunePermutations = true;
RGroupDecompositionParameters params;
std::vector<std::vector<RGroupMatch>> matches;
std::set<int> labels;
std::vector<size_t> permutation;
unsigned int pruneLength = 0U;
FingerprintVarianceScoreData prunedFingerprintVarianceScoreData;
std::map<int, std::vector<int>> userLabels;
std::vector<int> processedRlabels;
std::map<int, int> finalRlabelMapping;
mutable RGroupScorer rGroupScorer;
RGroupDecompData(const RWMol &inputCore,
RGroupDecompositionParameters inputParams);
RGroupDecompData(const std::vector<ROMOL_SPTR> &inputCores,
RGroupDecompositionParameters inputParams);
void addCore(const ROMol &inputCore);
void prepareCores();
void setRlabel(Atom *atom, int rlabel);
int getRlabel(Atom *atom) const;
double scoreFromPrunedData(const std::vector<size_t> &permutation,
bool reset = true);
void prune();
// Return the RGroups with the current "best" permutation
// of matches.
std::vector<RGroupMatch> GetCurrentBestPermutation() const;
class UsedLabels {
public:
std::set<int> labels_used;
bool add(int rlabel);
int next();
};
void addCoreUserLabels(const RWMol &core, std::set<int> &userLabels);
void addAtoms(RWMol &mol,
const std::vector<std::pair<Atom *, Atom *>> &atomsToAdd);
bool replaceHydrogenCoreDummy(const RGroupMatch &match, RWMol &core,
const Atom &atom, const int currentLabel,
const int rLabel);
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 relabelRGroup(RGroupData &rgroup, const std::map<int, int> &mappings);
// relabel the core and sidechains using the specified user labels
// if matches exist for non labelled atoms, these are added as well
void relabel();
double score(const std::vector<size_t> &permutation,
FingerprintVarianceScoreData *fingerprintVarianceScoreData =
nullptr) const;
RGroupDecompositionProcessResult process(bool pruneMatches,
bool finalize = false);
private:
void addInputCore(const ROMol &inputCore);
};
} // namespace RDKit
#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:285
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