Generated on Wed Apr 29 2015 11:51:40 for GGL-4.1.2 by doxygen 1.8.3.1
AP_disabled.hh
Go to the documentation of this file.
1 
2 #ifndef GGL_CHEM_AP_DISABLED_HH_
3 #define GGL_CHEM_AP_DISABLED_HH_
4 
5 #include <cassert>
6 #include <vector>
7 #include <set>
8 #include <algorithm>
9 #include <limits>
10 
11 
12 #include "ggl/chem/Molecule.hh"
13 #include "ggl/chem/MoleculeUtil.hh"
15 
16 namespace ggl {
17 namespace chem {
18 
19 ////////////////////////////////////////////////////////////////////////////////
20 ////////////////////////////////////////////////////////////////////////////////
21 
22 
23  /*! @brief disables aromaticity prediction
24  *
25  * Dummy aromaticity perception implementation that actually performs NO
26  * AROMATICITY PERCEPTION at all and thus disables aromaticity perception
27  * wherever used.
28  *
29  * The current aromaticity assignment is preserved.
30  *
31  * @author Martin Mann (c) 2014 http://www.bioinf.uni-freiburg.de/~mmann/
32  *
33  */
35  : public AromaticityPerception
36  {
37  public :
38 
39  //! ring describing class
41 
42  //! Vector that holds ( index, weight ) pairs
43  typedef std::vector< std::pair<size_t,double> > RingWeightVec;
44 
45 
46  protected:
47 
48  //! defines an edge; NOTE: use as ordered pairs, i.e. first <= second
50  //! defines an aromatic ring via the set of aromatic edges
52 
53  //! the aromatic ring container to fill
55 
56  //! container that will hold all rings of the current molecule
57  //! -> this list is later pruned to the rings of interest
59 
60  public:
61 
62 
63  /*!
64  * Construction
65  * @param model the aromaticity model to be used
66  */
69  {}
70 
71  /*!
72  * Copy construction
73  * @param toCopy the object to make this a copy of
74  */
75  AP_disabled( const AP_disabled & toCopy )
76  : AromaticityPerception( toCopy )
77  {}
78 
79  /*!
80  * destruction
81  */
82  virtual ~AP_disabled()
83  {}
84 
85 
86  /*!
87  * Does nothing here...
88  *
89  * @param mol the molecule to check for rings
90  */
91  virtual
92  void
93  findAllRings( const Molecule & mol )
94  {
95  // DO NOTHING
96  }
97 
98  /*!
99  * Push all currently aromatic edges to the
100  * aromaticEdges container.
101  *
102  * @param mol the molecule to check for aromatic rings
103  */
104  void
106  {
107  boost::property_map< Molecule , PropNodeIndex >
108  ::const_type nodeIndex = boost::get( PropNodeIndex(), mol );
109  boost::property_map< Molecule , PropEdgeLabel >
110  ::const_type edgeLabel = boost::get( PropEdgeLabel(), mol );
111 
112  // get access to edge descriptors
113  boost::graph_traits<Molecule>::edge_iterator ei, e_end;
114  boost::tie(ei, e_end) = boost::edges( mol );
115 
116  // check all edges if they have to be relabeled
117  for (; ei != e_end; ++ei) {
118  // get bond data for this edge
119  const MoleculeUtil::BondLabelData * bondData
120  = MoleculeUtil::getBondData( edgeLabel[*ei] );
121  assert( bondData != NULL /*unknown bond label*/);
122 
123  // check if the bond is currently aromatic
124  if ( bondData->isAromatic != 0 ) {
125  // generate edge descriptor
126  Edge curEdge( nodeIndex[boost::source(*ei,mol)]
127  , nodeIndex[boost::target(*ei,mol)] );
128  if (curEdge.first > curEdge.second) {
129  curEdge = Edge(curEdge.second, curEdge.first);
130  }
131  // store to preserve bond aromaticity
132  aromaticEdges.insert(curEdge);
133  }
134  }
135 
136  }
137 
138  /*!
139  * Does nothing and thus fully disables aromaticity perception
140  *
141  * @param mol the molecule to correct (not changed)
142  * @param checkValence whether or not the valence of nodes and bonds
143  * should be checked. (ignored)
144  *
145  * @throw std::runtime_error (never thrown)
146  */
147  virtual
148  void
149  correctAromaticity( Molecule & mol, const bool checkValence )
150  throw (std::runtime_error)
151  {}
152 
153 
154  /*!
155  * Creates a heap copy of this instance that has to be deleted by the
156  * calling methods later on.
157  * @return a new instance that is a copy of this object
158  */
159  virtual
160  AP_disabled *
161  clone() const
162  {
163  return new AP_disabled();
164  }
165 
166  };
167 
168 
169 ////////////////////////////////////////////////////////////////////////////////
170 ////////////////////////////////////////////////////////////////////////////////
171 
172 }} // namespace
173 
174 
175 #endif /* GGL_CHEM_AP_DISABLED_HH_ */