BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
kekulizer.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_KEKULIZER_H
6 #define BALL_STRUCTURE_KEKULIZER_H
7 
8 #ifndef BALL_COMMON_H
9 # include <BALL/common.h>
10 #endif
11 
12 #ifndef BALL_DATATYPE_HASHMAP_H
13 # include <BALL/DATATYPE/hashMap.h>
14 #endif
15 
16 #include <set>
17 
18 namespace BALL
19 {
20  class Atom;
21  class Molecule;
22  class Bond;
23 
38  {
40  struct BALL_EXPORT AtomInfo
41  {
42  // needed for sorting:
43  bool operator < (const AtomInfo& info) const;
44  AtomInfo& operator = (const AtomInfo& ai) ;
45 
46  // THE atom
47  Atom* atom;
48 
49  // bond to be set to a double bond
50  Bond* double_bond;
51 
52  // aromatic bonds
53  std::vector<Bond*> abonds;
54 
55  // position of the partner atoms in the vector of AtomInfos
56  std::vector<Position> partner_id;
57 
58  // current number of double bonds for this atom
59  Index curr_double;
60 
61  // minumum possible number of double bonds for this atom
62  Index min_double;
63 
64  // maximum possible number of double bonds for this atom
65  Index max_double;
66 
67  // number of double bonds for this atom to be uncharged
68  Index uncharged_double;
69  };
70 
71  public:
72 
74 
75 
76  Kekuliser();
77 
79  virtual ~Kekuliser() {}
80 
82  bool setup(Molecule& ac);
83 
85  void setAromaticRings(const std::vector<std::set<Atom*> >& rings) { aromatic_rings_ = rings;}
86 
88  void setRings(const std::vector<std::set<Atom*> >& rings) { rings_ = rings;}
89 
91  const std::vector<Bond*>& getUnassignedBonds() const { return unassigned_bonds_; }
92 
94  void clear();
95 
97  void dump();
98 
100  void setUseFormalCharges(bool state) { use_formal_charges_ = state;}
101 
103  bool useFormalCharges() const { return use_formal_charges_;}
104 
105  protected:
106 
107  bool fixAromaticRings_();
108  void fixAromaticSystem_(Position it);
109  virtual Size getPenalty_(Atom& atom, Index charge);
110 
111  void getMaximumValence_();
112 
113  // merge aromatic rings:
114  void calculateAromaticSystems_();
115  void collectSystems_(Atom& atom);
116  void collectAromaticAtoms_();
117  bool hasAromaticBonds_(Atom& atom);
118  void applySolution_(Position pos);
119  Position calculateDistanceScores_();
120 
122 
123  std::vector<std::set<Atom*> > aromatic_systems_;
124  std::vector<std::set<Atom*> > aromatic_rings_;
125  std::vector<std::set<Atom*> > rings_;
126  std::vector<Bond*> unassigned_bonds_;
127 
128  // atoms that take part in an aromatic bond:
129  std::set<const Atom*> aromatic_atoms_;
130  std::set<const Atom*> all_aromatic_atoms_;
132 
133  std::set<Atom*> current_aromatic_system_;
134 
135  // current aromatic system:
136  std::vector<AtomInfo> atom_infos_;
140 
141  std::vector<std::vector<AtomInfo> > solutions_;
142  };
143 
144 } // namespace BALL
145 
146 #endif // BALL_STRUCTURE_KEKULIZER_H
std::vector< Bond * > unassigned_bonds_
Definition: kekulizer.h:126
#define BALL_CREATE(name)
Definition: create.h:62
void setAromaticRings(const std::vector< std::set< Atom * > > &rings)
Definition: kekulizer.h:85
std::vector< std::set< Atom * > > rings_
Definition: kekulizer.h:125
std::set< Atom * > current_aromatic_system_
Definition: kekulizer.h:133
Size lowest_penalty_
Definition: kekulizer.h:138
bool useFormalCharges() const
Definition: kekulizer.h:103
bool use_formal_charges_
Definition: kekulizer.h:121
void setUseFormalCharges(bool state)
Definition: kekulizer.h:100
virtual ~Kekuliser()
Definition: kekulizer.h:79
void setRings(const std::vector< std::set< Atom * > > &rings)
Definition: kekulizer.h:88
std::vector< std::set< Atom * > > aromatic_rings_
Definition: kekulizer.h:124
std::vector< std::vector< AtomInfo > > solutions_
Definition: kekulizer.h:141
Size current_penalty_
Definition: kekulizer.h:139
std::set< const Atom * > all_aromatic_atoms_
Definition: kekulizer.h:130
std::set< const Atom * > aromatic_atoms_
Definition: kekulizer.h:129
char Atom[5]
Definition: PDBdefs.h:257
std::vector< AtomInfo > atom_infos_
Definition: kekulizer.h:136
HashMap< Atom *, Index > max_valence_
Definition: kekulizer.h:131
std::vector< std::set< Atom * > > aromatic_systems_
Definition: kekulizer.h:123
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:73
#define BALL_EXPORT
Definition: COMMON/global.h:50
Molecule * molecule_
Definition: kekulizer.h:137
const std::vector< Bond * > & getUnassignedBonds() const
Definition: kekulizer.h:91
BALL_EXPORT bool operator<(const String &s1, const String &s2)