Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | List of all members
CDPL::Chem::TautomerGenerator Class Reference

Enumerates the tautomers of a molecular graph by iteratively applying a configurable set of Chem::TautomerizationRule instances and reporting each accepted tautomer to a user-supplied callback. More...

#include <TautomerGenerator.hpp>

+ Inheritance diagram for CDPL::Chem::TautomerGenerator:

Public Types

enum  Mode {
  TOPOLOGICALLY_UNIQUE ,
  GEOMETRICALLY_UNIQUE ,
  EXHAUSTIVE
}
 Constants specifying the output tautomer filtering strategy. More...
 
typedef std::shared_ptr< TautomerGeneratorSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated TautomerGenerator instances. More...
 
typedef std::function< bool(MolecularGraph &)> CallbackFunction
 Type of the callback invoked for every generated tautomer (returning false aborts the enumeration). More...
 
typedef std::function< void(MolecularGraph &)> CustomSetupFunction
 Type of the optional setup function invoked on the input molecular graph before enumeration starts. More...
 

Public Member Functions

 TautomerGenerator ()
 Constructs the TautomerGenerator instance. More...
 
 TautomerGenerator (const TautomerGenerator &gen)
 Constructs a copy of the TautomerGenerator instance gen. More...
 
virtual ~TautomerGenerator ()
 Virtual destructor. More...
 
TautomerGeneratoroperator= (const TautomerGenerator &gen)
 Replaces the state of this generator by a copy of the state of gen. More...
 
void addTautomerizationRule (const TautomerizationRule::SharedPointer &rule)
 Registers a new tautomerization rule. More...
 
const TautomerizationRule::SharedPointergetTautomerizationRule (std::size_t idx) const
 Returns the registered tautomerization rule at index idx. More...
 
void removeTautomerizationRule (std::size_t idx)
 Removes the registered tautomerization rule at index idx. More...
 
std::size_t getNumTautomerizationRules () const
 Returns the number of registered tautomerization rules. More...
 
void setCallbackFunction (const CallbackFunction &func)
 Sets the callback invoked for every accepted output tautomer. More...
 
const CallbackFunctiongetCallbackFunction () const
 Returns the currently configured callback. More...
 
void setMode (Mode mode)
 Sets the tautomer duplicate filtering mode. More...
 
Mode getMode () const
 Returns the currently configured tautomer duplicate filtering mode. More...
 
void regardStereochemistry (bool regard)
 Specifies whether atom/bond stereochemistry shall be regarded by the tautomer duplicate detection algorithm. More...
 
bool stereochemistryRegarded () const
 Tells whether atom/bond stereochemistry is regarded by the tautomer duplicate detection algorithm. More...
 
void regardIsotopes (bool regard)
 Specifies whether atom isotope information shall be regarded by the tautomer duplicate detection algorithm. More...
 
bool isotopesRegarded () const
 Tells whether atom isotope information is regarded by the tautomer duplicate detection algorithm. More...
 
void clearCoordinates2D (bool clear)
 Specifies whether 2D atom coordinates shall be cleared from the generated tautomers. More...
 
bool coordinates2DCleared () const
 Tells whether 2D atom coordinates are cleared from the generated tautomers. More...
 
void clearCoordinates3D (bool clear)
 Specifies whether 3D atom coordinates shall be cleared from the generated tautomers. More...
 
bool coordinates3DCleared () const
 Tells whether 3D atom coordinates are cleared from the generated tautomers. More...
 
void removeResonanceDuplicates (bool remove)
 Specifies whether tautomers that differ only by resonance (no atom-connectivity change) shall be filtered out. More...
 
bool resonanceDuplicatesRemoved () const
 Tells whether resonance-only duplicates are filtered out. More...
 
void setCustomSetupFunction (const CustomSetupFunction &func)
 Sets the optional setup function invoked on the generated tautomers. More...
 
