BALL  1.5.0
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 
23 #include <stack>
24 #include <vector>
25 
26 namespace BALL
27 {
37  : public UnaryProcessor<AtomContainer>
38 {
39 public:
40 
42 
43 
49 
53 
56  virtual ~RingPerceptionProcessor();
57 
59 
62 
65  RingPerceptionProcessor& operator = (const RingPerceptionProcessor& rp);
66 
68 
71 
76  Size calculateSSSR(vector<vector<Atom*> >& sssr, AtomContainer& ac);
78 
82  const vector<vector<Atom*> >& getAllSmallRings() const;
83 
87  Processor::Result operator () (AtomContainer& ac);
89 
90 protected:
91 
92  // Balducci and Pearlman algorithm
93  struct PathMessage_;
94 
95  /*_ The tnode structure described in the paper
96  */
97  struct TNode_
98  {
100  void recieve();
101 
103  void send();
104 
105  bool haveZeroIntersection(BitVector& beep1, BitVector& beep2);
106 
107  bool haveSingleIntersection(BitVector& beep1, BitVector& beep2);
108 
109  bool nodeIsNew(BitVector& beep, NodeItem<Index, Index>* node);
110 
112  std::vector<PathMessage_> recieve_buffer;
113 
115  std::vector<PathMessage_> send_buffer;
116  };
117 
118  /*_ The pathMsg structure described in the paper
119  */
121  {
122  void push(EdgeItem<Index, Index>* bond, TNode_* node);
123 
124  // path of the message
126 
129 
130  // pointer to the last node of the messages' path
132 
135  };
136 
140 
144 
146  static std::vector<BitVector> rings_;
147 
149  static std::vector<BitVector> matrix_;
150 
152  static std::vector<BitVector> forwarded_rings_;
153 
155  static std::vector<BitVector> tested_beers_;
156 
158  static std::vector<std::vector<Atom*> > all_small_rings_;
159 
161  static std::vector<BitVector> all_small_beers_;
162 
163  /*_ function that gets a binary edge-encoded ring as a BitVector
164  and adds it to the ringset if its linearly independend
165  */
166  static void BalducciPearlmanRingSelector_(BitVector bit_vector);
167 
168  /*_ Implementation of the Balducci/Pearlman algorithm
169  */
170  Size BalducciPearlmanAlgorithm_(std::vector<std::vector<Atom*> >& sssr, SimpleMolecularGraph& graph);
171 };
172 
173 
181 namespace Exception
182 {
184 {
185 public:
186  RingProcessorException(const char* file, int line)
187  : GeneralException(file, line, "RingProcessorException", "")
188  {
189  message_ = "\nCould not find a valid set of smallest rings for an input molecule.\n\n";
190  message_+= "Either the input molecule was not valid (e.g.: not a single connected component)\n";
191  message_+= "or the algorithm failed on this special topology.";
192 
193  globalHandler.setMessage(message_);
194  }
195 };
196 } // namespace Exception
197 
198 } // namespace BALL
199 
200 #endif // BALL_QSAR_RINGPERCEPTIONPROCESSOR_H
BALL::RingPerceptionProcessor::matrix_
static std::vector< BitVector > matrix_
the matrix for the independency tests
Definition: ringPerceptionProcessor.h:149
BALL::RingPerceptionProcessor::PathMessage_::beep
BitVector beep
Definition: ringPerceptionProcessor.h:125
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
BALL::RingPerceptionProcessor::rings_
static std::vector< BitVector > rings_
the SSSR detected by the algorithm
Definition: ringPerceptionProcessor.h:146
BALL::RingPerceptionProcessor::TNode_::recieve_buffer
std::vector< PathMessage_ > recieve_buffer
the recieve buffer, where messages are stored in
Definition: ringPerceptionProcessor.h:112
BALL::RingPerceptionProcessor::tnode_to_atom_
static HashMap< TNode_ *, NodeItem< Index, Index > * > tnode_to_atom_
mapping for internal TNode structure and the nodes of the molecular graph
Definition: ringPerceptionProcessor.h:138
BALL::Exception::GeneralException
Definition: COMMON/exception.h:59
BALL::HashMap
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:73
BALL::RingPerceptionProcessor::PathMessage_::nlast
TNode_ * nlast
Definition: ringPerceptionProcessor.h:131
BALL::RingPerceptionProcessor::PathMessage_::nfirst
TNode_ * nfirst
pointer to the first node this message was sent from
Definition: ringPerceptionProcessor.h:128
BALL::AtomContainer
Definition: atomContainer.h:29
BALL_SIZE_TYPE
BALL::NodeItem
Definition: simpleMolecularGraph.h:41
BALL::Exception::RingProcessorException::RingProcessorException
RingProcessorException(const char *file, int line)
Definition: ringPerceptionProcessor.h:186
BALL
Definition: constants.h:12
BALL::RingPerceptionProcessor::TNode_
Definition: ringPerceptionProcessor.h:97
simpleMolecularGraph.h
BALL::EdgeItem
Definition: simpleMolecularGraph.h:32
BALL::RingPerceptionProcessor::tested_beers_
static std::vector< BitVector > tested_beers_
rings (beer) which have already been tested
Definition: ringPerceptionProcessor.h:155
options.h
BALL::BitVector
Definition: bitVector.h:176
BALL::RingPerceptionProcessor::all_small_rings_
static std::vector< std::vector< Atom * > > all_small_rings_
contains all 3 to 6 membered rings after the procedure of the Balducci-Pearlman algorithm
Definition: ringPerceptionProcessor.h:158
BALL::RingPerceptionProcessor::PathMessage_::efirst
EdgeItem< Index, Index > * efirst
pointer to the first edge of the message path
Definition: ringPerceptionProcessor.h:134
BALL::Exception::RingProcessorException
Definition: ringPerceptionProcessor.h:183
BALL::RingPerceptionProcessor::TNode_::send_buffer
std::vector< PathMessage_ > send_buffer
the send buffer, where messages are stored in
Definition: ringPerceptionProcessor.h:115
BALL::RingPerceptionProcessor::index_to_bond_
static HashMap< Size, EdgeItem< Index, Index > * > index_to_bond_
Definition: ringPerceptionProcessor.h:143
BALL::UnaryProcessor
Definition: processor.h:58
BALL::RingPerceptionProcessor::bond_to_index_
static HashMap< EdgeItem< Index, Index > *, Size > bond_to_index_
mapping for the path representation as bitvectors
Definition: ringPerceptionProcessor.h:142
BALL::Exception::globalHandler
BALL_EXPORT GlobalExceptionHandler globalHandler
BALL::RingPerceptionProcessor::PathMessage_
Definition: ringPerceptionProcessor.h:120
atomContainer.h
BALL::Exception::GlobalExceptionHandler::setMessage
static void setMessage(const String &message)
Set the error message.
BALL::Processor::Result
int Result
Definition: processor.h:36
BALL_CREATE
#define BALL_CREATE(name)
Definition: create.h:62
BALL::RingPerceptionProcessor
Definition: ringPerceptionProcessor.h:36
BALL::RingPerceptionProcessor::forwarded_rings_
static std::vector< BitVector > forwarded_rings_
the rings of the ith phase, which are to be forwarded to the ring selector
Definition: ringPerceptionProcessor.h:152
BALL::RingPerceptionProcessor::atom_to_tnode_
static HashMap< NodeItem< Index, Index > *, TNode_ * > atom_to_tnode_
Definition: ringPerceptionProcessor.h:139
BALL::TSimpleMolecularGraph
Definition: simpleMolecularGraph.h:35
BALL::RingPerceptionProcessor::all_small_beers_
static std::vector< BitVector > all_small_beers_
contains all 3 to 6 membered rings as beers
Definition: ringPerceptionProcessor.h:161