34 #ifndef RD_REACTIONPARSER_H_21Aug2006
35 #define RD_REACTIONPARSER_H_21Aug2006
41 #include <boost/format.hpp>
46 class ChemicalReaction;
50 :
public std::exception {
58 const char *
what() const noexcept
override {
return _msg.c_str(); };
83 const std::string &text,
84 std::map<std::string, std::string> *replacements =
nullptr,
85 bool useSmiles =
false);
123 const std::string &rxnBlock,
bool sanitize =
false,
bool removeHs =
false,
124 bool strictParsing =
true);
127 const std::string &fileName,
bool sanitize =
false,
bool removeHs =
false,
128 bool strictParsing =
true);
131 std::istream &rxnStream,
unsigned int &line,
bool sanitize =
false,
132 bool removeHs =
false,
bool strictParsing =
true);
169 std::istream &pngStream);
173 std::stringstream inStream(data);
179 std::ifstream inStream(fname.c_str(), std::ios::binary);
180 if (!inStream || (inStream.bad())) {
200 bool includeSmiles =
true,
bool includeSmarts =
false,
201 bool includeRxn =
false);
205 const std::string &pngString,
206 bool includePkl =
true,
207 bool includeSmiles =
true,
208 bool includeSmarts =
false,
209 bool includeRxn =
false) {
210 std::stringstream inStream(pngString);
212 rxn, inStream, includePkl, includeSmiles, includeSmarts, includeRxn);
217 const std::string &fname,
218 bool includePkl =
true,
219 bool includeSmiles =
true,
220 bool includeSmarts =
false,
221 bool includeRxn =
false) {
222 std::ifstream inStream(fname.c_str(), std::ios::binary);
224 rxn, inStream, includePkl, includeSmiles, includeSmarts, includeRxn);
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() noexcept
ChemicalReactionParserException(const char *msg)
construct with an error message
ChemicalReactionParserException(const std::string &msg)
construct with an error message
This is a class for storing and applying general chemical reactions.
#define RDKIT_CHEMREACTIONS_EXPORT
RDKIT_GRAPHMOL_EXPORT ROMol * removeHs(const ROMol &mol, bool implicitOnly=false, bool updateExplicitCount=false, bool sanitize=true)
returns a copy of a molecule with hydrogens removed
RDKIT_CHEMREACTIONS_EXPORT const std::string rxnRxnTag
RDKIT_CHEMREACTIONS_EXPORT const std::string rxnSmilesTag
RDKIT_CHEMREACTIONS_EXPORT const std::string rxnSmartsTag
RDKIT_CHEMREACTIONS_EXPORT const std::string rxnPklTag
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnSmiles(const ChemicalReaction &rxn, bool canonical=true)
returns the reaction SMILES for a reaction
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
RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction * RxnBlockToChemicalReaction(const std::string &rxnBlock, bool sanitize=false, bool removeHs=false, bool strictParsing=true)
Parse a text block in MDL rxn format into a ChemicalReaction.
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...
RDKIT_CHEMREACTIONS_EXPORT ROMol * ChemicalReactionToRxnMol(const ChemicalReaction &rxn)
returns a ROMol with RXN roles used to describe the reaction
ChemicalReaction * PNGStringToChemicalReaction(const std::string &data)
constructs a ChemicalReaction from the metadata in a PNG string See PNGStreamToChemicalReaction() for...
RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction * RxnDataStreamToChemicalReaction(std::istream &rxnStream, unsigned int &line, bool sanitize=false, bool removeHs=false, bool strictParsing=true)
Parse a text stream in MDL rxn format into a ChemicalReaction.
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnSmarts(const ChemicalReaction &rxn)
returns the reaction SMARTS for a reaction
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...
RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction * RxnFileToChemicalReaction(const std::string &fileName, bool sanitize=false, bool removeHs=false, bool strictParsing=true)
Parse a file in MDL rxn format into a ChemicalReaction.
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnBlock(const ChemicalReaction &rxn, bool separateAgents=false)
returns an rxn block for a reaction
RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction * RxnMolToChemicalReaction(const ROMol &mol)
Parse a ROMol into a ChemicalReaction, RXN role must be set before.
RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction * RxnSmartsToChemicalReaction(const std::string &text, std::map< std::string, std::string > *replacements=nullptr, bool useSmiles=false)
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...