Generated on Wed Apr 29 2015 11:51:40 for GGL-4.1.2 by doxygen 1.8.3.1
SMILESparser.hh
Go to the documentation of this file.
1 
2 #ifndef GGL_CHEM_SMILES_PARSER_HH_
3 #define GGL_CHEM_SMILES_PARSER_HH_
4 
5 #include <utility>
6 #include <string>
7 
8 #include "ggl/chem/Molecule.hh"
10 #include "ggl/chem/ChemRule.hh"
11 
12 namespace ggl {
13  namespace chem {
14 
15 
16  /*! @brief SMILES molecule parser
17  *
18  * This class is a wrapper for the ggl::chem::SMILESparser that
19  * parses SMILES via their BNF grammar. See there for further details.
20  *
21  * @author Martin Mann (c) 2012 http://www.bioinf.uni-freiburg.de/~mmann/
22  */
24  {
25  public:
26 
27 
28  /**
29  * Parses a SMILES string and generates a graph representation of the
30  * molecule
31  * @param SMILES_string the string to parse
32  * @return pair.first = the graph encoding of the molecule
33  * pair.second = -1 if parsing was successful,
34  * in error case it returns the string position that caused
35  * the parsing error
36  * @throw std::invalid_argument in case a check fails
37  */
38  static
39  std::pair< Molecule, int >
40  parseSMILES( const std::string & SMILES_string )
41  throw (std::invalid_argument);
42 
43 
44  /**
45  * Parses a SMILES string and generates a graph representation of the
46  * molecule
47  * @param SMILES_string the string to parse
48  * @param groups a container that holds group IDs where
49  * each matching node has to be replaced by the according
50  * mapped subgraph
51  * @return pair.first = the graph encoding of the molecule
52  * pair.second = -1 if parsing was successfull,
53  * in error case it returns the string position that caused
54  * the parsing error
55  * @throw std::invalid_argument in case a check fails
56  */
57  static
58  std::pair< Molecule, int >
59  parseSMILES( const std::string & SMILES_string, const GroupMap & groups )
60  throw (std::invalid_argument);
61 
62 
63  /**
64  * Parses a SMILES string of multiple molecules separated by '.'
65  * and generates a graph representation of the molecules
66  * @param SMILES_string the string to parse
67  * @return vector of according molecule graphs
68  * @throw std::invalid_argument in case a parsing fails
69  */
70  static
71  std::vector< Molecule * >
72  parseMultiSMILES( const std::string & SMILES_string )
73  throw (std::invalid_argument);
74 
75 
76  /**
77  * Parses a SMILES string of multiple molecules separated by '.'
78  * and generates a graph representation of the molecules
79  * @param SMILES_string the string to parse
80  * @param groups a container that holds group IDs where
81  * each matching node has to be replaced by the according
82  * mapped subgraph
83  * @return vector of according molecule graphs
84  * @throw std::invalid_argument in case a parsing fails
85  */
86  static
87  std::vector< Molecule * >
88  parseMultiSMILES( const std::string & SMILES_string, const GroupMap & groups )
89  throw (std::invalid_argument);
90 
91 
92  /**
93  * Parses a reaction SMILES string and uses the atom mapping encoded
94  * in the atom label class information to generate a graph grammar
95  * rule core graph, thus, each atom in the educts has to
96  * have a unique class ID and a corresponding atom (with same ID) in
97  * the products.
98  *
99  * An example '[C:13][C-2:2].[O:3]>>[O:3]=[C:2][C:13]'
100  *
101  * For protons part of complex labels like [CH3:1] are automatically
102  * given class IDs while it is expected that the adjacent atom (with
103  * given class ID) is present both in educt and product and features
104  * in both the same number of adjacent protons given without class
105  * ID within the complex atom label. Otherwise, an exception is
106  * raised.
107  *
108  * NOTE: the reaction is not checked for sanity or chemical
109  * correctness. Furthermore, no constraints etc. are generated.
110  *
111  * @param SMILES_string the string to parse
112  * @param pruneClassID whether or not the classID information is to
113  * be pruned from the atom labels
114  * @return the parsed rule core graph
115  * @throw std::invalid_argument with according description in case
116  * a check fails
117  */
118  static
120  parseReactionSMILES( const std::string & SMILES_string
121  , const bool pruneClassID = true )
122  throw (std::invalid_argument);
123 
124  protected :
125 
126 
127  /**
128  * Prunes all aromatic bonds that are not part of a ring.
129  *
130  * @param mol the molecule to correct
131  */
132  static
133  void
135 
136  }; // class SMILESparser
137 
138 
139 
140  } // namespace chem
141 } // namespace ggl
142 
143 
144 
145 #endif /*GGL_CHEM_SMILES_PARSER_HH_*/