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>
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
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
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
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.
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition export.h:337
RDCatalog::HierarchCatalog< TransformCatalogEntry, TransformCatalogParams, int > TransformCatalog
Definition Normalize.h:34
Normalizer * normalizerFromParams(const CleanupParameters &params)
Definition Normalize.h:95
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition Fragment.h:25
std::pair< std::string, ROMOL_SPTR > SmilesMolPair
Definition Normalize.h:35
Std stuff.
boost::shared_ptr< ROMol > ROMOL_SPTR
std::vector< std::pair< std::string, std::string > > normalizationData