Loading...
Searching...
No Matches
isomorphism.h
Go to the documentation of this file.
/**********************************************************************
isomophism.h - OBIsomorphismMapper class for finding isomorphisms.
Copyright (C) 2010 by Tim Vandermeersch
This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
**********************************************************************/
#ifndef OB_ISOMORPHISM_H
#define OB_ISOMORPHISM_H
#include <openbabel/bitvec.h>
namespace OpenBabel {
class OBQuery;
class OBMol;
class OBAPI OBIsomorphismMapper
{
public:
typedef std::vector< std::pair<unsigned int,unsigned int> > Mapping;
typedef std::vector< Mapping > Mappings;
OBIsomorphismMapper(OBQuery *query);
virtual ~OBIsomorphismMapper();
static OBIsomorphismMapper* GetInstance(OBQuery *query, const std::string &algorithm = std::string("VF2"));
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;
class Functor
{
public:
virtual ~Functor() {}
virtual bool operator()(Mapping &map) = 0;
};
virtual void MapGeneric(Functor &functor, const OBMol *queried, const OBBitVec &mask = OBBitVec()) = 0;
void SetTimeout(unsigned int seconds) { m_timeout = seconds; }
protected:
OBQuery *m_query;
unsigned int m_timeout;
};
inline bool MapsTo(const OBIsomorphismMapper::Mapping &map, unsigned int queryIndex, unsigned int &queriedIndex)
{
OBIsomorphismMapper::Mapping::const_iterator i;
for (i = map.begin(); i != map.end(); ++i)
if (i->first == queryIndex) {
queriedIndex = i->second;
return true;
}
return false;
}
typedef OBIsomorphismMapper::Mapping Automorphism;
typedef OBIsomorphismMapper::Mappings Automorphisms;
OBAPI bool FindAutomorphisms(OBMol *mol, std::vector<OBIsomorphismMapper::Mapping> &aut, const std::vector<unsigned int> &symmetry_classes,
const OBBitVec &mask = OBBitVec(), std::size_t maxMemory = 3000000);
OBAPI bool FindAutomorphisms(OBMol *mol, std::vector<OBIsomorphismMapper::Mapping> &aut, const OBBitVec &mask = OBBitVec(),
std::size_t maxMemory = 3000000);
OBAPI void FindAutomorphisms(OBIsomorphismMapper::Functor &functor, OBMol *mol,
const std::vector<unsigned int> &symmetry_classes, const OBBitVec &mask = OBBitVec());
}
#endif
bitvec.h
Fast and efficient bitstring class.
OpenBabel::OBBitVec
A speed-optimized vector of bits.
Definition bitvec.h:58
OpenBabel::OBIsomorphismMapper::Functor
Functor base class to be used in combination with MapGeneric.
Definition isomorphism.h:149
OpenBabel::OBIsomorphismMapper::Functor::~Functor
virtual ~Functor()
Definition isomorphism.h:151
OpenBabel::OBIsomorphismMapper::Functor::operator()
virtual bool operator()(Mapping &map)=0
OpenBabel::OBIsomorphismMapper::m_query
OBQuery * m_query
The search query.
Definition isomorphism.h:178
OpenBabel::OBIsomorphismMapper::MapFirst
virtual void MapFirst(const OBMol *queried, Mapping &map, const OBBitVec &mask=OBBitVec())=0
OpenBabel::OBIsomorphismMapper::SetTimeout
void SetTimeout(unsigned int seconds)
Definition isomorphism.h:175
OpenBabel::OBIsomorphismMapper::MapGeneric
virtual void MapGeneric(Functor &functor, const OBMol *queried, const OBBitVec &mask=OBBitVec())=0
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::m_timeout
unsigned int m_timeout
The timeout in seconds.
Definition isomorphism.h:179
OpenBabel::OBIsomorphismMapper::Mapping
std::vector< std::pair< unsigned int, unsigned int > > Mapping
Definition isomorphism.h:84
OpenBabel::OBIsomorphismMapper::MapUnique
virtual void MapUnique(const OBMol *queried, Mappings &maps, const OBBitVec &mask=OBBitVec())=0
OpenBabel::OBIsomorphismMapper::MapAll
virtual void MapAll(const OBMol *queried, Mappings &maps, const OBBitVec &mask=OBBitVec(), std::size_t maxMemory=3000000)=0
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBQuery
A substructure query.
Definition query.h:198
OpenBabel::Automorphisms
OBIsomorphismMapper::Mappings Automorphisms
A group of automorphic permutations.
Definition isomorphism.h:206
OpenBabel::MapsTo
bool MapsTo(const OBIsomorphismMapper::Mapping &map, unsigned int queryIndex, unsigned int &queriedIndex)
Definition isomorphism.h:182
OpenBabel::Automorphism
OBIsomorphismMapper::Mapping Automorphism
A single automorphic permutation.
Definition isomorphism.h:200
OpenBabel::FindAutomorphisms
bool FindAutomorphisms(OBMol *mol, std::vector< OBIsomorphismMapper::Mapping > &aut, const std::vector< unsigned int > &symmetry_classes, const OBBitVec &mask=OBBitVec(), std::size_t maxMemory=3000000)
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23