36#ifndef RD_REACTIONPARSER_H_21Aug2006
37#define RD_REACTIONPARSER_H_21Aug2006
44#include <boost/format.hpp>
49class ChemicalReaction;
53 :
public std::exception {
59 : _msg(std::move(msg)) {}
61 const char *
what() const noexcept
override {
return _msg.c_str(); }
90 const std::
string &text,
91 std::map<std::
string, std::
string> *replacements =
nullptr,
92 bool useSmiles = false,
bool allowCXSMILES = true);
129 const std::
string &rxnBlock,
bool sanitize = false,
bool removeHs = false,
130 bool strictParsing = true);
133 const std::
string &fileName,
bool sanitize = false,
bool removeHs = false,
134 bool strictParsing = true);
137 std::istream &rxnStream,
unsigned int &line,
bool sanitize = false,
138 bool removeHs = false,
bool strictParsing = true);
152 bool forceV3000 = false);
190 std::istream &pngStream);
194 std::stringstream inStream(data);
200 std::ifstream inStream(fname.c_str(), std::ios::binary);
201 if (!inStream || (inStream.bad())) {
221 bool includeSmiles =
true,
bool includeSmarts =
false,
222 bool includeRxn =
false);
226 const std::string &pngString,
227 bool includePkl =
true,
228 bool includeSmiles =
true,
229 bool includeSmarts =
false,
230 bool includeRxn =
false) {
231 std::stringstream inStream(pngString);
233 rxn, inStream, includePkl, includeSmiles, includeSmarts, includeRxn);
238 const std::string &fname,
239 bool includePkl =
true,
240 bool includeSmiles =
true,
241 bool includeSmarts =
false,
242 bool includeRxn =
false) {
243 std::ifstream inStream(fname.c_str(), std::ios::binary);
245 rxn, inStream, includePkl, includeSmiles, includeSmarts, includeRxn);
249inline std::unique_ptr<ChemicalReaction>
operator"" _rxnsmarts(
const char *text,
251 std::string sma(text, len);
258 return std::unique_ptr<ChemicalReaction>(ptr);
260inline std::unique_ptr<ChemicalReaction>
operator"" _rxnsmiles(
const char *text,
262 std::string sma(text, len);
269 return std::unique_ptr<ChemicalReaction>(ptr);
279 bool removeHs =
false);
283 bool removeHs =
false);
287 bool sanitize =
false,
288 bool removeHs =
false);
used by various file parsing classes to indicate a bad file
used to indicate an error in parsing reaction data
const char * what() const noexcept override
get the error message
ChemicalReactionParserException(std::string msg)
construct with an error message
~ChemicalReactionParserException() noexcept override=default
ChemicalReactionParserException(const char *msg)
construct with an error message
This is a class for storing and applying general chemical reactions.
#define RDKIT_CHEMREACTIONS_EXPORT
RDKIT_CHEMREACTIONS_EXPORT std::vector< std::unique_ptr< ChemicalReaction > > CDXMLFileToChemicalReactions(const std::string &fileName, bool sanitize=false, bool removeHs=false)
Parse a file in CDXML rxn format into a vector of ChemicalReactions.
RDKIT_CHEMREACTIONS_EXPORT std::vector< std::unique_ptr< ChemicalReaction > > CDXMLDataStreamToChemicalReactions(std::istream &rxnStream, bool sanitize=false, bool removeHs=false)
Parse a text stream in CDXML rxn format into a vector of ChemicalReactions.
RDKIT_CHEMREACTIONS_EXPORT std::vector< std::unique_ptr< ChemicalReaction > > CDXMLToChemicalReactions(const std::string &rxnBlock, bool sanitize=false, bool removeHs=false)
Parse text in CDXML rxn format into a vector of ChemicalReactions.
RDKIT_CHEMREACTIONS_EXPORT std::string addChemicalReactionToPNGStream(const ChemicalReaction &rxn, std::istream &iStream, bool includePkl=true, bool includeSmiles=true, bool includeSmarts=false, bool includeRxn=false)
adds metadata for a ChemicalReaction to the data from a PNG stream. The modified PNG data is returned...
ChemicalReaction * PNGFileToChemicalReaction(const std::string &fname)
constructs a ChemicalReaction from the metadata in a PNG file See PNGStreamToChemicalReaction() for m...
RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction * PNGStreamToChemicalReaction(std::istream &pngStream)
constructs a ChemicalReaction from the metadata in a PNG stream
std::string addChemicalReactionToPNGFile(const ChemicalReaction &rxn, const std::string &fname, bool includePkl=true, bool includeSmiles=true, bool includeSmarts=false, bool includeRxn=false)
adds metadata for a ChemicalReaction to the data from a PNG string. See addChemicalReactionToPNGStrea...
ChemicalReaction * PNGStringToChemicalReaction(const std::string &data)
constructs a ChemicalReaction from the metadata in a PNG string See PNGStreamToChemicalReaction() for...
RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction * RxnSmartsToChemicalReaction(const std::string &text, std::map< std::string, std::string > *replacements=nullptr, bool useSmiles=false, bool allowCXSMILES=true)
Parse a string containing "Reaction SMARTS" into a ChemicalReaction.
std::string addChemicalReactionToPNGString(const ChemicalReaction &rxn, const std::string &pngString, bool includePkl=true, bool includeSmiles=true, bool includeSmarts=false, bool includeRxn=false)
adds metadata for a ChemicalReaction to the data from a PNG string. See addChemicalReactionToPNGStrea...