Abstract class defining interface for isomorphism (i.e. substructure) searches. More...
#include <openbabel/isomorphism.h>
Inherited by VF2Mapper.
Classes | |
class | Functor |
Functor base class to be used in combination with MapGeneric. More... | |
Public Types | |
typedef std::vector< std::pair < unsigned int, unsigned int > > | Mapping |
typedef std::vector< Mapping > | Mappings |
Public Member Functions | |
OBIsomorphismMapper (OBQuery *query) | |
virtual | ~OBIsomorphismMapper () |
virtual void | MapFirst (const OBMol *queried, Mapping &map, const OBBitVec &mask=OBBitVec())=0 |
virtual void | MapUnique (const OBMol *queried, Mappings &maps, const OBBitVec &mask=OBBitVec())=0 |
virtual void | MapAll (const OBMol *queried, Mappings &maps, const OBBitVec &mask=OBBitVec(), std::size_t maxMemory=3000000)=0 |
virtual void | MapGeneric (Functor &functor, const OBMol *queried, const OBBitVec &mask=OBBitVec())=0 |
void | SetTimeout (unsigned int seconds) |
Static Public Member Functions | |
static OBIsomorphismMapper * | GetInstance (OBQuery *query, const std::string &algorithm=std::string("VF2")) |
Protected Attributes | |
OBQuery * | m_query |
unsigned int | m_timeout |
Abstract class defining interface for isomorphism (i.e. substructure) searches.
Since this is an abstract class with pure virtual methods, this class can't be instantiated directly. To get a pointer to a subclass, the GetInstance() method can be used which also sets the query. Once an instance is obtained, the desired mapping function can be used to perform the mapping (i.e. MapFirst(), MapUnique() or MapAll()).
A typical example:
OBMol *queried; // ... initialize queried ... OBQuery *query = CompileSmilesQuery("c1ccccc1"); OBIsomorphismMapper *mapper = OBIsomorphismMapper::GetInstance(query); OBIsomorphismMapper::Mappings maps = mapper->MapUnique(mol); std::cout << "found " << maps.size() << " unique mappings" << std::endl; delete mapper; delete query;
All mapping methods take an optional mask parameter. This can be used to restrict the search to a part of the queried OBMol. The masked atoms in the OBBitVec are indexed from 1. A special case of isomorphism search is an automorphism search where the query and queried molecule are the same. Automorphism searches can be done using the MapAll method but an additional FindAutomorphisms() function is provided for convenience.
std::vector< std::pair< unsigned int, unsigned int > > Mapping |
Type for an individual mapping.
std::vector< OBIsomorphismMapper::Mapping > Mappings |
Type for a collection (std::vector) of Mapping objects.
OBIsomorphismMapper | ( | OBQuery * | query ) |
Constructor. OBIsomorphismMapper is an abstract class, use GetInstance() to get an instance of a derived class.
query | The search query. |
~OBIsomorphismMapper | ( | ) | [virtual] |
OBIsomorphismMapper * GetInstance | ( | OBQuery * | query, |
const std::string & | algorithm = std::string("VF2") |
||
) | [static] |
Get a pointer to an instance of the specified algorithm
. This pointer has to be delted when the instance is no longer needed.
query | The search query to be mapped. |
algorithm | The algorithm for the mapper. |
algorithm
. Referenced by OpenBabel::FindAutomorphisms().
virtual void MapFirst | ( | const OBMol * | queried, |
Mapping & | map, | ||
const OBBitVec & | mask = OBBitVec() |
||
) | [pure virtual] |
Find a single mapping in queried
.
queried | The molecule to search. |
map | Reference to the object to store the result in. |
mask | A mask to restrict the search to a part of the queried molecule. The default empty mask will result in all atoms being considered. The mask indexes start from 1 (i.e. OBAtom::GetIdx()). |
virtual void MapUnique | ( | const OBMol * | queried, |
Mappings & | maps, | ||
const OBBitVec & | mask = OBBitVec() |
||
) | [pure virtual] |
Find all unique mappings in queried
. A mapping is unique when there is no previous mapping covering the same queried atoms. For two mappings, some overlap is allowed but at least one atom should be different.
queried | The molecule to search. |
maps | Reference to the object to store the results in. |
mask | A mask to restrict the search to a part of the queried molecule. The default empty mask will result in all atoms being considered. The mask indexes start from 1 (i.e. OBAtom::GetIdx()). |
virtual void MapAll | ( | const OBMol * | queried, |
Mappings & | maps, | ||
const OBBitVec & | mask = OBBitVec() , |
||
std::size_t | maxMemory = 3000000 |
||
) | [pure virtual] |
Find all mappings in queried
. This function is used by FindAutomorphisms() with a query that is a copy of the queried molecule (taking the mask into account).
queried | The molecule to search. |
maps | Reference to the object to store the results in. |
mask | A mask to restrict the search to a part of the queried molecule. |
maxMemory | Memory limit for the maps object in bytes. Default is 300MB. The default empty mask will result in all atoms being considered. The mask indexes start from 1 (i.e. OBAtom::GetIdx()). |
virtual void MapGeneric | ( | Functor & | functor, |
const OBMol * | queried, | ||
const OBBitVec & | mask = OBBitVec() |
||
) | [pure virtual] |
Find all mappings in queried
. The functor will be called when a mapping is found.
functor | The functor to handle found mappings. |
queried | The molecule to search. |
mask | A mask to restrict the search to a part of the queried molecule. The default empty mask will result in all atoms being considered. The mask indexes start from 1 (i.e. OBAtom::GetIdx()). |
Referenced by OpenBabel::FindAutomorphisms().
void SetTimeout | ( | unsigned int | seconds ) | [inline] |
Set the timeout in seconds.
unsigned int m_timeout [protected] |
The timeout in seconds.