RDKit: Normalize.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
Normalize.h
Go to the documentation of this file.
1//
2// Copyright (C) 2018-2021 Susan H. Leung and other RDKit contributors
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/*! \file Normalize.h
11
12 \brief Defines the Normalizer class.
13
14*/
15#include <RDGeneral/export.h>
16#ifndef RD_NORMALIZE_H
17#define RD_NORMALIZE_H
18
19#include <Catalogs/Catalog.h>
20#include <GraphMol/MolStandardize/TransformCatalog/TransformCatalogEntry.h>
21#include <GraphMol/MolStandardize/TransformCatalog/TransformCatalogParams.h>
22#include <GraphMol/MolStandardize/MolStandardize.h>
23
24namespace RDKit {
25class RWMol;
26class ROMol;
27
28namespace MolStandardize {
29 RDKIT_MOLSTANDARDIZE_EXPORT extern const CleanupParameters
30 defaultCleanupParameters;
31
32typedef RDCatalog::HierarchCatalog<TransformCatalogEntry,
33 TransformCatalogParams, int>
34 TransformCatalog;
35 typedef std::pair<std::string, ROMOL_SPTR> SmilesMolPair;
36
37//! The Normalizer class for applying Normalization transforms.
38/*!
39
40 <b>Notes:</b>
41 - This class is typically used to apply a series of Normalization transforms
42 to correct functional groups and recombine charges.
43 - Each transform is repeatedly applied until no further changes
44 occur.
45*/
46
47 class RDKIT_MOLSTANDARDIZE_EXPORT Normalizer {
48 public:
49 Normalizer();
50 //! Construct a Normalizer with a particular normalizeFile and maxRestarts
51 Normalizer(const std::string normalizeFile, const unsigned int maxRestarts);
52 //! Construct a Normalizer with a particular stream (with parameters) and
53 //! maxRestarts
54 Normalizer(std::istream &normalizeStream, const unsigned int maxRestarts);
55 //! Construct a Normalizer with a set of data and maxRestarts
56 Normalizer(
57 const std::vector<std::pair<std::string, std::string>> &normalizations,
58 const unsigned int maxRestarts);
59 //! making Normalizer objects non-copyable
60 Normalizer(const Normalizer &other) = delete;
61 Normalizer &operator=(Normalizer const &) = delete;
62 ~Normalizer();
63
64 //! Apply a series of Normalization transforms to correct functional groups
65 //! and recombine charges.
66 /*!
67 <b>Notes:</b>
68 - A series of transforms are applied to the molecule. For each
69 Normalization, the transform is applied repeatedly until no further changes
70 occur.
71 - If any changes occurred, we go back and start from the first
72 Normalization again, in case the changes mean an earlier transform is now
73 applicable.
74 - The molecule is returned once the entire series of
75 Normalizations cause no further changes or if max_restarts (default 200) is
76 reached.
77 */
78 ROMol *normalize(const ROMol &mol);
79
80 void normalizeInPlace(RWMol &mol);
81
82 private:
83 const TransformCatalog *d_tcat;
84 unsigned int MAX_RESTARTS;
85
86 ROMOL_SPTR normalizeFragment(
87 const ROMol &mol,
88 const std::vector<std::shared_ptr<ChemicalReaction>> &transforms) const;
89 SmilesMolPair applyTransform(const ROMOL_SPTR &mol,
90 ChemicalReaction &rule) const;
91
92}; // Normalizer class
93
94// caller owns the returned pointer
95 inline Normalizer *normalizerFromParams(const CleanupParameters &params) {
96 if (params.normalizationData.empty()) {
97 return new Normalizer(params.normalizations, params.maxRestarts);
98 } else {
99 return new Normalizer(params.normalizationData, params.maxRestarts);
100 }
101}
102
103} // namespace MolStandardize
104} // namespace RDKit
105
106#endif
Catalog.h
MolStandardize.h
Defines the CleanupParameters and some convenience functions.
TransformCatalogEntry.h
TransformCatalogParams.h
RDKit::ChemicalReaction
This is a class for storing and applying general chemical reactions.
Definition Reaction.h:121
RDKit::MolStandardize::Normalizer
The Normalizer class for applying Normalization transforms.
Definition Normalize.h:47
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer(const Normalizer &other)=delete
making Normalizer objects non-copyable
RDKit::MolStandardize::Normalizer::normalizeInPlace
void normalizeInPlace(RWMol &mol)
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer(const std::vector< std::pair< std::string, std::string > > &normalizations, const unsigned int maxRestarts)
Construct a Normalizer with a set of data and maxRestarts.
RDKit::MolStandardize::Normalizer::normalize
ROMol * normalize(const ROMol &mol)
RDKit::MolStandardize::Normalizer::~Normalizer
~Normalizer()
RDKit::MolStandardize::Normalizer::operator=
Normalizer & operator=(Normalizer const &)=delete
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer(std::istream &normalizeStream, const unsigned int maxRestarts)
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer()
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer(const std::string normalizeFile, const unsigned int maxRestarts)
Construct a Normalizer with a particular normalizeFile and maxRestarts.
RDKit::MolStandardize::TransformCatalogEntry
Definition TransformCatalogEntry.h:25
RDKit::MolStandardize::TransformCatalogParams
Definition TransformCatalogParams.h:26
RDKit::ROMol
Definition ROMol.h:199
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
export.h
RDKIT_MOLSTANDARDIZE_EXPORT
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition export.h:369
RDKit::MolStandardize
Definition AcidBaseCatalogEntry.h:22
RDKit::MolStandardize::TransformCatalog
RDCatalog::HierarchCatalog< TransformCatalogEntry, TransformCatalogParams, int > TransformCatalog
Definition Normalize.h:34
RDKit::MolStandardize::normalizerFromParams
Normalizer * normalizerFromParams(const CleanupParameters &params)
Definition Normalize.h:95
RDKit::MolStandardize::defaultCleanupParameters
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition Fragment.h:25
RDKit::MolStandardize::SmilesMolPair
std::pair< std::string, ROMOL_SPTR > SmilesMolPair
Definition Normalize.h:35
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::ROMOL_SPTR
boost::shared_ptr< ROMol > ROMOL_SPTR
Definition ChemTransforms.h:22
RDKit::MolStandardize::CleanupParameters
Definition MolStandardize.h:41
RDKit::MolStandardize::CleanupParameters::normalizations
std::string normalizations
Definition MolStandardize.h:48
RDKit::MolStandardize::CleanupParameters::normalizationData
std::vector< std::pair< std::string, std::string > > normalizationData
Definition MolStandardize.h:80
RDKit::MolStandardize::CleanupParameters::maxRestarts
int maxRestarts
Definition MolStandardize.h:52