Open Babel: alias.h Source File

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

- File List
- File Members

# alias.h

Go to the documentation of this file.

    00001 /**********************************************************************
    00002 alias.h - OBGenericData class to hold alias information on atoms
    00003 Copyright (C) Copyright (C) 2007 by Chris Morley
    00004
    00005 This program is free software; you can redistribute it and/or modify
    00006 it under the terms of the GNU General Public License as published by
    00007 the Free Software Foundation version 2 of the License.
    00008
    00009 This program is distributed in the hope that it will be useful,
    00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012 GNU General Public License for more details.
    00013 ***********************************************************************/
    00014
    00015 #ifndef OB_ALIAS_H
    00016 #define OB_ALIAS_H
    00017
    00018 #include <vector>
    00019 #include <openbabel/shared_ptr.h>
    00020 #include <openbabel/mol.h>
    00021
    00022 namespace OpenBabel
    00023 {
    00024 // This macro is used in DLL builds. If it has not
    00025 // been set in babelconfig.h, define it as nothing.
    00026 #ifndef OBCOMMON
    00027   #define OBCOMMON
    00028 #endif
    00029
    00030 const unsigned int AliasDataType = 0x7883;
    00031
    00049 class OBCOMMON AliasData : public OBGenericData
    00050 {
    00051 protected:
    00052   std::string _alias;
    00053   std::string _right_form;
    00054   std::vector<unsigned long> _expandedatoms; //atom ids (not idxs)
    00055   std::string _color;
    00056 public:
    00057
    00058   AliasData(): OBGenericData("Alias", AliasDataType){ }
    00059
    00060   virtual OBGenericData* Clone(OBBase* /*parent*/) const{return new AliasData(*this);}
    00061
    00063   void SetAlias(const std::string& alias) {_alias = alias;}
    00064   void SetAlias(const char* alias) {_alias = alias;}
    00065
    00067   std::string GetAlias(bool rightAligned = false) const;
    00068
    00070   std::string GetColor() const { return _color; }
    00071
    00073   void SetColor(std::string color){ _color = color; }
    00074
    00075   bool IsExpanded()const { return !_expandedatoms.empty(); }
    00076
    00079   static void RevertToAliasForm(OBMol& mol);
    00080
    00082   bool Expand(OBMol& mol, const unsigned int atomindex);
    00083
    00084  #ifdef HAVE_SHARED_POINTER
    00085
    00086
    00087   static bool AddAliases(OBMol* pmol);
    00088  #endif
    00089
    00090 private:
    00092   bool FormulaParse(OBMol& mol, const unsigned atomindex);
    00093
    00095   void AddExpandedAtom(int id);
    00096
    00098   void DeleteExpandedAtoms(OBMol& mol);
    00099
    00100   struct AliasItem
    00101   {
    00102     std::string right_form;
    00103     std::string smiles;
    00104     std::string color;
    00105   };
    00106   typedef std::map<std::string, AliasItem> SuperAtomTable; //key=alias left-form
    00107
    00108   static bool LoadFile(SuperAtomTable& table);
    00109   static SuperAtomTable& table()
    00110   {
    00111     static SuperAtomTable t;
    00112     if(t.empty())
    00113       LoadFile(t);
    00114     return t;
    00115   }
    00116   bool        FromNameLookup(OBMol& mol, const unsigned int atomindex);
    00117 #ifdef HAVE_SHARED_POINTER
    00118   typedef std::vector< std::pair<std::string, shared_ptr<OBSmartsPattern> > > SmartsTable;
    00119   static bool LoadFile(SmartsTable& smtable);
    00120 #endif
    00121 };
    00122 } //namespace
    00123
    00124 #endif // OB_ALIAS_H
    00125

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

This file is part of the documentation for Open Babel, version 2.3.

Documentation copyright © 1998-2007, the Open Babel Developers.
Open Babel is hosted by:
Generated on Mon Oct 25 2010 11:55:07 by 1.7.2.