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