Generated on Wed Apr 29 2015 11:51:40 for GGL-4.1.2 by doxygen 1.8.3.1
GS_SMILES_OB.hh
Go to the documentation of this file.
1 #ifndef GGL_CHEM_GS_SMILES_OB_HH_
2 #define GGL_CHEM_GS_SMILES_OB_HH_
3 
4 #include "ggl/chem/GS_chem.hh"
5 
6 #include "ggl/chem/Molecule.hh"
7 
8 
9 #include <iterator>
10 
11 namespace ggl {
12  namespace chem {
13 
14 #define GGL_CHEM_GS_SMILES_OB_TEMPLATE \
15  template < class STL_INSERTER >
16 
17 #define GGL_CHEM_GS_SMILES_OB_TYPE \
18  GS_SMILES_OB < STL_INSERTER >
19 
20 
21 
22 
23  /*! @brief SMILES graph storage OpenBabel
24  *
25  * A Graph_Storage implementation that converts each added Molecule graph
26  * into a SMILES string representation and adds it to the specified
27  * STL string container.
28  *
29  * Usage Examples :
30  * \verbatim
31  * //////////////////////////////////////////////////////////////////////
32  *
33  * std::set< std::string > SMILES_set;
34  * typedef std::insert_iterator< SMILES_set > SMILES_set_inserter;
35  *
36  * SMILES_set smilesSet;
37  * SMILES_set_inserter insertSet(smilesSet, smilesSet.end());
38  *
39  * ggl::chem::GS_SMILES_OB< SMILES_set_inserter > gs_set(insertSet);
40  *
41  * //////////////////////////////////////////////////////////////////////
42  *
43  * std::vector< std::string > SMILES_vector;
44  * typedef std::back_insert_iterator< SMILES_vector > SMILES_vector_inserter;
45  *
46  * SMILES_vector smilesVec;
47  * SMILES_vector_inserter insertVec(smilesVec);
48  *
49  * ggl::chem::GS_SMILES_OB< SMILES_vector_inserter > gs_vec(insertVec);
50  *
51  * //////////////////////////////////////////////////////////////////////
52  * \endverbatim
53  *
54  * @author Martin Mann (c) 2008 http://www.bioinf.uni-freiburg.de/~mmann/
55  *
56  * @tparam STL_INSERTER an STL insert iterator (e.g. std::insert_iterator)
57  * to add all SMILES to store to
58  */
59  template < class STL_INSERTER >
60  class GS_SMILES_OB : public GS_chem {
61 
62  protected:
63 
64  //! the std::inserter where each SMILES string is reported to
65  STL_INSERTER insert;
66 
67 
68  public:
69 
70  //! Construction
71  //! @param insert the STL inserter to which each generated SMILES
72  //! is assigned to
73  GS_SMILES_OB( STL_INSERTER insert );
74 
75  //! Destruction
76  virtual
77  ~GS_SMILES_OB();
78 
79 
80  /*! Adds the SMILES string representation of a given graph to a
81  * string container.
82  * @param graph the Graph object to add.
83  */
84  virtual
85  void
86  addMolecule( const Molecule & graph );
87  };
88 
89 
90  } // namespace chem
91 } // namespace ggl
92 
93 
94 namespace ggl {
95  namespace chem {
96 
97 #define GGL_CHEM_GS_SMILES_OB_MOL_TEMPLATE \
98  template < class SMILES_MOL_MAP >
99 
100 #define GGL_CHEM_GS_SMILES_OB_MOL_TYPE \
101  GS_SMILES_OB_MOL < SMILES_MOL_MAP >
102 
103 
104  /*! @brief SMILES graph storage OpenBabel using STL SMILES-Graph map
105  *
106  * A Graph_Storage implementation that converts each added Molecule graph
107  * into a SMILES string representation and adds it, if not already
108  * existing, to the specified STL map container using the SMILES as key
109  * and the Molecule object as value.
110  *
111  * @author Martin Mann (c) 2008 http://www.bioinf.uni-freiburg.de/~mmann/
112  *
113  * @tparam STL_INSERTER an STL insert iterator (e.g. std::insert_iterator)
114  * to add all SMILES to store to
115  */
116  template < class SMILES_MOL_MAP >
117  class GS_SMILES_OB_MOL : public GS_chem {
118 
119  protected:
120 
121  //! the map where each SMILES string is mapped to the represented
122  //! molecule
123  SMILES_MOL_MAP* smiles2mol;
124 
125  public:
126 
127  //! Construction
128  //! @param smiles2mol the STL inserter to which each generated SMILES
129  //! and its molecule is assigned to
130  GS_SMILES_OB_MOL( SMILES_MOL_MAP& smiles2mol );
131 
132 
133  virtual
135 
136 
137  //! Rewrites a given molecule to SMILES and adds it to a contained.
138  //! @param graph the molecule to add.
139  virtual
140  void
141  addMolecule( const Molecule & graph );
142 
143  protected:
144 
145  virtual
146  bool
147  insert2map(const std::string & SMILES, const Molecule& graph );
148 
149  };
150 
151  } // namespace chem
152 } // namespace ggl
153 
154 
155 namespace ggl {
156  namespace chem {
157 
158 
159 #define GGL_CHEM_GS_SMILES_OB_MOLp_TEMPLATE \
160  template < class SMILES_MOL_MAP >
161 
162 #define GGL_CHEM_GS_SMILES_OB_MOLp_TYPE \
163  GS_SMILES_OB_MOL < SMILES_MOL_MAP >
164 
165 
166  /*! @brief SMILES graph storage OpenBabel using STL SMILES-GraphPointer map
167  *
168  * A Graph_Storage implementation that converts each added Molecule graph
169  * into a SMILES string representation and adds it, if not already
170  * existing, to the specified STL map container using the SMILES as key
171  * and the pointer to the newly allocated Molecule object as value.
172  *
173  * @author Martin Mann (c) 2008 http://www.bioinf.uni-freiburg.de/~mmann/
174  *
175  * @tparam STL_INSERTER an STL insert iterator (e.g. std::insert_iterator)
176  * to add all SMILES to store to
177  */
178  template < class SMILES_MOL_MAP >
179  class GS_SMILES_OB_MOLp : public GS_chem {
180 
181  protected:
182 
183  //! the map where each SMILES string is mapped to the represented
184  //! molecule
185  SMILES_MOL_MAP* smiles2mol;
186 
187 
188  public:
189 
190  size_t reportedHits;
191 
192  //! Construction
193  //! @param smiles2mol the STL inserter to which each generated SMILES
194  //! and its molecule is assigned to
195  GS_SMILES_OB_MOLp( SMILES_MOL_MAP& smiles2mol );
196 
197 
198  virtual
200 
201 
202  //! Rewrites the given molecule to SMILES and adds it to a contained
203  //! @param graph the molecule to add.
204  virtual
205  void
206  addMolecule( const Molecule & graph );
207 
208  protected:
209 
210  virtual
211  bool
212  insert2map(const std::string & SMILES, const Molecule& graph );
213 
214  };
215 
216  } // namespace chem
217 } // namespace ggl
218 
219 #include "ggl/chem/GS_SMILES_OB.icc"
220 
221 
222 #endif /*GS_SMILES_OB_HH_*/