Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
00025
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;
00055 std::string _color;
00056 public:
00057
00058 AliasData(): OBGenericData("Alias", AliasDataType){ }
00059
00060 virtual OBGenericData* Clone(OBBase* ) 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;
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 }
00123
00124 #endif // OB_ALIAS_H
00125