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

Evaluates a boolean expression over multiple substructure queries against a target molecular graph. More...

#include <MultiSubstructureSearch.hpp>

Public Types

typedef std::shared_ptr< MultiSubstructureSearchSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated MultiSubstructureSearch instances. More...
 

Public Member Functions

 MultiSubstructureSearch ()
 Constructs and initializes a MultiSubstructureSearch instance. More...
 
 MultiSubstructureSearch (const MultiSubstructureSearch &)=delete
 
 ~MultiSubstructureSearch ()
 Destructor. More...
 
MultiSubstructureSearchoperator= (const MultiSubstructureSearch &)=delete
 
bool matches (const MolecularGraph &molgraph)
 Evaluates the configured boolean substructure expression against the target molecular graph molgraph. More...
 
void addSubstructure (const MolecularGraph::SharedPointer &molgraph)
 Appends a substructure query to the internal substructure list. More...
 
std::size_t getNumSubstructures () const
 Returns the number of stored substructure queries. More...
 
void clear ()
 Removes all stored substructure queries and clears the compiled expression. More...
 
void setup (const std::string &qry_expr="")
 Compiles the boolean substructure expression qry_expr. More...
 
std::string validate (const std::string &qry_expr, std::size_t max_substr_id)
 Validates the syntax of qry_expr without compiling it for evaluation. More...
 

Detailed Description

Evaluates a boolean expression over multiple substructure queries against a target molecular graph.

Substructure query molecular graphs are added via addSubstructure() and referenced in the boolean expression by their 1-based insertion order (e.g. "1 AND (2 OR NOT 3)"). The expression is parsed by setup() and subsequently evaluated for each target molecular graph passed to matches().

Since
1.2

Member Typedef Documentation

◆ SharedPointer

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

Constructor & Destructor Documentation

◆ MultiSubstructureSearch() [1/2]

CDPL::Chem::MultiSubstructureSearch::MultiSubstructureSearch ( )

Constructs and initializes a MultiSubstructureSearch instance.

◆ MultiSubstructureSearch() [2/2]

CDPL::Chem::MultiSubstructureSearch::MultiSubstructureSearch ( const MultiSubstructureSearch )
delete

◆ ~MultiSubstructureSearch()

CDPL::Chem::MultiSubstructureSearch::~MultiSubstructureSearch ( )

Destructor.

Destroys the MultiSubstructureSearch instance and frees all allocated resources.

Member Function Documentation

◆ operator=()

MultiSubstructureSearch& CDPL::Chem::MultiSubstructureSearch::operator= ( const MultiSubstructureSearch )
delete

◆ matches()

bool CDPL::Chem::MultiSubstructureSearch::matches ( const MolecularGraph molgraph)

Evaluates the configured boolean substructure expression against the target molecular graph molgraph.

Parameters
molgraphThe target molecular graph.
Returns
true if the boolean expression evaluates to true for molgraph, and false otherwise (also false when no expression has been compiled by setup() yet).

◆ addSubstructure()

void CDPL::Chem::MultiSubstructureSearch::addSubstructure ( const MolecularGraph::SharedPointer molgraph)

Appends a substructure query to the internal substructure list.

The query receives the 1-based ID equal to the new value of getNumSubstructures(), which is how it is referenced in the boolean expression.

Parameters
molgraphA smart pointer to the substructure query molecular graph.

◆ getNumSubstructures()

std::size_t CDPL::Chem::MultiSubstructureSearch::getNumSubstructures ( ) const

Returns the number of stored substructure queries.

Returns
The number of stored substructure queries.

◆ clear()

void CDPL::Chem::MultiSubstructureSearch::clear ( )

Removes all stored substructure queries and clears the compiled expression.

◆ setup()

void CDPL::Chem::MultiSubstructureSearch::setup ( const std::string &  qry_expr = "")

Compiles the boolean substructure expression qry_expr.

Substructure IDs in the expression are 1-based and refer to the order in which queries were added via addSubstructure(). Supported operators are AND, OR, XOR and NOT.

Parameters
qry_exprThe boolean expression to compile (an empty string clears the compiled expression).

◆ validate()

std::string CDPL::Chem::MultiSubstructureSearch::validate ( const std::string &  qry_expr,
std::size_t  max_substr_id 
)

Validates the syntax of qry_expr without compiling it for evaluation.

Parameters
qry_exprThe expression to validate.
max_substr_idLargest accepted substructure ID; expressions referencing larger IDs are rejected.
Returns
An empty string if qry_expr is well-formed, otherwise an error message describing the failure.

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