void generate (const MolecularGraph &molgraph)
 Enumerates the tautomers of molgraph and reports each accepted one to the registered callback. More...
 

Detailed Description

Enumerates the tautomers of a molecular graph by iteratively applying a configurable set of Chem::TautomerizationRule instances and reporting each accepted tautomer to a user-supplied callback.

After registering tautomerization rules (via addTautomerizationRule()) and a callback (via setCallbackFunction()), each call to generate() seeds the enumeration with the input molecular graph, applies every registered rule to every intermediate tautomer to derive the next generation, and reports each newly-generated tautomer to the callback. The Mode setting controls how various types of duplicates shall be handled.

Member Typedef Documentation

◆ SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated TautomerGenerator instances.

◆ CallbackFunction

Type of the callback invoked for every generated tautomer (returning false aborts the enumeration).

◆ CustomSetupFunction

Type of the optional setup function invoked on the input molecular graph before enumeration starts.

Member Enumeration Documentation

◆ Mode

Constants specifying the output tautomer filtering strategy.

Enumerator
TOPOLOGICALLY_UNIQUE 

Report a generated tautomer only if its molecular graph is not topologically equivalent to an already reported one.

GEOMETRICALLY_UNIQUE 

Report a generated tautomer only if its ordinary H-deplete molecular graph connection table is different from already reported ones.

EXHAUSTIVE 

Report a generated tautomer only if its molecular graph connection table is different from already reported ones.

Constructor & Destructor Documentation

◆ TautomerGenerator() [1/2]

CDPL::Chem::TautomerGenerator::TautomerGenerator ( )

Constructs the TautomerGenerator instance.

◆ TautomerGenerator() [2/2]

CDPL::Chem::TautomerGenerator::TautomerGenerator ( const TautomerGenerator gen)

Constructs a copy of the TautomerGenerator instance gen.

Parameters
genThe TautomerGenerator to copy.

◆ ~TautomerGenerator()

virtual CDPL::Chem::TautomerGenerator::~TautomerGenerator ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ operator=()

TautomerGenerator& CDPL::Chem::TautomerGenerator::operator= ( const TautomerGenerator gen)

Replaces the state of this generator by a copy of the state of gen.

Parameters
genThe source TautomerGenerator.
Returns
A reference to itself.

◆ addTautomerizationRule()

void CDPL::Chem::TautomerGenerator::addTautomerizationRule ( const TautomerizationRule::SharedPointer rule)

Registers a new tautomerization rule.

Parameters
ruleThe tautomerization rule to register.

◆ getTautomerizationRule()

const TautomerizationRule::SharedPointer& CDPL::Chem::TautomerGenerator::getTautomerizationRule ( std::size_t  idx) const

Returns the registered tautomerization rule at index idx.

Parameters
idxThe zero-based rule index.
Returns
A const reference to the rule smart pointer.
Exceptions
Base::IndexErrorif the number of rules is zero or idx is not in the range [0, getNumTautomerizationRules() - 1].

◆ removeTautomerizationRule()

void CDPL::Chem::TautomerGenerator::removeTautomerizationRule ( std::size_t  idx)

Removes the registered tautomerization rule at index idx.

Parameters
idxThe zero-based rule index.
Exceptions
Base::IndexErrorif the number of rules is zero or idx is not in the range [0, getNumTautomerizationRules() - 1].

◆ getNumTautomerizationRules()

std::size_t CDPL::Chem::TautomerGenerator::getNumTautomerizationRules ( ) const

Returns the number of registered tautomerization rules.

Returns
The rule count.

◆ setCallbackFunction()

void CDPL::Chem::TautomerGenerator::setCallbackFunction ( const CallbackFunction func)

Sets the callback invoked for every accepted output tautomer.

The callback receives the tautomer molecular graph as its argument and returns a boolean: returning false aborts the enumeration.

Parameters
funcThe new callback function.

◆ getCallbackFunction()

const CallbackFunction& CDPL::Chem::TautomerGenerator::getCallbackFunction ( ) const

