// // 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 #include namespace RDKit { extern const std::string _rgroupInputDummy; struct RGroupDecompData { // matches[mol_idx] == vector of potential matches std::map cores; std::map 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> matches; std::set labels; std::vector permutation; unsigned int pruneLength = 0U; FingerprintVarianceScoreData prunedFingerprintVarianceScoreData; std::map> userLabels; std::vector processedRlabels; std::map finalRlabelMapping; mutable RGroupScorer rGroupScorer; RGroupDecompData(const RWMol &inputCore, RGroupDecompositionParameters inputParams); RGroupDecompData(const std::vector &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 &permutation, bool reset = true); void prune(); // Return the RGroups with the current "best" permutation // of matches. std::vector GetCurrentBestPermutation() const; class UsedLabels { public: std::set labels_used; bool add(int rlabel); int next(); }; void addCoreUserLabels(const RWMol &core, std::set &userLabels); void addAtoms(RWMol &mol, const std::vector> &atomsToAdd); bool replaceHydrogenCoreDummy(const RGroupMatch &match, RWMol &core, const Atom &atom, const int currentLabel, const int rLabel); void relabelCore(RWMol &core, std::map &mappings, UsedLabels &used_labels, const std::set &indexLabels, const std::map> &extraAtomRLabels, const RGroupMatch *const match = nullptr); void relabelRGroup(RGroupData &rgroup, const std::map &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 &permutation, FingerprintVarianceScoreData *fingerprintVarianceScoreData = nullptr) const; RGroupDecompositionProcessResult process(bool pruneMatches, bool finalize = false); private: void addInputCore(const ROMol &inputCore); }; } // namespace RDKit #endif