Loading...
Searching...
No Matches
ringPerceptionProcessor.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: ringPerceptionProcessor.h,v 1.17.4.2 2007/04/03 13:29:45 bertsch Exp $
//
#ifndef BALL_QSAR_RINGPERCEPTIONPROCESSOR_H
#define BALL_QSAR_RINGPERCEPTIONPROCESSOR_H
#ifndef BALL_KERNEL_ATOMCONTAINER_H
#include <BALL/KERNEL/atomContainer.h>
#endif
#ifndef BALL_STRUCTURE_SIMPLEMOLECULARGRAPH_H
#include <BALL/STRUCTURE/simpleMolecularGraph.h>
#endif
#ifndef BALL_DATATYPE_OPTIONS_H
#include <BALL/DATATYPE/options.h>
#endif
#include <stack>
#include <vector>
namespace BALL
{
class BALL_EXPORT RingPerceptionProcessor
: public UnaryProcessor<AtomContainer>
{
public:
BALL_CREATE(RingPerceptionProcessor)
RingPerceptionProcessor();
RingPerceptionProcessor(const RingPerceptionProcessor& rp);
virtual ~RingPerceptionProcessor();
RingPerceptionProcessor& operator = (const RingPerceptionProcessor& rp);
Size calculateSSSR(vector<vector<Atom*> >& sssr, AtomContainer& ac);
const vector<vector<Atom*> >& getAllSmallRings() const;
Processor::Result operator () (AtomContainer& ac);
protected:
// Balducci and Pearlman algorithm
struct PathMessage_;
/*_ The tnode structure described in the paper
*/
struct TNode_
{
void recieve();
void send();
bool haveZeroIntersection(BitVector& beep1, BitVector& beep2);
bool haveSingleIntersection(BitVector& beep1, BitVector& beep2);
bool nodeIsNew(BitVector& beep, NodeItem<Index, Index>* node);
std::vector<PathMessage_> recieve_buffer;
std::vector<PathMessage_> send_buffer;
};
/*_ The pathMsg structure described in the paper
*/
struct PathMessage_
{
void push(EdgeItem<Index, Index>* bond, TNode_* node);
// path of the message
BitVector beep;
TNode_* nfirst;
// pointer to the last node of the messages' path
TNode_* nlast;
EdgeItem<Index, Index>* efirst;
};
static HashMap<TNode_*, NodeItem<Index, Index>* > tnode_to_atom_;
static HashMap<NodeItem<Index, Index>* , TNode_*> atom_to_tnode_;
static HashMap<EdgeItem<Index, Index>*, Size> bond_to_index_;
static HashMap<Size, EdgeItem<Index, Index>*> index_to_bond_;
static std::vector<BitVector> rings_;
static std::vector<BitVector> matrix_;
static std::vector<BitVector> forwarded_rings_;
static std::vector<BitVector> tested_beers_;
static std::vector<std::vector<Atom*> > all_small_rings_;
static std::vector<BitVector> all_small_beers_;
/*_ function that gets a binary edge-encoded ring as a BitVector
and adds it to the ringset if its linearly independend
*/
static void BalducciPearlmanRingSelector_(BitVector bit_vector);
/*_ Implementation of the Balducci/Pearlman algorithm
*/
Size BalducciPearlmanAlgorithm_(std::vector<std::vector<Atom*> >& sssr, SimpleMolecularGraph& graph);
};
namespace Exception
{
class BALL_EXPORT RingProcessorException: public GeneralException
{
public:
RingProcessorException(const char* file, int line)
: GeneralException(file, line, "RingProcessorException", "")
{
message_ = "\nCould not find a valid set of smallest rings for an input molecule.\n\n";
message_+= "Either the input molecule was not valid (e.g.: not a single connected component)\n";
message_+= "or the algorithm failed on this special topology.";
globalHandler.setMessage(message_);
}
};
} // namespace Exception
} // namespace BALL
#endif // BALL_QSAR_RINGPERCEPTIONPROCESSOR_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
atomContainer.h
BALL::AtomContainer
Definition atomContainer.h:32
BALL::Atom
Definition atom.h:90
BALL::BitVector
Definition bitVector.h:177
BALL::EdgeItem
Definition simpleMolecularGraph.h:94
BALL::Exception::GeneralException::GeneralException
GeneralException()
Default constructor.
BALL::Exception::GeneralException::message_
std::string message_
Definition COMMON/exception.h:111
BALL::Exception::RingProcessorException::RingProcessorException
RingProcessorException(const char *file, int line)
Definition ringPerceptionProcessor.h:186
BALL::HashMap
HashMap class based on the STL map (containing serveral convenience functions).
Definition hashMap.h:74
BALL::NodeItem
Definition simpleMolecularGraph.h:42
BALL::Processor
Definition processor.h:32
BALL::Result
Definition result.h:22
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::matrix_
static std::vector< BitVector > matrix_
the matrix for the independency tests
Definition ringPerceptionProcessor.h:149
BALL::RingPerceptionProcessor::rings_
static std::vector< BitVector > rings_
the SSSR detected by the algorithm
Definition ringPerceptionProcessor.h:146
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
BALL::RingPerceptionProcessor::RingPerceptionProcessor
RingPerceptionProcessor()
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::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::RingPerceptionProcessor::atom_to_tnode_
static HashMap< NodeItem< Index, Index > *, TNode_ * > atom_to_tnode_
Definition ringPerceptionProcessor.h:139
BALL::RingPerceptionProcessor::BalducciPearlmanRingSelector_
static void BalducciPearlmanRingSelector_(BitVector bit_vector)
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::RingPerceptionProcessor::index_to_bond_
static HashMap< Size, EdgeItem< Index, Index > * > index_to_bond_
Definition ringPerceptionProcessor.h:143
BALL::RingPerceptionProcessor::BalducciPearlmanAlgorithm_
Size BalducciPearlmanAlgorithm_(std::vector< std::vector< Atom * > > &sssr, SimpleMolecularGraph &graph)
BALL::RingPerceptionProcessor::tested_beers_
static std::vector< BitVector > tested_beers_
rings (beer) which have already been tested
Definition ringPerceptionProcessor.h:155
BALL::RingPerceptionProcessor::getAllSmallRings
const vector< vector< Atom * > > & getAllSmallRings() const
BALL::RingPerceptionProcessor::calculateSSSR
Size calculateSSSR(vector< vector< Atom * > > &sssr, AtomContainer &ac)
BALL::UnaryProcessor< AtomContainer >::UnaryProcessor
UnaryProcessor()
Definition processor.h:69
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
BALL::Exception
Definition COMMON/exception.h:33
BALL::Exception::globalHandler
BALL_EXPORT GlobalExceptionHandler globalHandler
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::SimpleMolecularGraph
TSimpleMolecularGraph< Index, Index > SimpleMolecularGraph
Definition simpleMolecularGraph.h:202
options.h
simpleMolecularGraph.h
BALL::RingPerceptionProcessor::PathMessage_
Definition ringPerceptionProcessor.h:121
BALL::RingPerceptionProcessor::PathMessage_::nlast
TNode_ * nlast
Definition ringPerceptionProcessor.h:131
BALL::RingPerceptionProcessor::PathMessage_::push
void push(EdgeItem< Index, Index > *bond, TNode_ *node)
BALL::RingPerceptionProcessor::PathMessage_::nfirst
TNode_ * nfirst
pointer to the first node this message was sent from
Definition ringPerceptionProcessor.h:128
BALL::RingPerceptionProcessor::PathMessage_::efirst
EdgeItem< Index, Index > * efirst
pointer to the first edge of the message path
Definition ringPerceptionProcessor.h:134
BALL::RingPerceptionProcessor::PathMessage_::beep
BitVector beep
Definition ringPerceptionProcessor.h:125
BALL::RingPerceptionProcessor::TNode_
Definition ringPerceptionProcessor.h:98
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_::haveZeroIntersection
bool haveZeroIntersection(BitVector &beep1, BitVector &beep2)
BALL::RingPerceptionProcessor::TNode_::haveSingleIntersection
bool haveSingleIntersection(BitVector &beep1, BitVector &beep2)
BALL::RingPerceptionProcessor::TNode_::nodeIsNew
bool nodeIsNew(BitVector &beep, NodeItem< Index, Index > *node)
BALL::RingPerceptionProcessor::TNode_::send
void send()
method to process the messages in the send buffer
BALL::RingPerceptionProcessor::TNode_::send_buffer
std::vector< PathMessage_ > send_buffer
the send buffer, where messages are stored in
Definition ringPerceptionProcessor.h:115
BALL::RingPerceptionProcessor::TNode_::recieve
void recieve()
method to process the messages in the recieve buffer