00001 /********************************************************************** 00002 isomophism.h - OBIsomorphismMapper class for finding isomorphisms. 00003 00004 Copyright (C) 2010 by Tim Vandermeersch 00005 00006 This file is part of the Open Babel project. 00007 For more information, see <http://openbabel.org/> 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00022 02110-1301, USA. 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
This file is part of the documentation for Open Babel, version 2.3.