![]() |
Chemical Data Processing Library C++ API - Version 1.4.0
|
Calculator that performs a bulk pairwise comparison of a single query descriptor against a stored set of target descriptors using a configurable similarity function. More...
#include <BulkSimilarityCalculator.hpp>
Public Types | |
| typedef DT | Descriptor |
| The descriptor type. More... | |
| typedef std::shared_ptr< DT > | DescriptorPointer |
| A smart pointer to a stored descriptor. More... | |
| typedef SVT | SimilarityValue |
| The similarity-value type. More... | |
| typedef std::function< SVT(const DT &, const DT &)> | SimilarityFunction |
| Type of the generic functor used to compute the similarity of two descriptors. More... | |
| typedef std::pair< std::size_t, SVT > | Result |
| A single calculation result: (target descriptor index, similarity value). More... | |
| typedef std::shared_ptr< BulkSimilarityCalculator > | SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated BulkSimilarityCalculator instances. More... | |
| typedef boost::indirect_iterator< typename DescriptorList::const_iterator, DT > | ConstDescriptorIterator |
| A constant iterator over the stored target descriptors. More... | |
| typedef boost::indirect_iterator< typename DescriptorList::iterator, DT > | DescriptorIterator |
| A mutable iterator over the stored target descriptors. More... | |
| typedef ResultList::const_iterator | ConstResultIterator |
| A constant iterator over the calculation results. More... | |
Public Member Functions | |
| BulkSimilarityCalculator ()=default | |
Constructs the BulkSimilarityCalculator instance with the default similarity function (TanimotoSimilarity). More... | |
| BulkSimilarityCalculator (const BulkSimilarityCalculator &calc)=default | |
| Copy constructor. More... | |
| BulkSimilarityCalculator (BulkSimilarityCalculator &&calc)=default | |
| Move constructor. More... | |
| template<typename SF > | |
| BulkSimilarityCalculator (SF &&sim_func) | |
Constructs the BulkSimilarityCalculator instance with the given similarity function. More... | |
| BulkSimilarityCalculator & | operator= (const BulkSimilarityCalculator &calc)=default |
| Copy assignment operator. More... | |
| BulkSimilarityCalculator & | operator= (BulkSimilarityCalculator &&calc)=default |
| Move assignment operator. More... | |
| const SimilarityFunction & | getSimilarityFunction () const |
| Returns the currently configured similarity function. More... | |
| template<typename SF > | |
| void | setSimilarityFunction (SF &&func) |
| Sets the similarity function. More... | |
| void | clear () |
| Removes all stored descriptors and calculation results. More... | |
| DescriptorIterator | getDescriptorsBegin () |
| Returns a mutable iterator pointing to the first stored descriptor. More... | |
| DescriptorIterator | getDescriptorsEnd () |
| Returns a mutable iterator pointing one past the last stored descriptor. More... | |
| ConstDescriptorIterator | getDescriptorsBegin () const |
| Returns a constant iterator pointing to the first stored descriptor. More... | |
| ConstDescriptorIterator | getDescriptorsEnd () const |
| Returns a constant iterator pointing one past the last stored descriptor. More... | |
| std::size_t | getNumDescriptors () const |
| Returns the number of stored descriptors. More... | |
| void | addDescriptor (const Descriptor &descr) |
| Adds a copy of descr to the stored descriptor list. More... | |
| void | addDescriptor (const DescriptorPointer &descr_ptr) |
| Adds the descriptor referenced by descr_ptr to the stored descriptor list, sharing ownership. More... | |
| bool | containsDescriptor (const Descriptor &descr) const |
| Tells whether a descriptor that compares equal to descr is stored. More... | |
| const Descriptor & | getDescriptor (std::size_t idx) const |
| Returns the stored descriptor at index idx. More... | |
| void | removeDescriptor (std::size_t idx) |
| Removes the descriptor at index idx. More... | |
| DescriptorIterator | removeDescriptor (const DescriptorIterator &it) |
| Removes the descriptor referenced by it. More... | |
| void | calculate (const Descriptor &descr, bool sort=false, bool sort_desc=true) |
| Computes the similarity between the query descr and every stored descriptor. More... | |
| ConstResultIterator | getResultsBegin () const |
| Returns a constant iterator pointing to the first result of the last calculate() call. More... | |
| ConstResultIterator | getResultsEnd () const |
| Returns a constant iterator pointing one past the last result of the last calculate() call. More... | |
| ConstResultIterator | begin () const |
| Returns a constant iterator pointing to the first result (range-based for support). More... | |
| ConstResultIterator | end () const |
| Returns a constant iterator pointing one past the last result (range-based for support). More... | |
| const Result & | getResult (std::size_t idx) const |
| Returns the result at the given index. More... | |
| const SimilarityValue & | getSimilarity (std::size_t idx) const |
| Returns the similarity value of the result at the given index. More... | |
| std::size_t | getDescriptorIndex (std::size_t idx) const |
| Returns the index of the target descriptor referenced by the result at the given result index. More... | |
Calculator that performs a bulk pairwise comparison of a single query descriptor against a stored set of target descriptors using a configurable similarity function.
Stored descriptors are held by shared pointer; the calculator can therefore share descriptor ownership with external code. After a call to calculate() the per-target similarity values are available in stored order and can optionally be sorted.
| DT | The descriptor type (defaults to Util::BitSet, suitable for fingerprint similarity). |
| SVT | The similarity-value type (defaults to double). |
| typedef DT CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::Descriptor |
The descriptor type.
| typedef std::shared_ptr<DT> CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::DescriptorPointer |
A smart pointer to a stored descriptor.
| typedef SVT CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::SimilarityValue |
The similarity-value type.
| typedef std::function<SVT(const DT&, const DT&)> CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::SimilarityFunction |
Type of the generic functor used to compute the similarity of two descriptors.
| typedef std::pair<std::size_t, SVT> CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::Result |
A single calculation result: (target descriptor index, similarity value).
| typedef std::shared_ptr<BulkSimilarityCalculator> CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated BulkSimilarityCalculator instances.
| typedef boost::indirect_iterator<typename DescriptorList::const_iterator, DT> CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::ConstDescriptorIterator |
A constant iterator over the stored target descriptors.
| typedef boost::indirect_iterator<typename DescriptorList::iterator, DT> CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::DescriptorIterator |
A mutable iterator over the stored target descriptors.
| typedef ResultList::const_iterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::ConstResultIterator |
A constant iterator over the calculation results.
|
default |
Constructs the BulkSimilarityCalculator instance with the default similarity function (TanimotoSimilarity).
|
default |
Copy constructor.
| calc | The other BulkSimilarityCalculator instance. |
|
default |
Move constructor.
| calc | The other BulkSimilarityCalculator instance. |
|
inline |
Constructs the BulkSimilarityCalculator instance with the given similarity function.
| SF | The similarity-function type. |
| sim_func | The similarity function. |
|
default |
Copy assignment operator.
| calc | The other BulkSimilarityCalculator instance. |
|
default |
Move assignment operator.
| calc | The other BulkSimilarityCalculator instance. |
| const CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::SimilarityFunction & CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getSimilarityFunction |
Returns the currently configured similarity function.
const reference to the similarity function. | void CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::setSimilarityFunction | ( | SF && | func | ) |
Sets the similarity function.
| SF | The similarity-function type. |
| func | The new similarity function. |
| void CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::clear |
Removes all stored descriptors and calculation results.
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::DescriptorIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getDescriptorsBegin |
Returns a mutable iterator pointing to the first stored descriptor.
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::DescriptorIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getDescriptorsEnd |
Returns a mutable iterator pointing one past the last stored descriptor.
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::ConstDescriptorIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getDescriptorsBegin |
Returns a constant iterator pointing to the first stored descriptor.
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::ConstDescriptorIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getDescriptorsEnd |
Returns a constant iterator pointing one past the last stored descriptor.
| std::size_t CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getNumDescriptors |
Returns the number of stored descriptors.
| void CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::addDescriptor | ( | const Descriptor & | descr | ) |
Adds a copy of descr to the stored descriptor list.
| descr | The descriptor to copy. |
| void CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::addDescriptor | ( | const DescriptorPointer & | descr_ptr | ) |
Adds the descriptor referenced by descr_ptr to the stored descriptor list, sharing ownership.
| descr_ptr | A smart pointer to the descriptor. |
| bool CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::containsDescriptor | ( | const Descriptor & | descr | ) | const |
Tells whether a descriptor that compares equal to descr is stored.
| descr | The descriptor to look for. |
true if such a descriptor is stored, and false otherwise. | const CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::Descriptor & CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getDescriptor | ( | std::size_t | idx | ) | const |
Returns the stored descriptor at index idx.
| idx | The zero-based descriptor index. |
const reference to the descriptor. | Base::IndexError | if the number of descriptors is zero or idx is not in the range [0, getNumDescriptors() - 1]. |
| void CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::removeDescriptor | ( | std::size_t | idx | ) |
Removes the descriptor at index idx.
| idx | The zero-based descriptor index. |
| Base::IndexError | if the number of descriptors is zero or idx is not in the range [0, getNumDescriptors() - 1]. |
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::DescriptorIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::removeDescriptor | ( | const DescriptorIterator & | it | ) |
Removes the descriptor referenced by it.
| it | Iterator referencing the descriptor to remove. |
| Base::RangeError | if the number of descriptors is zero or it is not in the range [getDescriptorsBegin(), getDescriptorsEnd() - 1]. |
| void CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::calculate | ( | const Descriptor & | descr, |
| bool | sort = false, |
||
| bool | sort_desc = true |
||
| ) |
Computes the similarity between the query descr and every stored descriptor.
| descr | The query descriptor. |
| sort | If true, the resulting (index, similarity) pairs are sorted by similarity value. |
| sort_desc | If true (default), sorting is in descending order of similarity; if false, in ascending order. |
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::ConstResultIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getResultsBegin |
Returns a constant iterator pointing to the first result of the last calculate() call.
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::ConstResultIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getResultsEnd |
Returns a constant iterator pointing one past the last result of the last calculate() call.
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::ConstResultIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::begin |
Returns a constant iterator pointing to the first result (range-based for support).
| CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::ConstResultIterator CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::end |
Returns a constant iterator pointing one past the last result (range-based for support).
| const CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::Result & CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getResult | ( | std::size_t | idx | ) | const |
Returns the result at the given index.
| idx | The zero-based result index. |
const reference to the (descriptor index, similarity) pair. | Base::IndexError | if the number of descriptors is zero or idx is not in the range [0, getNumDescriptors() - 1]. |
| const CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::SimilarityValue & CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getSimilarity | ( | std::size_t | idx | ) | const |
Returns the similarity value of the result at the given index.
| idx | The zero-based result index. |
const reference to the similarity value. | Base::IndexError | if the number of descriptors is zero or idx is not in the range [0, getNumDescriptors() - 1]. |
| std::size_t CDPL::Descr::BulkSimilarityCalculator< DT, SVT >::getDescriptorIndex | ( | std::size_t | idx | ) | const |
Returns the index of the target descriptor referenced by the result at the given result index.
| idx | The zero-based result index. |
| Base::IndexError | if the number of descriptors is zero or idx is not in the range [0, getNumDescriptors() - 1]. |