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  //! Construct a Normalizer with a particular stream (with parameters) and
52  //! maxRestarts
53  Normalizer(std::istream &normalizeStream, const unsigned int maxRestarts);
54  //! making Normalizer objects non-copyable
55  Normalizer(const Normalizer &other) = delete;
56  Normalizer &operator=(Normalizer const &) = delete;
57  ~Normalizer();
58 
59  //! Apply a series of Normalization transforms to correct functional groups
60  //! and recombine charges.
61  /*!
62  <b>Notes:</b>
63  - A series of transforms are applied to the molecule. For each
64  Normalization, the transform is applied repeatedly until no further changes
65  occur.
66  - If any changes occurred, we go back and start from the first
67  Normalization again, in case the changes mean an earlier transform is now
68  applicable.
69  - The molecule is returned once the entire series of
70  Normalizations cause no further changes or if max_restarts (default 200) is
71  reached.
72  */
73  ROMol *normalize(const ROMol &mol);
74  struct Product {
75  std::string Smiles;
76  boost::shared_ptr<ROMol> Mol;
77  Product(std::string smiles, boost::shared_ptr<ROMol> &mol)
78  : Smiles(smiles), Mol(mol) {}
79 
80  // sorting products alphabetically by SMILES
81  bool operator<(const Product &pdt) const { return (Smiles < pdt.Smiles); }
82  };
83 
84  private:
85  const TransformCatalog *d_tcat;
86  unsigned int MAX_RESTARTS;
87 
88  boost::shared_ptr<ROMol> normalizeFragment(
89  const ROMol &mol,
90  const std::vector<std::shared_ptr<ChemicalReaction>> &transforms);
91  boost::shared_ptr<ROMol> applyTransform(const boost::shared_ptr<ROMol> mol,
92  ChemicalReaction &rule);
93 
94 }; // Normalizer class
95 } // namespace MolStandardize
96 } // namespace RDKit
97 
98 #endif
MolStandardize.h
RDKit::MolStandardize::Normalizer
The Normalizer class for applying Normalization transforms.
Definition: Normalize.h:46
RDKit::MolStandardize::Normalizer::Product::Mol
boost::shared_ptr< ROMol > Mol
Definition: Normalize.h:76
TransformCatalogParams.h
RDKit::MolStandardize::Normalizer::Product::Product
Product(std::string smiles, boost::shared_ptr< ROMol > &mol)
Definition: Normalize.h:77
TransformCatalogEntry.h
RDKit::MolStandardize::Normalizer::Product::operator<
bool operator<(const Product &pdt) const
Definition: Normalize.h:81
RDKit::MolStandardize::Normalizer::Product
Definition: Normalize.h:74
RDKit::MolStandardize::Normalizer::Product::Smiles
std::string Smiles
Definition: Normalize.h:75
RDCatalog::HierarchCatalog
A Catalog with a hierarchical structure.
Definition: Catalog.h:135
Catalog.h
RDKit::ROMol
Definition: ROMol.h:171
RDKit::ChemicalReaction
This is a class for storing and applying general chemical reactions.
Definition: Reaction.h:119
RDKit::MolStandardize::normalize
RDKIT_MOLSTANDARDIZE_EXPORT RWMol * normalize(const RWMol *mol, const CleanupParameters &params=defaultCleanupParameters)
Works the same as Normalizer().normalize(mol)
RDKit
Std stuff.
Definition: Atom.h:30
RDKIT_MOLSTANDARDIZE_EXPORT
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition: export.h:437
RDKit::MolStandardize::defaultCleanupParameters
const RDKIT_MOLSTANDARDIZE_EXPORT CleanupParameters defaultCleanupParameters
Definition: Fragment.h:25
RDKit::MolStandardize::TransformCatalog
RDCatalog::HierarchCatalog< TransformCatalogEntry, TransformCatalogParams, int > TransformCatalog
Definition: Normalize.h:34
export.h