Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OB_ISOMORPHISM_H
00025 #define OB_ISOMORPHISM_H
00026
00027 #include <openbabel/mol.h>
00028
00029 namespace OpenBabel {
00030
00031 class OBQuery;
00032
00035
00076 class OBAPI OBIsomorphismMapper
00077 {
00078 public:
00083 typedef std::vector< std::pair<unsigned int,unsigned int> > Mapping;
00088 typedef std::vector< Mapping > Mappings;
00089
00095 OBIsomorphismMapper(OBQuery *query);
00096 virtual ~OBIsomorphismMapper();
00097
00106 static OBIsomorphismMapper* GetInstance(OBQuery *query, const std::string &algorithm = std::string("VF2"));
00107
00116 virtual void MapFirst(const OBMol *queried, Mapping &map, const OBBitVec &mask = OBBitVec()) = 0;
00127 virtual void MapUnique(const OBMol *queried, Mappings &maps, const OBBitVec &mask = OBBitVec()) = 0;
00139 virtual void MapAll(const OBMol *queried, Mappings &maps, const OBBitVec &mask = OBBitVec(), std::size_t maxMemory = 3000000) = 0;
00140
00147 class Functor
00148 {
00149 public:
00150 virtual ~Functor() {}
00158 virtual bool operator()(Mapping &map) = 0;
00159 };
00168 virtual void MapGeneric(Functor &functor, const OBMol *queried, const OBBitVec &mask = OBBitVec()) = 0;
00169
00170
00174 void SetTimeout(unsigned int seconds) { m_timeout = seconds; }
00175
00176 protected:
00177 OBQuery *m_query;
00178 unsigned int m_timeout;
00179 };
00180
00181 inline bool MapsTo(const OBIsomorphismMapper::Mapping &map, unsigned int queryIndex, unsigned int &queriedIndex)
00182 {
00183 OBIsomorphismMapper::Mapping::const_iterator i;
00184 for (i = map.begin(); i != map.end(); ++i)
00185 if (i->first == queryIndex) {
00186 queriedIndex = i->second;
00187 return true;
00188 }
00189
00190 return false;
00191 }
00192
00193
00199 typedef OBIsomorphismMapper::Mapping Automorphism;
00205 typedef OBIsomorphismMapper::Mappings Automorphisms;
00206
00224 OBAPI bool FindAutomorphisms(OBMol *mol, std::vector<OBIsomorphismMapper::Mapping> &aut, const std::vector<unsigned int> &symmetry_classes,
00225 const OBBitVec &mask = OBBitVec(), std::size_t maxMemory = 3000000);
00234 OBAPI bool FindAutomorphisms(OBMol *mol, std::vector<OBIsomorphismMapper::Mapping> &aut, const OBBitVec &mask = OBBitVec(),
00235 std::size_t maxMemory = 3000000);
00236
00248 OBAPI void FindAutomorphisms(OBIsomorphismMapper::Functor &functor, OBMol *mol,
00249 const std::vector<unsigned int> &symmetry_classes, const OBBitVec &mask = OBBitVec());
00250
00365
00366
00367 }
00368
00369 #endif
00370