Returns the currently configured callback.

Returns
A const reference to the callback function.

◆ setMode()

void CDPL::Chem::TautomerGenerator::setMode ( Mode  mode)

Sets the tautomer duplicate filtering mode.

Parameters
modeThe new duplicate filtering mode.

◆ getMode()

Mode CDPL::Chem::TautomerGenerator::getMode ( ) const

Returns the currently configured tautomer duplicate filtering mode.

Returns
The current duplicate filtering mode.

◆ regardStereochemistry()

void CDPL::Chem::TautomerGenerator::regardStereochemistry ( bool  regard)

Specifies whether atom/bond stereochemistry shall be regarded by the tautomer duplicate detection algorithm.

Parameters
regardIf true, atom/bond stereo configurations are taken into account.

◆ stereochemistryRegarded()

bool CDPL::Chem::TautomerGenerator::stereochemistryRegarded ( ) const

Tells whether atom/bond stereochemistry is regarded by the tautomer duplicate detection algorithm.

Returns
true if stereochemistry is regarded, and false otherwise.

◆ regardIsotopes()

void CDPL::Chem::TautomerGenerator::regardIsotopes ( bool  regard)

Specifies whether atom isotope information shall be regarded by the tautomer duplicate detection algorithm.

Parameters
regardIf true, atom isotope information is taken into account.

◆ isotopesRegarded()

bool CDPL::Chem::TautomerGenerator::isotopesRegarded ( ) const

Tells whether atom isotope information is regarded by the tautomer duplicate detection algorithm.

Returns
true if atom isotope information is regarded, and false otherwise.

◆ clearCoordinates2D()

void CDPL::Chem::TautomerGenerator::clearCoordinates2D ( bool  clear)

Specifies whether 2D atom coordinates shall be cleared from the generated tautomers.

Parameters
clearIf true, the output tautomers have no 2D coordinates.
Since
1.3

◆ coordinates2DCleared()

bool CDPL::Chem::TautomerGenerator::coordinates2DCleared ( ) const

Tells whether 2D atom coordinates are cleared from the generated tautomers.

Returns
true if 2D coordinates are cleared, and false otherwise.
Since
1.3

◆ clearCoordinates3D()

void CDPL::Chem::TautomerGenerator::clearCoordinates3D ( bool  clear)

Specifies whether 3D atom coordinates shall be cleared from the generated tautomers.

Parameters
clearIf true, the output tautomers have no 3D coordinates.
Since
1.3

◆ coordinates3DCleared()

bool CDPL::Chem::TautomerGenerator::coordinates3DCleared ( ) const

Tells whether 3D atom coordinates are cleared from the generated tautomers.

Returns
true if 3D coordinates are cleared, and false otherwise.
Since
1.3

◆ removeResonanceDuplicates()

void CDPL::Chem::TautomerGenerator::removeResonanceDuplicates ( bool  remove)

Specifies whether tautomers that differ only by resonance (no atom-connectivity change) shall be filtered out.

Parameters
removeIf true, resonance-only duplicates are not reported.
Since
1.1

◆ resonanceDuplicatesRemoved()

bool CDPL::Chem::TautomerGenerator::resonanceDuplicatesRemoved ( ) const

Tells whether resonance-only duplicates are filtered out.

Returns
true if resonance duplicates are removed, and false otherwise.
Since
1.1

◆ setCustomSetupFunction()

void CDPL::Chem::TautomerGenerator::setCustomSetupFunction ( const CustomSetupFunction func)

Sets the optional setup function invoked on the generated tautomers.

Parameters
funcThe new custom setup function.

◆ generate()

void CDPL::Chem::TautomerGenerator::generate ( const MolecularGraph molgraph)

Enumerates the tautomers of molgraph and reports each accepted one to the registered callback.

Parameters
molgraphThe molecular graph whose tautomers shall be generated.

The documentation for this class was generated from the following file: