Loading...
Searching...
No Matches
Normalize.h
Go to the documentation of this file.
//
// Copyright (C) 2018-2021 Susan H. Leung and other RDKit contributors
//
// @@ 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;
typedef std::pair<std::string, ROMOL_SPTR> SmilesMolPair;
//! 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);
//! Construct a Normalizer with a particular stream (with parameters) and
//! maxRestarts
Normalizer(std::istream &normalizeStream, const unsigned int maxRestarts);
//! Construct a Normalizer with a set of data and maxRestarts
Normalizer(
const std::vector<std::pair<std::string, std::string>> &normalizations,
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);
void normalizeInPlace(RWMol &mol);
private:
const TransformCatalog *d_tcat;
unsigned int MAX_RESTARTS;
ROMOL_SPTR normalizeFragment(
const ROMol &mol,
const std::vector<std::shared_ptr<ChemicalReaction>> &transforms) const;
SmilesMolPair applyTransform(const ROMOL_SPTR &mol,
ChemicalReaction &rule) const;
}; // Normalizer class
// caller owns the returned pointer
inline Normalizer *normalizerFromParams(const CleanupParameters &params) {
if (params.normalizationData.empty()) {
return new Normalizer(params.normalizations, params.maxRestarts);
} else {
return new Normalizer(params.normalizationData, params.maxRestarts);
}
}
} // namespace MolStandardize
} // namespace RDKit
#endif
Catalog.h
MolStandardize.h
Defines the CleanupParameters and some convenience functions.
TransformCatalogEntry.h
TransformCatalogParams.h
RDKit::ChemicalReaction
This is a class for storing and applying general chemical reactions.
Definition Reaction.h:122
RDKit::MolStandardize::Normalizer
The Normalizer class for applying Normalization transforms.
Definition Normalize.h:47
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer(const Normalizer &other)=delete
making Normalizer objects non-copyable
RDKit::MolStandardize::Normalizer::normalizeInPlace
void normalizeInPlace(RWMol &mol)
RDKit::MolStandardize::Normalizer::Normalizer
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.
RDKit::MolStandardize::Normalizer::normalize
ROMol * normalize(const ROMol &mol)
RDKit::MolStandardize::Normalizer::~Normalizer
~Normalizer()
RDKit::MolStandardize::Normalizer::operator=
Normalizer & operator=(Normalizer const &)=delete
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer(std::istream &normalizeStream, const unsigned int maxRestarts)
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer()
RDKit::MolStandardize::Normalizer::Normalizer
Normalizer(const std::string normalizeFile, const unsigned int maxRestarts)
Construct a Normalizer with a particular normalizeFile and maxRestarts.
RDKit::MolStandardize::TransformCatalogEntry
Definition TransformCatalogEntry.h:25
RDKit::MolStandardize::TransformCatalogParams
Definition TransformCatalogParams.h:26
RDKit::ROMol
Definition ROMol.h:285
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
export.h
RDKIT_MOLSTANDARDIZE_EXPORT
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition export.h:377
RDKit::MolStandardize
Definition AcidBaseCatalogEntry.h:22
RDKit::MolStandardize::TransformCatalog
RDCatalog::HierarchCatalog< TransformCatalogEntry, TransformCatalogParams, int > TransformCatalog
Definition Normalize.h:34
RDKit::MolStandardize::normalizerFromParams
Normalizer * normalizerFromParams(const CleanupParameters &params)
Definition Normalize.h:95
RDKit::MolStandardize::defaultCleanupParameters
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition Fragment.h:25
RDKit::MolStandardize::SmilesMolPair
std::pair< std::string, ROMOL_SPTR > SmilesMolPair
Definition Normalize.h:35
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::ROMOL_SPTR
boost::shared_ptr< ROMol > ROMOL_SPTR
Definition ChemTransforms.h:23
RDKit::MolStandardize::CleanupParameters
Definition MolStandardize.h:41
RDKit::MolStandardize::CleanupParameters::normalizations
std::string normalizations
Definition MolStandardize.h:48
RDKit::MolStandardize::CleanupParameters::normalizationData
std::vector< std::pair< std::string, std::string > > normalizationData
Definition MolStandardize.h:80
RDKit::MolStandardize::CleanupParameters::maxRestarts
int maxRestarts
Definition MolStandardize.h:52