RDKit: RGroupUtils.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
RGroupUtils.h
Go to the documentation of this file.
1//
2// Copyright (C) 2017 Novartis Institutes for BioMedical Research
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#ifndef RGROUP_UTILS
11#define RGROUP_UTILS
12
13#include <GraphMol/RDKitBase.h>
14#include <GraphMol/ChemTransforms/MolFragmenter.h>
15#include "RGroupDecomp.h"
16
17#include <map>
18namespace RDKit {
19
20 RDKIT_RGROUPDECOMPOSITION_EXPORT extern const std::string RLABEL;
21 RDKIT_RGROUPDECOMPOSITION_EXPORT extern const std::string RLABEL_TYPE;
22 RDKIT_RGROUPDECOMPOSITION_EXPORT extern const std::string RLABEL_CORE_INDEX;
23 RDKIT_RGROUPDECOMPOSITION_EXPORT extern const std::string SIDECHAIN_RLABELS;
24 RDKIT_RGROUPDECOMPOSITION_EXPORT extern const std::string done;
25 RDKIT_RGROUPDECOMPOSITION_EXPORT extern const std::string
26 UNLABELED_CORE_ATTACHMENT;
27
28 const unsigned int EMPTY_CORE_LABEL = -100000;
29
30// Various places where rgroups can be labeled
31// the order of precedence
32 enum class Labelling {
33 RGROUP_LABELS,
34 ISOTOPE_LABELS,
35 ATOMMAP_LABELS,
36 INDEX_LABELS,
37 DUMMY_LABELS,
38 INTERNAL_LABELS
39};
40
41//! return the user friendly name for the given labelling
42std::string labellingToString(Labelling type);
43
44//! Get the RLabels,atom mapping for the current molecule
45std::map<int, Atom *> getRlabels(const RWMol &mol);
46
47//! Remove the user labels from the atom
48 void clearInputLabels(Atom *atom);
49
50//! Set the rgroup label for the current atom, this also sets the
51/// appropriate MDL or other label
52 bool setLabel(Atom *atom, int label, std::set<int> &labels, int &maxLabel,
53 bool relabel, Labelling type);
54
55//! Returns true if the core has a dummy atom
56 bool hasDummy(const RWMol &core);
57
58//! Returns true if the core atom is either an atom with multiple
59/// connections or an atom with a single connection that has no user
60/// defined rgroup label
61 bool isAtomWithMultipleNeighborsOrNotDummyRGroupAttachment(const Atom &atom);
62
63//! Return true if the atom has a user-defined R group label
64 bool isUserRLabel(const Atom &atom);
65
66// ! Return true if the atom is a terminal dummy R group (user labelled or
67// unlabelled)
68 bool isDummyRGroupAttachment(const Atom &atom);
69
70//! Returns true if the core atom is either a dummy atom with multiple
71/// connections or a dummy atom with a single connection that has no user
72/// defined rgroup label
73 inline bool isAnyAtomWithMultipleNeighborsOrNotUserRLabel(const Atom &atom) {
74 if (atom.getAtomicNum()) {
75 return false;
76 }
77 return isAtomWithMultipleNeighborsOrNotDummyRGroupAttachment(atom);
78}
79
80//! Returns a JSON form
81/// The prefix argument is added to each line in the output
82 RDKIT_RGROUPDECOMPOSITION_EXPORT std::string toJSON(
83 const RGroupRow &rgr, const std::string &prefix = "");
84//! Returns a JSON form
85/// The prefix argument is added to each line in the output
86 RDKIT_RGROUPDECOMPOSITION_EXPORT std::string toJSON(
87 const RGroupRows &rgr, const std::string &prefix = "");
88//! Returns a JSON form
89/// The prefix argument is added to each line in the output
90 RDKIT_RGROUPDECOMPOSITION_EXPORT std::string toJSON(
91 const RGroupColumn &rgr, const std::string &prefix = "");
92//! Returns a JSON form
93/// The prefix argument is added to each line in the output
94 RDKIT_RGROUPDECOMPOSITION_EXPORT std::string toJSON(
95 const RGroupColumns &rgr, const std::string &prefix = "");
96
97//! Relabel dummy atoms bearing an R-group mapping (as
98/// atom map number, isotope or MDLRGroup label) such that
99/// they will be displayed by the rendering code as R# rather
100/// than #*, *:#, #*:#, etc. By default, only the MDLRGroup label
101/// is retained on output; this may be configured through the
102/// outputLabels parameter.
103/// In case there are multiple potential R-group mappings,
104/// the priority on input is Atom map number > Isotope > MDLRGroup.
105/// The inputLabels parameter allows to configure which mappings
106/// are taken into consideration.
107 RDKIT_RGROUPDECOMPOSITION_EXPORT void relabelMappedDummies(
108 ROMol &mol, unsigned int inputLabels = AtomMap | Isotope | MDLRGroup,
109 unsigned int outputLabels = MDLRGroup);
110
111} // namespace RDKit
112
113#endif
MolFragmenter.h
RDKitBase.h
pulls in the core RDKit functionality
RGroupDecomp.h
RDKit::Atom
The class for representing atoms.
Definition Atom.h:74
RDKit::Atom::getAtomicNum
int getAtomicNum() const
returns our atomic number
Definition Atom.h:145
RDKit::ROMol
Definition ROMol.h:199
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
RDKIT_RGROUPDECOMPOSITION_EXPORT
#define RDKIT_RGROUPDECOMPOSITION_EXPORT
Definition export.h:473
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::RLABEL_CORE_INDEX
RDKIT_RGROUPDECOMPOSITION_EXPORT const std::string RLABEL_CORE_INDEX
RDKit::labellingToString
std::string labellingToString(Labelling type)
return the user friendly name for the given labelling
RDKit::done
RDKIT_RGROUPDECOMPOSITION_EXPORT const std::string done
RDKit::UNLABELED_CORE_ATTACHMENT
RDKIT_RGROUPDECOMPOSITION_EXPORT const std::string UNLABELED_CORE_ATTACHMENT
RDKit::RGroupRow
std::map< std::string, ROMOL_SPTR > RGroupRow
Definition RGroupDecomp.h:31
RDKit::RGroupColumn
std::vector< ROMOL_SPTR > RGroupColumn
Definition RGroupDecomp.h:32
RDKit::relabelMappedDummies
RDKIT_RGROUPDECOMPOSITION_EXPORT void relabelMappedDummies(ROMol &mol, unsigned int inputLabels=AtomMap|Isotope|MDLRGroup, unsigned int outputLabels=MDLRGroup)
RDKit::isDummyRGroupAttachment
bool isDummyRGroupAttachment(const Atom &atom)
RDKit::setLabel
bool setLabel(Atom *atom, int label, std::set< int > &labels, int &maxLabel, bool relabel, Labelling type)
RDKit::clearInputLabels
void clearInputLabels(Atom *atom)
Remove the user labels from the atom.
RDKit::RGroupColumns
std::map< std::string, RGroupColumn > RGroupColumns
Definition RGroupDecomp.h:35
RDKit::isAtomWithMultipleNeighborsOrNotDummyRGroupAttachment
bool isAtomWithMultipleNeighborsOrNotDummyRGroupAttachment(const Atom &atom)
RDKit::RLABEL
RDKIT_RGROUPDECOMPOSITION_EXPORT const std::string RLABEL
RDKit::hasDummy
bool hasDummy(const RWMol &core)
Returns true if the core has a dummy atom.
RDKit::SIDECHAIN_RLABELS
RDKIT_RGROUPDECOMPOSITION_EXPORT const std::string SIDECHAIN_RLABELS
RDKit::toJSON
RDKIT_RGROUPDECOMPOSITION_EXPORT std::string toJSON(const RGroupRow &rgr, const std::string &prefix="")
RDKit::isAnyAtomWithMultipleNeighborsOrNotUserRLabel
bool isAnyAtomWithMultipleNeighborsOrNotUserRLabel(const Atom &atom)
Definition RGroupUtils.h:73
RDKit::RLABEL_TYPE
RDKIT_RGROUPDECOMPOSITION_EXPORT const std::string RLABEL_TYPE
RDKit::EMPTY_CORE_LABEL
const unsigned int EMPTY_CORE_LABEL
Definition RGroupUtils.h:28
RDKit::isUserRLabel
bool isUserRLabel(const Atom &atom)
Return true if the atom has a user-defined R group label.
RDKit::RGroupRows
std::vector< RGroupRow > RGroupRows
Definition RGroupDecomp.h:34
RDKit::getRlabels
std::map< int, Atom * > getRlabels(const RWMol &mol)
Get the RLabels,atom mapping for the current molecule.
RDKit::Labelling
Labelling
Definition RGroupUtils.h:32
RDKit::Labelling::DUMMY_LABELS
@ DUMMY_LABELS
Definition RGroupUtils.h:37
RDKit::Labelling::INDEX_LABELS
@ INDEX_LABELS
Definition RGroupUtils.h:36
RDKit::Labelling::ISOTOPE_LABELS
@ ISOTOPE_LABELS
Definition RGroupUtils.h:34
RDKit::Labelling::RGROUP_LABELS
@ RGROUP_LABELS
Definition RGroupUtils.h:33
RDKit::Labelling::ATOMMAP_LABELS
@ ATOMMAP_LABELS
Definition RGroupUtils.h:35
RDKit::Labelling::INTERNAL_LABELS
@ INTERNAL_LABELS
Definition RGroupUtils.h:38