RDKit
Open-source cheminformatics and machine learning.
Normalize.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2018 Susan H. Leung
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 
24 namespace RDKit {
25 class RWMol;
26 class ROMol;
27 
28 namespace MolStandardize {
29 RDKIT_MOLSTANDARDIZE_EXPORT extern const CleanupParameters
31 
32 typedef RDCatalog::HierarchCatalog<TransformCatalogEntry,
33  TransformCatalogParams, int>
35 
36 //! The Normalizer class for applying Normalization transforms.
37 /*!
38 
39  <b>Notes:</b>
40  - This class is typically used to apply a series of Normalization transforms
41  to correct functional groups and recombine charges.
42  - Each transform is repeatedly applied until no further changes
43  occur.
44 */
45 
47  public:
48  Normalizer();
49  //! Construct a Normalizer with a particular normalizeFile and maxRestarts
50  Normalizer(const std::string normalizeFile, const unsigned int maxRestarts);
51  //! making Normalizer objects non-copyable
52  Normalizer(const Normalizer &other) = delete;
53  Normalizer &operator=(Normalizer const &) = delete;
54  ~Normalizer();
55 
56  //! Apply a series of Normalization transforms to correct functional groups
57  //! and recombine charges.
58  /*!
59  <b>Notes:</b>
60  - A series of transforms are applied to the molecule. For each
61  Normalization, the transform is applied repeatedly until no further changes
62  occur.
63  - If any changes occurred, we go back and start from the first
64  Normalization again, in case the changes mean an earlier transform is now
65  applicable.
66  - The molecule is returned once the entire series of
67  Normalizations cause no further changes or if max_restarts (default 200) is
68  reached.
69  */
70  ROMol *normalize(const ROMol &mol);
71  struct Product {
72  std::string Smiles;
73  boost::shared_ptr<ROMol> Mol;
74  Product(std::string smiles, boost::shared_ptr<ROMol> &mol)
75  : Smiles(smiles), Mol(mol) {}
76 
77  // sorting products alphabetically by SMILES
78  bool operator<(const Product &pdt) const { return (Smiles < pdt.Smiles); }
79  };
80 
81  private:
82  TransformCatalog *d_tcat;
83  unsigned int MAX_RESTARTS;
84 
85  ROMol *normalizeFragment(
86  const ROMol &mol,
87  const std::vector<std::shared_ptr<ChemicalReaction>> &transforms);
88  boost::shared_ptr<ROMol> applyTransform(const ROMol &mol,
89  ChemicalReaction &rule);
90 
91 }; // Normalizer class
92 } // namespace MolStandardize
93 } // namespace RDKit
94 
95 #endif
bool operator<(const Product &pdt) const
Definition: Normalize.h:78
RDKIT_MOLSTANDARDIZE_EXPORT RWMol * normalize(const RWMol *mol, const CleanupParameters &params=defaultCleanupParameters)
Works the same as Normalizer().normalize(mol)
This is a class for storing and applying general chemical reactions.
Definition: Reaction.h:118
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition: Fragment.h:25
A Catalog with a hierarchical structure.
Definition: Catalog.h:135
Std stuff.
Definition: Atom.h:30
The Normalizer class for applying Normalization transforms.
Definition: Normalize.h:46
RDCatalog::HierarchCatalog< TransformCatalogEntry, TransformCatalogParams, int > TransformCatalog
Definition: Normalize.h:34
boost::shared_ptr< ROMol > Mol
Definition: Normalize.h:73
Defines the CleanupParameters and some convenience functions.
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition: export.h:424
Product(std::string smiles, boost::shared_ptr< ROMol > &mol)
Definition: Normalize.h:74