Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes

OBIsomorphismMapper Class Reference
[Substructure Searching]

Abstract class defining interface for isomorphism (i.e. substructure) searches. More...

#include <openbabel/isomorphism.h>

Inherited by VF2Mapper.

List of all members.

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< MappingMappings

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 OBIsomorphismMapperGetInstance (OBQuery *query, const std::string &algorithm=std::string("VF2"))

Protected Attributes

OBQuerym_query
unsigned int m_timeout

Detailed Description

Abstract class defining interface for isomorphism (i.e. substructure) searches.

Since:
version 2.3 The OBIsomorphism class is an abstract class which defines an interface for performing isomorphism (i.e. substructure) searches. It uses a OBQuery and tries to map this onto a queried OBMol. A single mapping is represented by a OBIsomorphismMapper::Mapping which is a std::map mapping query indexes to queried indexes. Both query and queried indexes in the map start from 0. Multiple mappings can be stored in a OBIsomorphismMapper::Mappings object which is a std::vector of OBIsomorphismMapper objects.

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.


Member Typedef Documentation

std::vector< std::pair< unsigned int, unsigned int > > Mapping

Type for an individual mapping.

Type for a collection (std::vector) of Mapping objects.


Constructor & Destructor Documentation

OBIsomorphismMapper ( OBQuery query )

Constructor. OBIsomorphismMapper is an abstract class, use GetInstance() to get an instance of a derived class.

Parameters:
queryThe search query.
~OBIsomorphismMapper (  ) [virtual]

Member Function Documentation

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.

Parameters:
queryThe search query to be mapped.
algorithmThe algorithm for the mapper.
Returns:
OBIsomorphismMapper instance or 0 if there is no subclass implementing the specified 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.

Parameters:
queriedThe molecule to search.
mapReference to the object to store the result in.
maskA 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.

Parameters:
queriedThe molecule to search.
mapsReference to the object to store the results in.
maskA 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).

Parameters:
queriedThe molecule to search.
mapsReference to the object to store the results in.
maskA mask to restrict the search to a part of the queried molecule.
maxMemoryMemory 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.

Parameters:
functorThe functor to handle found mappings.
queriedThe molecule to search.
maskA 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.


Member Data Documentation

OBQuery* m_query [protected]

The search query.

unsigned int m_timeout [protected]

The timeout in seconds.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines