main page
namespaces
classes
files
GGL home
Generated on Wed Apr 29 2015 11:51:40 for GGL-4.1.2 by
doxygen
1.8.3.1
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
src
ggl
chem
GS_chem.hh
Go to the documentation of this file.
1
#ifndef GGL_CHEM_GS_CHEM_HH_
2
#define GGL_CHEM_GS_CHEM_HH_
3
4
#include "
ggl/Graph_Storage.hh
"
5
6
#include <boost/graph/filtered_graph.hpp>
7
#include <boost/graph/connected_components.hpp>
8
9
#include "
ggl/chem/Molecule.hh
"
10
11
namespace
ggl {
12
namespace
chem {
13
14
15
16
17
/*! @brief Interface molecule graph storage
18
*
19
* An abstract interface for the storage of molecule objects.
20
* For instance, it is used by ggl::MR_ApplyRule to store the
21
* molecule graphs resulting from graph grammar ggl::chem::ChemRule
22
* applications.
23
*
24
* @author Martin Mann (c) 2011 http://www.bioinf.uni-freiburg.de/~mmann/
25
*/
26
class
GS_chem
:
public
ggl::Graph_Storage
27
{
28
protected
:
29
30
//! the container type used to represent the connected component id
31
//! for each node
32
typedef
std::vector<int>
ComponentIdVec
;
33
34
//! the type of a constant index map of a Molecule boost graph
35
typedef
boost::property_map<Molecule, PropNodeIndex>::const_type
IndexMap
;
36
37
/*!
38
* A boost graph node filter used as VertexPredicate of a
39
* boost::filtered_graph to represent a specific connected component
40
* of a Molecule. This is needed if the added Molecule represents
41
* a set of molecules to generate a SMILES string for each of them.
42
*
43
*/
44
class
node_is_in_component
{
45
protected
:
46
//! componentID the index of the connected component to represent
47
int
componentID
;
48
//! the connected component ID for each vertex
49
const
ComponentIdVec
*
componentVec
;
50
//! the index map of the underlying graph to get the index of a
51
//! requested vertex
52
const
IndexMap
*
idxMap
;
53
public
:
54
//! empty construction
55
node_is_in_component
();
56
57
/*! construction
58
* @param componentID the index of the connected component to
59
* represent
60
* @param componentVec the connected component ID for each vertex
61
* @param idxMap the index map of the underlying graph to get the
62
* index of a requested vertex
63
*/
64
node_is_in_component
(
const
int
componentID
65
,
const
ComponentIdVec
&
componentVec
66
,
const
IndexMap
*
idxMap
);
67
68
//! Check if a vertex should be part of the filtered graph that
69
//! represents a specific connected component of a boost graph.
70
//! @return true if the node should be represented, false otherwise.
71
template
<
typename
VERTEX>
72
bool
operator()
(
const
VERTEX& node)
const
;
73
};
74
75
/*!
76
* A boost graph edge filter used as EdgePredicate of a
77
* boost::filtered_graph to represent a specific connected component
78
* of a Molecule. This is needed if the added Molecule represents
79
* a set of molecules to generate a SMILES string for each of them.
80
*
81
*/
82
class
edge_is_in_component
{
83
protected
:
84
//! componentID the index of the connected component to represent
85
int
componentID
;
86
//! the connected component ID for each vertex
87
const
ComponentIdVec
*
componentVec
;
88
//! the index map of the underlying graph to get the index of a
89
//! requested vertex
90
const
IndexMap
*
idxMap
;
91
//! the molecule graph where the edges of interest are from
92
const
Molecule
*
m
;
93
public
:
94
95
//! empty construction
96
edge_is_in_component
();
97
98
/*! construction
99
* @param componentID the index of the connected component to
100
* represent
101
* @param componentVec the connected component ID for each vertex
102
* @param idxMap the index map of the underlying graph to get the
103
* index of a requested vertex
104
* @param m the molecule graph where the edges of interest are
105
* from
106
*/
107
edge_is_in_component
(
const
int
componentID
108
,
const
ComponentIdVec
&
componentVec
109
,
const
IndexMap
*
idxMap
110
,
const
Molecule
&
m
);
111
112
113
//! Check if an edge should be part of the filtered graph that
114
//! represents a specific connected component of a boost graph.
115
//! @return true if source and target graph are within the
116
//! component and should be represented, false otherwise.
117
template
<
typename
EDGE>
118
bool
operator()
(
const
EDGE& e)
const
;
119
};
120
121
122
//! a component graph definition if more than one connected
123
//! component present is present and it is needed to split the graph
124
//! to report into its components
125
typedef
boost::filtered_graph<
Molecule
126
,
edge_is_in_component
127
,
node_is_in_component
128
>
ComponentGraph
;
129
130
public
:
131
132
virtual
~GS_chem
()
133
{}
134
135
//! The reported graphs is split into its individual independent
136
//! components. Each component is forwarded to addMolecule to be
137
//! implemented by any sub class.
138
//! @param graph the graph object to add that encodes one or more
139
//! molecules
140
virtual
141
void
142
add
(
const
Molecule
& graph );
143
144
//! Adds a single molecule graph to the storage.
145
//! @param mol the molecule graph to add
146
virtual
147
void
148
addMolecule
(
const
Molecule
& mol ) = 0;
149
150
};
151
152
}
// namespace chem
153
}
// namespace ggl
154
155
#include "ggl/chem/GS_chem.icc"
156
157
#endif
/*GGL_CHEM_GS_CHEM_HH_*/
158