BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
133  void parse(const String& s)
134  throw(Exception::ParseError);
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
Index getFormalCharge() const
Definition: smilesParser.h:93
BALL_EXTERN_VARIABLE const double E
Euler's number - base of the natural logarithm.
Definition: constants.h:38
void setAromatic(bool is_aromatic)
Definition: smilesParser.h:100
void setIsotope(Size isotope)
Definition: smilesParser.h:91
const ChiralDef & getChirality() const
Definition: smilesParser.h:96
std::vector< SPAtom * > connections_
Definition: smilesParser.h:169
static SmilesParser * current_parser_
Definition: smilesParser.h:171
void setInBrackets(bool in_brackets)
Definition: smilesParser.h:102
std::list< Position > ConnectionList
Definition: smilesParser.h:112
void setFormalCharge(Index charge)
Definition: smilesParser.h:94
void setChirality(const ChiralDef &chirality)
Definition: smilesParser.h:97
std::pair< ChiralClass, Position > ChiralDef
Definition: smilesParser.h:61
std::vector< SPAtom * > all_atoms_
Definition: smilesParser.h:170
SmilesParser * current_parser
Definition: smilesParser.h:161
#define BALL_EXPORT
Definition: COMMON/global.h:50
static State state
Definition: smilesParser.h:165