OBIsomorphismMapper Class Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
OBIsomorphismMapper Class Reference
Substructure Searching

`#include <openbabel/isomorphism.h>`

Inheritance diagram for OBIsomorphismMapper:
[legend]

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

## 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.

std::vector< OBIsomorphismMapper::Mapping > Mappings

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:

  query | The 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:

  query | The search query to be mapped.
  algorithm | The 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:

  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.

Parameters:

  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).

Parameters:

  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.

Parameters:

  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.

## 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:

- isomorphism.h
- isomorphism.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines