Loading...
Searching...
No Matches
OBIsomorphismMapper Class Referenceabstract
Substructure Searching

`#include <openbabel/isomorphism.h>`

Inheritance diagram for OBIsomorphismMapper:
[legend]

## Classes

class | Functor

## 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;
OpenBabel::OBIsomorphismMapper::GetInstance
static OBIsomorphismMapper * GetInstance(OBQuery *query, const std::string &algorithm=std::string("VF2"))
Definition isomorphism.cpp:516
OpenBabel::OBIsomorphismMapper::OBIsomorphismMapper
OBIsomorphismMapper(OBQuery *query)
Definition isomorphism.cpp:508
OpenBabel::OBIsomorphismMapper::Mappings
std::vector< Mapping > Mappings
Definition isomorphism.h:89
OpenBabel::OBIsomorphismMapper::MapUnique
virtual void MapUnique(const OBMol *queried, Mappings &maps, const OBBitVec &mask=OBBitVec())=0
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBQuery
A substructure query.
Definition query.h:198
OpenBabel::CompileSmilesQuery
OBQuery * CompileSmilesQuery(const std::string &smiles, const OBBitVec &mask=OBBitVec())
Definition query.cpp:75

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

## Mapping

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

Type for an individual mapping.

## Mappings

typedef std::vector< Mapping > Mappings

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

## Constructor & Destructor Documentation

## OBIsomorphismMapper()

OBIsomorphismMapper | ( | OBQuery * | query | ) |

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

Parameters

  query | The search query.

Referenced by GetInstance().

## ~OBIsomorphismMapper()

~OBIsomorphismMapper | ( |  | ) |

virtual

## Member Function Documentation

## GetInstance()

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

## MapFirst()

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

## MapUnique()

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

## MapAll()

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

## MapGeneric()

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

## SetTimeout()

void SetTimeout | ( | unsigned int | seconds | ) |

inline

Set the timeout in seconds.

## Member Data Documentation

## m_query

OBQuery* m_query

protected

The search query.

Referenced by OBIsomorphismMapper().

## m_timeout

unsigned int m_timeout

protected

The timeout in seconds.

Referenced by OBIsomorphismMapper(), and SetTimeout().

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

- isomorphism.h
- isomorphism.cpp