RDKit
Open-source cheminformatics and machine learning.
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>
23
24namespace RDKit {
25class RWMol;
26class ROMol;
27
28namespace MolStandardize {
29RDKIT_MOLSTANDARDIZE_EXPORT extern const CleanupParameters
31
32typedef RDCatalog::HierarchCatalog<TransformCatalogEntry,
33 TransformCatalogParams, int>
35typedef 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
48 public:
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
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;
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 private:
81 const TransformCatalog *d_tcat;
82 unsigned int MAX_RESTARTS;
83
84 ROMOL_SPTR normalizeFragment(
85 const ROMol &mol,
86 const std::vector<std::shared_ptr<ChemicalReaction>> &transforms) const;
87 SmilesMolPair applyTransform(const ROMOL_SPTR &mol,
88 ChemicalReaction &rule) const;
89
90}; // Normalizer class
91
92// caller owns the returned pointer
94 if (params.normalizationData.empty()) {
95 return new Normalizer(params.normalizations, params.maxRestarts);
96 } else {
97 return new Normalizer(params.normalizationData, params.maxRestarts);
98 }
99}
100
101} // namespace MolStandardize
102} // namespace RDKit
103
104#endif
A Catalog with a hierarchical structure.
Definition: Catalog.h:135
This is a class for storing and applying general chemical reactions.
Definition: Reaction.h:121
The Normalizer class for applying Normalization transforms.
Definition: Normalize.h:47
Normalizer(const Normalizer &other)=delete
making Normalizer objects non-copyable
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.
ROMol * normalize(const ROMol &mol)
Normalizer & operator=(Normalizer const &)=delete
Normalizer(std::istream &normalizeStream, const unsigned int maxRestarts)
Normalizer(const std::string normalizeFile, const unsigned int maxRestarts)
Construct a Normalizer with a particular normalizeFile and maxRestarts.
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition: export.h:313
RDCatalog::HierarchCatalog< TransformCatalogEntry, TransformCatalogParams, int > TransformCatalog
Definition: Normalize.h:34
Normalizer * normalizerFromParams(const CleanupParameters &params)
Definition: Normalize.h:93
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition: Fragment.h:25
std::pair< std::string, ROMOL_SPTR > SmilesMolPair
Definition: Normalize.h:35
Std stuff.
Definition: Abbreviations.h:18
boost::shared_ptr< ROMol > ROMOL_SPTR
std::vector< std::pair< std::string, std::string > > normalizationData