Loading...
Searching...
No Matches
alias.h
Go to the documentation of this file.
/**********************************************************************
alias.h - OBGenericData class to hold alias information on atoms
Copyright (C) Copyright (C) 2007 by Chris Morley
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 version 2 of the License.
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.
***********************************************************************/
#ifndef OB_ALIAS_H
#define OB_ALIAS_H
#include <vector>
#include <openbabel/generic.h>
#include <openbabel/shared_ptr.h>
namespace OpenBabel
{
class OBSmartsPattern;
class OBMol;
// This macro is used in DLL builds. If it has not
// been set in babelconfig.h, define it as nothing.
#ifndef OBCOMMON
#define OBCOMMON
#endif
const unsigned int AliasDataType = 0x7883;
class OBCOMMON AliasData : public OBGenericData
{
protected:
std::string _alias;
std::string _right_form;
std::vector<unsigned long> _expandedatoms; //atom ids (not idxs)
std::string _color;
public:
AliasData(): OBGenericData("Alias", AliasDataType){ }
virtual OBGenericData* Clone(OBBase* /*parent*/) const{return new AliasData(*this);}
void SetAlias(const std::string& alias) {_alias = alias;}
void SetAlias(const char* alias) {_alias = alias;}
std::string GetAlias(bool rightAligned = false) const;
std::string GetColor() const { return _color; }
void SetColor(std::string color){ _color = color; }
bool IsExpanded()const { return !_expandedatoms.empty(); }
static void RevertToAliasForm(OBMol& mol);
bool Expand(OBMol& mol, const unsigned int atomindex);
#ifdef HAVE_SHARED_POINTER
static bool AddAliases(OBMol* pmol);
#endif
private:
bool FormulaParse(OBMol& mol, const unsigned atomindex);
void AddExpandedAtom(int id);
void DeleteExpandedAtoms(OBMol& mol);
struct AliasItem
{
std::string right_form;
std::string smiles;
std::string color;
};
typedef std::map<std::string, AliasItem> SuperAtomTable; //key=alias left-form
static bool LoadFile(SuperAtomTable& table);
static SuperAtomTable& table()
{
static SuperAtomTable t;
if(t.empty())
LoadFile(t);
return t;
}
bool FromNameLookup(OBMol& mol, const unsigned int atomindex);
#ifdef HAVE_SHARED_POINTER
typedef std::vector< std::pair<std::string, obsharedptr<OBSmartsPattern> > > SmartsTable;
static bool LoadFile(SmartsTable& smtable);
#endif
};
} //namespace
#endif // OB_ALIAS_H
OpenBabel::AliasData::_expandedatoms
std::vector< unsigned long > _expandedatoms
Definition alias.h:57
OpenBabel::AliasData::_color
std::string _color
Definition alias.h:58
OpenBabel::AliasData::IsExpanded
bool IsExpanded() const
Definition alias.h:78
OpenBabel::AliasData::AliasData
AliasData()
Definition alias.h:61
OpenBabel::AliasData::GetColor
std::string GetColor() const
Return the color which has been assigned to this alias.
Definition alias.h:73
OpenBabel::AliasData::_alias
std::string _alias
Definition alias.h:55
OpenBabel::AliasData::_right_form
std::string _right_form
Definition alias.h:56
OpenBabel::AliasData::SetAlias
void SetAlias(const std::string &alias)
Add an alias.
Definition alias.h:66
OpenBabel::AliasData::Clone
virtual OBGenericData * Clone(OBBase *) const
Definition alias.h:63
OpenBabel::AliasData::SetColor
void SetColor(std::string color)
Assign a color to this alias.
Definition alias.h:76
OpenBabel::AliasData::SetAlias
void SetAlias(const char *alias)
Definition alias.h:67
OpenBabel::OBBase
Base Class.
Definition base.h:240
OpenBabel::OBGenericData::OBGenericData
OBGenericData(const std::string attr="undefined", const unsigned int type=OBGenericDataType::UndefinedData, const DataOrigin source=any)
Definition generic.cpp:166
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBSmartsPattern
SMARTS (SMiles ARbitrary Target Specification) substructure searching.
Definition parsmart.h:155
generic.h
Handle generic data classes. Custom data for atoms, bonds, etc.
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
OpenBabel::AliasDataType
const unsigned int AliasDataType
Definition alias.h:33
shared_ptr.h
Shared pointer.