File: Normalize.h

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (95 lines) | stat: -rw-r--r-- 3,062 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
//  Copyright (C) 2018 Susan H. Leung
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//
/*! \file Normalize.h

        \brief Defines the Normalizer class.

*/
#include <RDGeneral/export.h>
#ifndef __RD_NORMALIZE_H__
#define __RD_NORMALIZE_H__

#include <Catalogs/Catalog.h>
#include <GraphMol/MolStandardize/TransformCatalog/TransformCatalogEntry.h>
#include <GraphMol/MolStandardize/TransformCatalog/TransformCatalogParams.h>
#include <GraphMol/MolStandardize/MolStandardize.h>

namespace RDKit {
class RWMol;
class ROMol;

namespace MolStandardize {
RDKIT_MOLSTANDARDIZE_EXPORT extern const CleanupParameters
    defaultCleanupParameters;

typedef RDCatalog::HierarchCatalog<TransformCatalogEntry,
                                   TransformCatalogParams, int>
    TransformCatalog;

//! The Normalizer class for applying Normalization transforms.
/*!

  <b>Notes:</b>
    - This class is typically used to apply a series of Normalization transforms
  to correct functional groups and recombine charges.
                - Each transform is repeatedly applied until no further changes
  occur.
*/

class RDKIT_MOLSTANDARDIZE_EXPORT Normalizer {
 public:
  Normalizer();
  //! Construct a Normalizer with a particular normalizeFile and maxRestarts
  Normalizer(const std::string normalizeFile, const unsigned int maxRestarts);
  //! making Normalizer objects non-copyable
  Normalizer(const Normalizer &other) = delete;
  Normalizer &operator=(Normalizer const &) = delete;
  ~Normalizer();

  //! Apply a series of Normalization transforms to correct functional groups
  //! and recombine charges.
  /*!
    <b>Notes:</b>
      - A series of transforms are applied to the molecule. For each
    Normalization, the transform is applied repeatedly until no further changes
    occur.
      - If any changes occurred, we go back and start from the first
    Normalization again, in case the changes mean an earlier transform is now
    applicable.
                        - The molecule is returned once the entire series of
    Normalizations cause no further changes or if max_restarts (default 200) is
    reached.
  */
  ROMol *normalize(const ROMol &mol);
  struct Product {
    std::string Smiles;
    boost::shared_ptr<ROMol> Mol;
    Product(std::string smiles, boost::shared_ptr<ROMol> &mol)
        : Smiles(smiles), Mol(mol) {}

    // sorting products alphabetically by SMILES
    bool operator<(const Product &pdt) const { return (Smiles < pdt.Smiles); }
  };

 private:
  TransformCatalog *d_tcat;
  unsigned int MAX_RESTARTS;

  ROMol *normalizeFragment(
      const ROMol &mol,
      const std::vector<std::shared_ptr<ChemicalReaction>> &transforms);
  boost::shared_ptr<ROMol> applyTransform(const ROMol &mol,
                                          ChemicalReaction &rule);

};  // Normalizer class
}  // namespace MolStandardize
}  // namespace RDKit

#endif