Enable chemist-friendly depiction of R-groups (#6866)

* - added a convenience function to relabel R-groups in a chemist-friendly fashion
- exposed functionality to MinimalLib through a JSON option at molecule creation time
- added relevant unit tests

* changes in response to review

* added missing library

* fixed Python test

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
This commit is contained in:
Paolo Tosco
2023-11-11 07:16:54 +01:00
committed by GitHub
parent b58b8f1397
commit 08cc96336c
9 changed files with 406 additions and 9 deletions

View File

@@ -47,6 +47,7 @@
#include <GraphMol/ChemReactions/Reaction.h>
#include <GraphMol/ChemReactions/ReactionParser.h>
#include <GraphMol/ChemReactions/SanitizeRxn.h>
#include <GraphMol/RGroupDecomposition/RGroupUtils.h>
#include <RDGeneral/RDLog.h>
#include <sstream>
@@ -104,6 +105,7 @@ RWMol *mol_from_input(const std::string &input,
bool setAromaticity = true;
bool fastFindRings = true;
bool assignStereo = true;
bool mappedDummiesAreRGroups = false;
RWMol *res = nullptr;
boost::property_tree::ptree pt;
if (!details_json.empty()) {
@@ -117,6 +119,7 @@ RWMol *mol_from_input(const std::string &input,
LPT_OPT_GET(setAromaticity);
LPT_OPT_GET(fastFindRings);
LPT_OPT_GET(assignStereo);
LPT_OPT_GET(mappedDummiesAreRGroups);
}
try {
if (input.find("M END") != std::string::npos) {
@@ -170,6 +173,9 @@ RWMol *mol_from_input(const std::string &input,
if (mergeQueryHs) {
MolOps::mergeQueryHs(*res);
}
if (mappedDummiesAreRGroups) {
relabelMappedDummies(*res);
}
} catch (...) {
delete res;
res = nullptr;