BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ringPerceptionProcessor.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: ringPerceptionProcessor.h,v 1.17.4.2 2007/04/03 13:29:45 bertsch Exp $
5 //
6 
7 #ifndef BALL_QSAR_RINGPERCEPTIONPROCESSOR_H
8 #define BALL_QSAR_RINGPERCEPTIONPROCESSOR_H
9 
10 #ifndef BALL_KERNEL_ATOMCONTAINER_H
12 #endif
13 
14 #ifndef BALL_STRUCTURE_SIMPLEMOLECULARGRAPH_H
16 #endif
17 
18 #ifndef BALL_DATATYPE_OPTIONS_H
19  #include <BALL/DATATYPE/options.h>
20 #endif
21 
22 #include <stack>
23 #include <vector>
24 
25 namespace BALL
26 {
38  : public UnaryProcessor<AtomContainer>
39  {
40  public:
41 
45  struct Option
47  {
55  static const char* ALGORITHM_NAME;
56  };
57 
59  struct Default
60  {
65  static const char* ALGORITHM_NAME;
66  };
67 
68 
70 
71 
77 
80  RingPerceptionProcessor(const RingPerceptionProcessor& rp);
81 
84  virtual ~RingPerceptionProcessor();
85 
87 
90 
93  RingPerceptionProcessor& operator = (const RingPerceptionProcessor& rp);
94 
96 
99 
104  Size calculateSSSR(vector<vector<Atom*> >& sssr, AtomContainer& ac);
106 
110  const vector<vector<Atom*> >& getAllSmallRings() const;
111 
115  Processor::Result operator () (AtomContainer& ac);
117 
122  Size findAllBCC(std::vector<SimpleMolecularGraph*>& bcc, SimpleMolecularGraph& graph);
123 
124  /*_ Options for the ring perception
125  */
126  Options options;
127 
130  void setDefaultOptions();
131 
132  protected:
133 
134  /*_ @name Accessors
135  */
137  /*_ Implementation of the Figueras algorithm. This algorithm has some build
138  in bugs, and should not be used any more. Hence as default the provable
139  correct Balducci/Pearlman algorithm is used.
140  */
141  Size FiguerasAlgorithm_(vector<vector<Atom*> >& sssr, AtomContainer& ac);
142 
143  /*_ Method that return the smallest ring which atom n participates
144  @param atom from which the search is started
145  @param ring set in which the found ring is stored (if any)
146  */
147  Size getRing_(Atom* n, HashSet<Atom*>& ring_set);
148 
149  /*_ A bond, which when deleted leads to the smallest ring
150  is deleted.
151  @param ring_set atoms to test
152  @param ac the atom container the algorithm works on
153  */
154  void checkEdges_(HashSet<Atom*>& ring_set, AtomContainer& ac);
155 
156  /*_ Method that finds all biconnected components, the algorithm is freely
157  adapted from a standard bcc algorithm.
158  */
159  Size findAllBCC_(std::vector<SimpleMolecularGraph*>& bcc, SimpleMolecularGraph& graph);
160 
161  /*_ recursive function that finds bccs
162  */
163  void DFSBCC_( std::vector<SimpleMolecularGraph*>& bccs, Size dfbi,
164  HashMap<NodeItem<Index, Index>*, Size> DFBIndex,
165  NodeItem<Index, Index>* v);
166 
167  HashSet<NodeItem<Index, Index>* > visited_;
168  HashSet<EdgeItem<Index, Index>* > visited_bonds_;
169  HashMap<NodeItem<Index, Index>* , Size> P_;
170  HashMap<NodeItem<Index, Index>*, NodeItem<Index, Index>* > parents_;
171  std::stack<EdgeItem<Index, Index>* > BCC_;
172 
173 
174  // Balducci and Pearlman algorithm
175  struct PathMessage_;
176 
177  /*_ The tnode structure described in the paper
178  */
179  struct TNode_
180  {
182  void recieve();
183 
185  void send();
186 
188  std::vector<PathMessage_> recieve_buffer;
189 
191  std::vector<PathMessage_> send_buffer;
192  };
193 
194  /*_ The pathMsg structure described in the paper
195  */
197  {
198  void push(EdgeItem<Index, Index>* bond, TNode_* node);
199 
200  // path of the message
202 
205 
206  // pointer to the last node of the messages' path
208 
211  };
212 
216 
220 
222  static std::vector<BitVector> rings_;
223 
225  static std::vector<BitVector> matrix_;
226 
228  static std::vector<BitVector> forwarded_rings_;
229 
231  static std::vector<BitVector> tested_beers_;
232 
234  static std::vector<std::vector<Atom*> > all_small_rings_;
235 
237  static std::vector<BitVector> all_small_beers_;
238 
239  /*_ function that gets a binary edge-encoded ring as a BitVector
240  and adds it to the ringset if its linearly independend
241  */
242  static void BalducciPearlmanRingSelector_(BitVector bit_vector);
243 
244  /*_ Implementation of the Balducci/Pearlman algorithm
245  */
246  Size BalducciPearlmanAlgorithm_(std::vector<std::vector<Atom*> >& sssr, SimpleMolecularGraph& graph);
247  };
248 } // namespace BALL
249 
250 #endif // BALL_QSAR_RINGPERCEPTIONPROCESSOR_H
#define BALL_CREATE(name)
Definition: create.h:62
TNode_ * nfirst
pointer to the first node this message was sent from
static std::vector< BitVector > tested_beers_
rings (beer) which have already been tested
static HashMap< TNode_ *, NodeItem< Index, Index > * > tnode_to_atom_
mapping for internal TNode structure and the nodes of the molecular graph
static HashMap< Size, EdgeItem< Index, Index > * > index_to_bond_
static std::vector< BitVector > forwarded_rings_
the rings of the ith phase, which are to be forwarded to the ring selector
static std::vector< std::vector< Atom * > > all_small_rings_
contains all 3 to 6 membered rings after the procedure of the Balducci-Pearlman algorithm ...
static std::vector< BitVector > rings_
the SSSR detected by the algorithm
default options for the ring perception
std::vector< PathMessage_ > send_buffer
the send buffer, where messages are stored in
static HashMap< EdgeItem< Index, Index > *, Size > bond_to_index_
mapping for the path representation as bitvectors
static std::vector< BitVector > all_small_beers_
contains all 3 to 6 membered rings as beers
static HashMap< NodeItem< Index, Index > *, TNode_ * > atom_to_tnode_
EdgeItem< Index, Index > * efirst
pointer to the first edge of the message path
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:73
std::vector< PathMessage_ > recieve_buffer
the recieve buffer, where messages are stored in
#define BALL_EXPORT
Definition: COMMON/global.h:50
static std::vector< BitVector > matrix_
the matrix for the independency tests