Loading...
Searching...
No Matches
smilesParser.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_STRUCTURE_SMILES_PARSER_H
#define BALL_STRUCTURE_SMILES_PARSER_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#ifndef BALL_KERNEL_ATOM_H
# include <BALL/KERNEL/atom.h>
#endif
#ifndef BALL_KERNEL_BOND_H
# include <BALL/KERNEL/bond.h>
#endif
#ifndef BALL_KERNEL_SYSTEM_H
# include <BALL/KERNEL/system.h>
#endif
namespace BALL
{
class BALL_EXPORT SmilesParser
{
public:
enum ZEIsomerType
{
NONE,
Z,
E
};
enum ChiralClass
{
NONCHIRAL,
TH,
AL,
SP,
TB,
OH
};
enum
{
MAX_CONNECTIONS = 100
};
typedef std::pair<ChiralClass, Position> ChiralDef;
class SPAtom;
class BALL_EXPORT SPBond
: public Bond
{
public:
virtual ~SPBond() ;
SPBond(SPAtom* first, SPAtom* second, Index order = 1);
ZEIsomerType getZEType() const;
void setZEType(ZEIsomerType type);
protected:
ZEIsomerType ze_type_;
};
class BALL_EXPORT SPAtom
: public Atom
{
public:
SPAtom(const String& symbol, bool in_brackets);
virtual ~SPAtom() ;
Size getDefaultValence() const;
Size countRealValences() const;
Size getIsotope() const { return isotope_; }
void setIsotope(Size isotope) { isotope_ = isotope; };
Index getFormalCharge() const { return formal_charge_; }
void setFormalCharge(Index charge) { formal_charge_ = charge; }
const ChiralDef& getChirality() const { return chirality_; }
void setChirality(const ChiralDef& chirality) { chirality_ = chirality; }
bool isAromatic() const { return is_aromatic_; }
void setAromatic(bool is_aromatic) { is_aromatic_ = is_aromatic; };
bool isInBrackets() const { return in_brackets_; }
void setInBrackets(bool in_brackets) { in_brackets_ = in_brackets; };
protected:
Size isotope_;
Index formal_charge_;
ChiralDef chirality_;
bool is_aromatic_;
bool in_brackets_;
};
typedef std::list<Position> ConnectionList;
SmilesParser();
SmilesParser(const SmilesParser& parser);
virtual ~SmilesParser();
void parse(const String& s);
const System& getSystem() const;
SPAtom* createAtom(const String& symbol, bool in_bracket = false);
void createBonds(SPAtom* atom, const ConnectionList* list);
void createBond(SPAtom* left, SPAtom* right, Index order);
void addMissingHydrogens();
struct State
{
Size char_count;
SmilesParser* current_parser;
const char* buffer;
};
static State state;
protected:
System system_;
std::vector<SPAtom*> connections_;
std::vector<SPAtom*> all_atoms_;
static SmilesParser* current_parser_;
};
} // namespace BALL
#endif // BALL_STRUCTURE_SMILES_PARSER_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
system.h
atom.h
bond.h
BALL::Atom::Atom
Atom()
BALL::Bond::Bond
Bond()
BALL::SmilesParser::SPAtom
Definition smilesParser.h:81
BALL::SmilesParser::SPAtom::isotope_
Size isotope_
Definition smilesParser.h:105
BALL::SmilesParser::SPAtom::isInBrackets
bool isInBrackets() const
Definition smilesParser.h:101
BALL::SmilesParser::SPAtom::setInBrackets
void setInBrackets(bool in_brackets)
Definition smilesParser.h:102
BALL::SmilesParser::SPAtom::setIsotope
void setIsotope(Size isotope)
Definition smilesParser.h:91
BALL::SmilesParser::SPAtom::SPAtom
SPAtom(const String &symbol, bool in_brackets)
BALL::SmilesParser::SPAtom::chirality_
ChiralDef chirality_
Definition smilesParser.h:107
BALL::SmilesParser::SPAtom::getChirality
const ChiralDef & getChirality() const
Definition smilesParser.h:96
BALL::SmilesParser::SPAtom::setAromatic
void setAromatic(bool is_aromatic)
Definition smilesParser.h:100
BALL::SmilesParser::SPAtom::~SPAtom
virtual ~SPAtom()
BALL::SmilesParser::SPAtom::in_brackets_
bool in_brackets_
Definition smilesParser.h:109
BALL::SmilesParser::SPAtom::getDefaultValence
Size getDefaultValence() const
BALL::SmilesParser::SPAtom::countRealValences
Size countRealValences() const
BALL::SmilesParser::SPAtom::getIsotope
Size getIsotope() const
Definition smilesParser.h:90
BALL::SmilesParser::SPAtom::setChirality
void setChirality(const ChiralDef &chirality)
Definition smilesParser.h:97
BALL::SmilesParser::SPAtom::setFormalCharge
void setFormalCharge(Index charge)
Definition smilesParser.h:94
BALL::SmilesParser::SPAtom::is_aromatic_
bool is_aromatic_
Definition smilesParser.h:108
BALL::SmilesParser::SPAtom::isAromatic
bool isAromatic() const
Definition smilesParser.h:99
BALL::SmilesParser::SPAtom::getFormalCharge
Index getFormalCharge() const
Definition smilesParser.h:93
BALL::SmilesParser::SPAtom::formal_charge_
Index formal_charge_
Definition smilesParser.h:106
BALL::SmilesParser::SPBond::SPBond
SPBond(SPAtom *first, SPAtom *second, Index order=1)
BALL::SmilesParser::SPBond::getZEType
ZEIsomerType getZEType() const
BALL::SmilesParser::SPBond::setZEType
void setZEType(ZEIsomerType type)
BALL::SmilesParser::SPBond::~SPBond
virtual ~SPBond()
BALL::SmilesParser::SPBond::ze_type_
ZEIsomerType ze_type_
Definition smilesParser.h:76
BALL::SmilesParser::SmilesParser
SmilesParser(const SmilesParser &parser)
BALL::SmilesParser::ZEIsomerType
ZEIsomerType
Definition smilesParser.h:40
BALL::SmilesParser::NONE
@ NONE
Definition smilesParser.h:41
BALL::SmilesParser::Z
@ Z
Definition smilesParser.h:42
BALL::SmilesParser::E
@ E
Definition smilesParser.h:43
BALL::SmilesParser::getSystem
const System & getSystem() const
BALL::SmilesParser::SmilesParser
SmilesParser()
BALL::SmilesParser::createBond
void createBond(SPAtom *left, SPAtom *right, Index order)
BALL::SmilesParser::system_
System system_
Definition smilesParser.h:168
BALL::SmilesParser::parse
void parse(const String &s)
BALL::SmilesParser::ChiralClass
ChiralClass
Definition smilesParser.h:47
BALL::SmilesParser::TH
@ TH
Definition smilesParser.h:49
BALL::SmilesParser::AL
@ AL
Definition smilesParser.h:50
BALL::SmilesParser::SP
@ SP
Definition smilesParser.h:51
BALL::SmilesParser::NONCHIRAL
@ NONCHIRAL
Definition smilesParser.h:48
BALL::SmilesParser::OH
@ OH
Definition smilesParser.h:53
BALL::SmilesParser::TB
@ TB
Definition smilesParser.h:52
BALL::SmilesParser::ChiralDef
std::pair< ChiralClass, Position > ChiralDef
Definition smilesParser.h:61
BALL::SmilesParser::createBonds
void createBonds(SPAtom *atom, const ConnectionList *list)
BALL::SmilesParser::all_atoms_
std::vector< SPAtom * > all_atoms_
Definition smilesParser.h:170
BALL::SmilesParser::createAtom
SPAtom * createAtom(const String &symbol, bool in_bracket=false)
BALL::SmilesParser::MAX_CONNECTIONS
@ MAX_CONNECTIONS
Definition smilesParser.h:58
BALL::SmilesParser::ConnectionList
std::list< Position > ConnectionList
Definition smilesParser.h:112
BALL::SmilesParser::~SmilesParser
virtual ~SmilesParser()
BALL::SmilesParser::connections_
std::vector< SPAtom * > connections_
Definition smilesParser.h:169
BALL::SmilesParser::addMissingHydrogens
void addMissingHydrogens()
BALL::SmilesParser::current_parser_
static SmilesParser * current_parser_
Definition smilesParser.h:171
BALL::SmilesParser::state
static State state
Definition smilesParser.h:165
BALL::String
Definition string.h:57
BALL::System
Definition KERNEL/system.h:40
common.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Index
BALL_INDEX_TYPE Index
Definition COMMON/global.h:105
BALL::SmilesParser::State
Definition smilesParser.h:159
BALL::SmilesParser::State::char_count
Size char_count
Definition smilesParser.h:160
BALL::SmilesParser::State::current_parser
SmilesParser * current_parser
Definition smilesParser.h:161
BALL::SmilesParser::State::buffer
const char * buffer
Definition smilesParser.h:162