BALL  1.5.0
smilesParser.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_STRUCTURE_SMILES_PARSER_H
6 #define BALL_STRUCTURE_SMILES_PARSER_H
7 
8 #ifndef BALL_COMMON_H
9 # include <BALL/common.h>
10 #endif
11 
12 #ifndef BALL_KERNEL_ATOM_H
13 # include <BALL/KERNEL/atom.h>
14 #endif
15 
16 #ifndef BALL_KERNEL_BOND_H
17 # include <BALL/KERNEL/bond.h>
18 #endif
19 
20 #ifndef BALL_KERNEL_SYSTEM_H
21 # include <BALL/KERNEL/system.h>
22 #endif
23 
24 namespace BALL
25 {
26 
37  {
38  public:
40  {
42  Z,
43  E
44  };
45 
47  {
49  TH,
50  AL,
51  SP,
52  TB,
53  OH
54  };
55 
56  enum
57  {
58  MAX_CONNECTIONS = 100
59  };
60 
61  typedef std::pair<ChiralClass, Position> ChiralDef;
62 
63  class SPAtom;
65  : public Bond
66  {
67  public:
68  virtual ~SPBond() ;
69 
70  SPBond(SPAtom* first, SPAtom* second, Index order = 1);
71 
72  ZEIsomerType getZEType() const;
73  void setZEType(ZEIsomerType type);
74 
75  protected:
77  };
78 
80  : public Atom
81  {
82  public:
83 
84  SPAtom(const String& symbol, bool in_brackets);
85  virtual ~SPAtom() ;
86 
87  Size getDefaultValence() const;
88  Size countRealValences() const;
89 
90  Size getIsotope() const { return isotope_; }
91  void setIsotope(Size isotope) { isotope_ = isotope; };
92 
93  Index getFormalCharge() const { return formal_charge_; }
94  void setFormalCharge(Index charge) { formal_charge_ = charge; }
95 
96  const ChiralDef& getChirality() const { return chirality_; }
97  void setChirality(const ChiralDef& chirality) { chirality_ = chirality; }
98 
99  bool isAromatic() const { return is_aromatic_; }
100  void setAromatic(bool is_aromatic) { is_aromatic_ = is_aromatic; };
101  bool isInBrackets() const { return in_brackets_; }
102  void setInBrackets(bool in_brackets) { in_brackets_ = in_brackets; };
103 
104  protected:
105  Size isotope_;
110  };
111 
112  typedef std::list<Position> ConnectionList;
113 
117 
119  SmilesParser();
120 
122  SmilesParser(const SmilesParser& parser);
123 
125  virtual ~SmilesParser();
127 
134  void parse(const String& s);
135 
138  const System& getSystem() const;
140 
144  SPAtom* createAtom(const String& symbol, bool in_bracket = false);
146 
148  void createBonds(SPAtom* atom, const ConnectionList* list);
149 
151  void createBond(SPAtom* left, SPAtom* right, Index order);
152 
154  void addMissingHydrogens();
156 
157 
158  struct State
159  {
162  const char* buffer;
163  };
164 
165  static State state;
166 
167  protected:
169  std::vector<SPAtom*> connections_;
170  std::vector<SPAtom*> all_atoms_;
172  };
173 
174 } // namespace BALL
175 
176 #endif // BALL_STRUCTURE_SMILES_PARSER_H
BALL::SmilesParser::NONE
@ NONE
Definition: smilesParser.h:41
BALL::SmilesParser::SPAtom::chirality_
ChiralDef chirality_
Definition: smilesParser.h:107
BALL::SmilesParser::ConnectionList
std::list< Position > ConnectionList
Definition: smilesParser.h:112
BALL::SmilesParser::SPAtom::getIsotope
Size getIsotope() const
Definition: smilesParser.h:90
BALL::Bond
Definition: bond.h:54
BALL::SmilesParser::connections_
std::vector< SPAtom * > connections_
Definition: smilesParser.h:169
BALL::System
Definition: KERNEL/system.h:38
bond.h
BALL::SmilesParser::SPAtom::setIsotope
void setIsotope(Size isotope)
Definition: smilesParser.h:91
BALL::SmilesParser::SPAtom::getFormalCharge
Index getFormalCharge() const
Definition: smilesParser.h:93
BALL::Atom
Definition: atom.h:87
BALL::SmilesParser::NONCHIRAL
@ NONCHIRAL
Definition: smilesParser.h:48
BALL::SmilesParser::TB
@ TB
Definition: smilesParser.h:52
BALL::SmilesParser::ZEIsomerType
ZEIsomerType
Definition: smilesParser.h:39
BALL::SmilesParser::ChiralDef
std::pair< ChiralClass, Position > ChiralDef
Definition: smilesParser.h:61
BALL::SmilesParser::SPAtom::setFormalCharge
void setFormalCharge(Index charge)
Definition: smilesParser.h:94
BALL::SmilesParser::State::current_parser
SmilesParser * current_parser
Definition: smilesParser.h:161
BALL::String
Definition: string.h:56
BALL
Definition: constants.h:12
BALL::SmilesParser::system_
System system_
Definition: smilesParser.h:168
BALL::SmilesParser::SPAtom::is_aromatic_
bool is_aromatic_
Definition: smilesParser.h:108
BALL::SmilesParser::State::buffer
const char * buffer
Definition: smilesParser.h:162
BALL::SmilesParser::ChiralClass
ChiralClass
Definition: smilesParser.h:46
BALL::SmilesParser::Z
@ Z
Definition: smilesParser.h:42
BALL::Constants::E
const BALL_EXTERN_VARIABLE double E
Euler's number - base of the natural logarithm.
Definition: constants.h:38
BALL::SmilesParser::all_atoms_
std::vector< SPAtom * > all_atoms_
Definition: smilesParser.h:170
BALL::SmilesParser::State
Definition: smilesParser.h:158
BALL::SmilesParser::SPAtom::formal_charge_
Index formal_charge_
Definition: smilesParser.h:106
BALL::SmilesParser
Definition: smilesParser.h:36
BALL::SmilesParser::SPAtom::setChirality
void setChirality(const ChiralDef &chirality)
Definition: smilesParser.h:97
BALL_INDEX_TYPE
BALL::SmilesParser::SPAtom::isAromatic
bool isAromatic() const
Definition: smilesParser.h:99
BALL_SIZE_TYPE
BALL::SmilesParser::State::char_count
Size char_count
Definition: smilesParser.h:160
BALL::SmilesParser::SPAtom::getChirality
const ChiralDef & getChirality() const
Definition: smilesParser.h:96
atom.h
BALL::SmilesParser::TH
@ TH
Definition: smilesParser.h:49
BALL::SmilesParser::AL
@ AL
Definition: smilesParser.h:50
BALL::SmilesParser::SPAtom::setInBrackets
void setInBrackets(bool in_brackets)
Definition: smilesParser.h:102
common.h
BALL::SmilesParser::SPAtom
Definition: smilesParser.h:79
BALL::SmilesParser::current_parser_
static SmilesParser * current_parser_
Definition: smilesParser.h:171
BALL::SmilesParser::SPAtom::in_brackets_
bool in_brackets_
Definition: smilesParser.h:109
BALL::SmilesParser::state
static State state
Definition: smilesParser.h:165
BALL::SmilesParser::SPAtom::setAromatic
void setAromatic(bool is_aromatic)
Definition: smilesParser.h:100
BALL::SmilesParser::SPBond::ze_type_
ZEIsomerType ze_type_
Definition: smilesParser.h:76
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
system.h
BALL::SmilesParser::SPBond
Definition: smilesParser.h:64
BALL::SmilesParser::SPAtom::isInBrackets
bool isInBrackets() const
Definition: smilesParser.h:101
BALL::SmilesParser::SP
@ SP
Definition: smilesParser.h:51